Tidetracker Posted March 8, 2010 Share Posted March 8, 2010 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? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 8, 2010 Moderators Share Posted March 8, 2010 Tidetracker,I'm just learning thisWe 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. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tidetracker Posted March 8, 2010 Author Share Posted March 8, 2010 (edited) 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. 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 March 8, 2010 by Tidetracker Link to comment Share on other sites More sharing options...
dani Posted March 8, 2010 Share Posted March 8, 2010 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 8, 2010 Moderators Share Posted March 8, 2010 (edited) Tidetracker, Unfortunately, a fixed time delay is an unaceptable solutionYou 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. 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". 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. Edit: Speeling. Edited March 8, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tidetracker Posted March 8, 2010 Author Share Posted March 8, 2010 Still no luckI'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. Link to comment Share on other sites More sharing options...
Tidetracker Posted March 8, 2010 Author Share Posted March 8, 2010 OK, a little further information:ControlClick("Add Bluetooth Device Wizard","","[CLASS:SysListView32; instance:1]")MsgBox(0,"Testing...","DF2D found")ExitThe 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? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now