Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make window active
#1
Hello everybody

This is my first post, although I've been "using" QM for 3 years now.

I have this probably trivial problem which I have been trying to solve but don't seem to be able to.

I have to manually start my computer's boradband connection whenever the computer is turned on. The boradband is launched by a program supplied by the service provider. A window pops up and I just click "connect" and that's it.

So I thought I'd just put a simple macro in the start-up folder, call the connection program and then have QM click "connect" (or key in the short-cut key).

The irritating thing is that the window keeps on being de-focussed. This is probably caused by other programs still loading in the background, the greatest culprit is probably the McAfee anti-virus software.

I have tried what I know, which is frightfully little, to no avail.

Help! Thank you all in advance. Smile

System information:
OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 2 Build 2600
OS Manufacturer Microsoft Corporation
System Name YOUR-073FD0D65C
System Manufacturer FUJITSU
System Model LifeBook E Series
System Type X86-based PC
Processor x86 Family 6 Model 15 Stepping 6 GenuineIntel ~1995 Mhz
BIOS Version/Date FUJITSU // Phoenix Technologies Ltd. Version 1.15, 8/23/2006
SMBIOS Version 2.4

Total Physical Memory 2,048.00 MB
Available Physical Memory 1.02 GB
Total Virtual Memory 2.00 GB
Available Virtual Memory 1.96 GB
Page File Space 3.35 GB
Page File C:\pagefile.sys
#2
have you tried the command "act"? If you do set up a macro to run at startup, you may need to include some sort of wait command to ensure that it only occurs when the window exists. If it is a button, I would suggest using accessible objects (found in the toolbar, click the window->Accessible Object Actions->Drag it to the button that needs to be clicked->use DoDefaultAction for this variable, this does not require the window is active)


act should work, if not possibly a combination of two or more of these
Macro
Code:
Copy      Help
int hwnd = win("Notepad")
act hwnd ;;activate
;ont hwnd ;;make it always on top
;res hwnd ;;unminimize
;wait 0 WC "Notepad" ;;wait for window created
;wait 0 WA "Notepad" ;;wait for window active
;wait 0 WV "Notepad" ;;wait for window visible
#3
Thank you very much. I'll try it out.
#4
Hi

>>I would suggest using accessible objects (found in the toolbar, click the window->Accessible Object Actions->Drag it to the button that needs to be clicked->use DoDefaultAction for this variable, this does not require the window is active)<<

In the past week I've tried this several times but it didn't seem to do anything. Did you mean to click and hold "Accessible Object Actions" and then drag it to the button? I did that and nothing happened.

>>have you tried the command "act"? If you do set up a macro to run at startup, you may need to include some sort of wait command to ensure that it only occurs when the window exists.<<

"act" is what I tried at the very beginning. I also inserted a command to wait until the window exists, and then invoke "act". But the problem is after "act" is run but before QM could push the button, some program in the background snatched "active" status from this window and there is no way for the macro to know this. I even tried first waiting for a long time, say 2 minutes, so that whatever startup programs have all been run, and then invoke "act", but somehow nothing happened after the 2 minutes. I then became very frustrated and didn't try again.

In fact, another macro also did not run. That macro tries to print something by clicking on a button, wait for a printing software to show a preview, delete the second (and last) page, and then print. Every time I record the macro, it ran fine for about 2 to 3 days, and after that it simply didn't do anything.

These 2 macros are the only macros that I have written. Because of these failures I did not try writing another macro. In other words, QM has been a complete waste of money for me so far.

I have McAfee Anti-virus running in the background.
#5
To click a button in an inactive window, use code like

Macro Macro630
Code:
Copy      Help
but child("Do&n't Save" "Button" win("Notepad" "#32770") 0x5)

To create the code use Controls dialog. Drag and drop the second Drag image onto the button.

If it does not work, use code like

Macro Macro630
Code:
Copy      Help
Acc a=acc("Don't Save" "PUSHBUTTON" win("Notepad" "#32770") "Button" "" 0x1001)
a.DoDefaultAction

To insert the first line, use Find Accessible Object dialog. Drag and drop the Drag image. For the second line use Accessible Object dialog.
#6
I followed your above instructions and here is the screen shot of the macro and the error codes.

Help!


Attached Files Image(s)
   
#7
I see you try to record something in QM toolbar. Don't need to record. These dialogs are used to insert 1 line of code (like in my previous post) in macro. And this code will close the Connect dialog. No more code is needed for the macro. Just assign "window visible" trigger, and make sure that QM is already running when the Connect dialog appears. The whole macro (better if it is function) may be like

Function auto_connect
Trigger !v"Connect" "#32770"     Help - how to add the trigger to the macro
Code:
Copy      Help
int hwnd=val(_command)
but "Connect" hwnd

Of course you need to change window name etc, because I don't know them.
#8
Hi everybody

I have successfully (partially) implemented the macro. I don't think I can make it work perfectly because I have McAfee anti-virus also running at start-up and because it is constantly updating itself it interferes with the macro.

I now have a strange nuisance: sometimes MS Instant Messenger runs and tries to create a new account. It seems to be a very old version (I have installed a newer version).

Here is the macro:

-----
act win("" "Shell_TrayWnd")
'W{}
'Z
'CAi
wait 0 WV "Connect PCCW" ;;wait for window visible
Acc a=acc("Connect" "PUSHBUTTON" win("Connect PCCW" "#32770") "Button" "" 0x1001)
a.DoDefaultAction
------

