Jump to content
Sign in to follow this  
Tidetracker

Understanding the WinWaitActive function

Recommended Posts

Tidetracker

Forgive this newbie for asking simple questions... I'm just learning this.

The WinWaitAcive function doesn't seem to be working as expected.

Here's the sequence:

MouseMove(50,140,30)

WinWaitActive("Add Bluetooth Device Wizard","DF2D")

MouseClick("left")

I'm trying to automate the pairing process for a Bluetooth device. With this line, I'm expecting that the script will wait until the "Add Bluetooth Device Wizard" window is active, and the text string "DF2D" shows up in the window. When this window does become active, the Bluetooth Wizard is waiting to find the device... and this takes 10-15 seconds or so. Until it finds the device, the string "DF2D" is nowhere in the window... but the mouseclick never seems to happen. (I do notice a little 'blip' in the cursor, before the "DF2D" appears).

Shouldn't WinWaitActive wait until the "DF2D" shows up?

Share this post


Link to post
Share on other sites
Melba23

Tidetracker,

I'm just learning this

We all are every day, believe me! :(

I wonder if everything is happening just a little too fast - often the case when automating external apps with MouseClick, etc.

Try putting a Sleep(500) between the WinWaitActive and MouseClick lines - it might just give long enough for the display to update and also for your app to realise that it can accept a click. :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Tidetracker

I wonder if everything is happening just a little too fast - often the case when automating external apps with MouseClick, etc.

Try putting a Sleep(500) between the WinWaitActive and MouseClick lines - it might just give long enough for the display to update and also for your app to realise that it can accept a click. :mellow:

I have tried that. Unfortunately, a fixed time delay is an unaceptable solution. When that window starts, it takes anywhere from 10 to 30 seconds for the Bluetooth stack to find the device... that is why I need to wait until the partial string "DF2D" shows up. I presumed that WinWaitActive would indeed wait until that string showed up.

I also tried this:

Do

sleep(100)

until WinExists("Add Bluetooth Device Wizard","DF2D")

ControlClick("Add Bluetooth Device Wizard","DF2D","[CLASS:SysListView32; instance:1]")

But this didn't work, either... I was hoping that would also eliminate the need to specify mouse cordinates.

Any other ideas?

Edited by Tidetracker

Share this post


Link to post
Share on other sites
dani

Try some debugging first with MsgBox(0, "", [debug info here]) or ConsoleWrite([debug info here]) to verify when the WinWaitActive is true. You could put a MsgBox / ConsoleWrite on the line after the WinWaitActive call.

By the way, you can pass the x and y coordinates to the MouseClick function, no need to first do a MouseMove.

Share this post


Link to post
Share on other sites
Melba23

Tidetracker,

Unfortunately, a fixed time delay is an unaceptable solution

You have misunderstood what the Sleep was for. I suggested that you place it after the WinWaitActive so that once your app had found "DF2D" (whatever that is) you gave the whole system a chance to settle before trying the MouseClick:

MouseMove(50,140,30)
WinWaitActive("Add Bluetooth Device Wizard","DF2D")
Sleep(500)
MouseClick("left")

The Sleep does not affect the WinWaitActive at all - in fact until your app window is active, the Sleep is not even actioned.

However, other than a learning point, the discussion is moot, as you say you have already tried that. :P

Another possibility:

MouseMove(50,140,30)
; Wait until the window exists
Do
    Sleep(10)
Until WinExists("Add Bluetooth Device Wizard","DF2D")
Sleep(500) ; Optional !
MouseClick("left")

Although I am not sure that is any real difference to the first code "under the hood". :mellow:

Another thought - are you sure that the "DF2D" does not appear at any point before your app displays it? Have you checked the "Hidden text" of the window with the Au3 Window Info tool?

Other than that I am out of ideas, sorry. :(

M23

P.S. Why the MouseMove before the MouseClick - you can do them together. :lol:

Edit: Speeling.

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Tidetracker

Still no luck

I'm trying this:

WinWaitActive("Add Bluetooth Device Wizard","DF2D")

sleep(25000)

ControlClick("Add Bluetooth Device Wizard","DF2D","[CLASS:SysListView32; instance:1]")

I notice that if I wait 25 seconds after the DF2D" shows up, I see the cursor briefly blink into a 'pointer plus hourglass' shape, as if a click were attempted... but the item doesn't highlight like it would if I clicked manually... and the script stalls at that point.

Any other suggestions would be appreciated.

Share this post


Link to post
Share on other sites
Tidetracker

OK, a little further information:

ControlClick("Add Bluetooth Device Wizard","","[CLASS:SysListView32; instance:1]")

MsgBox(0,"Testing...","DF2D found")

Exit

The MsgBox gets executed even before instance 1 of the specified class even appears in the window... so the 'click', if it is occuring, is happening even before there is anything to click on.

Shouldn't it be waiting until the instance actually appears?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.