What is happening? Help!
#9
You should follow Gintaras' advice: (here's how toSmile
  • In QM, in the window where the names of all your functions and macros are displayed (id 2202)
    Click on the function you are working with.
    Then right click and select "Properties" or just key Ctrl+P
    In the properties make sure you are on the "Trigger" tab.
    Expand the "Window" section
    Select the appropriate trigger type.
    Drag the QM target to the window...or fill in the window information manually
    Select "Ok"
    When prompted "Insert code to receive window handle" select YES.

As for what you have:
'W{} = Windows key
'Z = Escape key
'CAi = Control + Alt + i

so this really doesn't do anything...what do you want it to do?

If you need to run the program...

Code:
Copy      Help
run "Connect PCCW.exe" ;; or whatever exe is called
wait 0 WC "Connect PCCW" ;;wait for window created
Acc a=acc("Connect" "PUSHBUTTON" win("Connect PCCW" "#32770") "Button" "" 0x1001);;define the button
a.DoDefaultAction;; click the button.

I've had pretty good results with "but" and would recommend trying that too:
Code:
Copy      Help
run "Connect PCCW.exe" ;; Make sure exe name is whatever your exe is called!!
wait 0 WC "Connect PCCW" ;;wait for window created
but id(?? win(win("Connect PCCW" "#32770"));; make sure ?? is the id number of your button!!
I cannot tell from you example what your button id is, I think it may be "5"
#10
Thank you, I will try.

To answer your question
"As for what you have:
'W{} = Windows key
'Z = Escape key
'CAi = Control + Alt + i

so this really doesn't do anything...what do you want it to do?"

Control + Alt + i = invoke the connection window, I could not find the executable, so I run the short-cut that was installed by the technician.

However, in order to ensure that the shortcut key is run, the focus must be on the dektop. I can't set focus by the mouse because the mouse can be anywhere when the macro runs. I have found that the windows key will set focus on the desktop. So I used the windows key. As for the escape key, that is to remove the menu that pops up after windows key is pressed.

Thank you.
#11
Quote:I could not find the executable, so I run the short-cut that was installed by the technician

Drag and drop the shortcut to the macro. It will insert

run "theexecutable.exe"
#12
Also if you right click on the short cut then select properties, then on the "Shortcut" tab in the properties dialog the target edit box contains the location of the .exe, it should even have the quotation marks you'll need in QM! If you paste that text into QM and then put a "run" command before it you'll be up and running.

You shouldn't need to mess with the Windows key, escape key, ctl+alt+i key stuff.

You'll just need:
Code:
Copy      Help
run "$program files\Connect PCCW\Connect PCCW.exe";;What ever Target text is in Shortcut Properties
wait 0 WC "Connect PCCW"
but id(5 win(win("Connect PCCW" "#32770"));;I think 5 is the right id. Make sure it's correct.

Fill in all the right data.
#13
Here is the image of what the properties of the shortcut look like. Thanks to you all.


Attached Files Image(s)
   
#14
Did you try like Gintaras said and drag and drop?
#15
Not yet, but I'm just replying to those who advised me to use the property tab to find the executable, because I think maybe they have something else to advise me.
#16
This site explains how to turn off the prompt for an internet connection like what you have:
http://www.e-wire.net.au/support/pdf/pppoexpstartup.php

All you have to do is untick the option for prompting for a password then it will just automatically log in so you won't have to mess with window triggers.

It also goes on to tell you how to make a shortcut and drop that into the startup folder. Should be what you are looking to do.

Jimmy Vig
#17
Thank you. Unfortunately under "Properties" of my connection there is no options tab and inside "Properties" I could not find a place where it allows me to un-check user name and password.
#18
Your right clicking on the "PCCW" connection straight in the "Network Connections" window and it brings up the "PCCW" connection "Properties" dialog?

From your picture it looks like you are bringing up the "Properties" dialog for the shortcut to the "PCCW" connection and not the actual connection properties.

I set up a new connection and had it create a shortcut, then I entered the "Properties" dialog to the shortcut and it looked exactly like what your picture shows. The actual connection "Properties" dialog will not have anything involving "Shortcut" and will contain 5 tabs, one of which will be the "Options" tab.

If you cannot find the actual connection, you should probably try setting up a new network connection. It should be fairly simple to do through windows and won't cause any problems to your existing connection.

Network Connections ->File -> New Connection
Tick "Connect to the Internet" Click "Next"
Tick "Set up my connection manually" Click "Next"
Tick "Connect using a broadband connection that requires a user name and password" Click "Next"
ISP Name is just what shows up as the title of the connection...use anything here. Could use "PCCW(2)" Click "Next"
Enter your user name and password in the appropriate boxes. Your provider should have given you these.
Untick "Make this the default Internet connection" Click "Next"
Click "Finish"

Test you connection and it should work provided there are not any advanced settings that are required to connect through your modem. Make sure you disconnect your current connection before connecting with your new connection.

If it works great...if not just delete it and you'll be back to square one and will not have done any harm and keep looking for the actual connection properties.

From there you should be able to right click on the new connection, enter the "Properties" dialog where there should be a "Options" tab where you'll be able to set up the connection properties to automatically log on without showing progress or prompts.
#19
Thank you. It works now. I did not click on the properties of the shortcut, but I don't know what I clicked on! After reading your post I went back to network connections again and sure enough, under properties there was an options tab.

In one of my earlier posts I showed the shortcut dialogue to show what short-cut keys were used to invoke the connection. I do know how to create a new connection, etc, but I was not confident enough to unclick the "user name..." box.

Thanks again!
#20
Glad I could help.

Jimmy Vig


Forum Jump:


Users browsing this thread: 1 Guest(s)