warcrow Posted November 27, 2007 Share Posted November 27, 2007 Hi guys!Not sure what's going on here, but I have an automated install that is not completing. For some reason it freezes on the first button--but it use to work--it's so weird. Here is the (simple) code:run("c:\migration\NCS_DOCK_INSTALL.exe") winwaitactive("USB","") controlclick("USB", "", 1);next button winwaitactive("USB","DOCKING") controlclick("HI-Speed USB 2.0", "DOCKING", 1);next button winwaitactive("HI-Speed USB 2.0)","") controlclick("HI-Speed USB 2.0", "", 4);rebootIt's a simple script, but I have no idea what's going on here. Here is a screenshot of the info window. Link to comment Share on other sites More sharing options...
Fossil Rock Posted November 27, 2007 Share Posted November 27, 2007 Try;WinTitleMatchMode - Alters the method that is used to match window titles during search operations.1 = Match the title from the start (default)2 = Match any substring in the title3 = Exact title match4 = Advanced mode, see Window Titles & Text (Advanced)-1 to -4 = force lower case match according to other type of match. Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
warcrow Posted November 27, 2007 Author Share Posted November 27, 2007 AutoItSetOption("wintitlematchmode", 2) Correct? Link to comment Share on other sites More sharing options...
warcrow Posted November 27, 2007 Author Share Posted November 27, 2007 Hrm--darn! Didnt work. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 27, 2007 Share Posted November 27, 2007 Hrm--darn! Didnt work. The second ControlClick should work, but the window you showed details for does not match the first one. Note the change in title used from "USB" to "HI-Speed USB 2.0", while you only show the info for "HI-Speed USB 2.0". Does the window title change? Also, use the following format to specify the control: ControlClick("HI-Speed USB 2.0", "DOCKING", "[CLASS:Button; INSTANCE:1]") ; Next button Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Klaatu Posted November 27, 2007 Share Posted November 27, 2007 I don't see the word "DOCKING" in the window's visible text. Maybe that's the problem. My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
warcrow Posted November 27, 2007 Author Share Posted November 27, 2007 The second ControlClick should work, but the window you showed details for does not match the first one. Note the change in title used from "USB" to "HI-Speed USB 2.0", while you only show the info for "HI-Speed USB 2.0". Does the window title change? Also, use the following format to specify the control: ControlClick("HI-Speed USB 2.0", "DOCKING", "[CLASS:Button; INSTANCE:1]") ; Next button run("c:\migration\NCS_DOCK_INSTALL.exe") winwaitactive("HI-Speed","") ControlClick("HI-Speed USB 2.0", "DOCKING", "[CLASS:Button; INSTANCE:1]"); Next button winwaitactive("HI-Speed","DOCKING") controlclick("HI-Speed USB 2.0", "DOCKING", 1);next button winwaitactive("HI-Speed USB 2.0)","") controlclick("HI-Speed USB 2.0", "", 4);reboot Like this? Didnt work. Link to comment Share on other sites More sharing options...
Klaatu Posted November 27, 2007 Share Posted November 27, 2007 (edited) run("c:\migration\NCS_DOCK_INSTALL.exe") winwaitactive("HI-Speed","") ControlClick("HI-Speed USB 2.0", "DOCKING", "[CLASS:Button; INSTANCE:1]"); Next button winwaitactive("HI-Speed","DOCKING") controlclick("HI-Speed USB 2.0", "DOCKING", 1);next button winwaitactive("HI-Speed USB 2.0)","") controlclick("HI-Speed USB 2.0", "", 4);reboot Like this? Didnt work. Yes, but what isn't working? You seem to be mixing up the window titles and texts so much it's a wonder any of it does. Is it getting hung up on any of the winwaitactive lines maybe?That's the first thing I'd make sure of if I were trying to debug it anyway. If you really want to see where it's getting hung up (if it is), try using my DebugIt script from my sig. Or someone else's if you don't care for mine. And if it's not getting hung up, well that tells us something too. Edited November 27, 2007 by Klaatu My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 27, 2007 Share Posted November 27, 2007 run("c:\migration\NCS_DOCK_INSTALL.exe") winwaitactive("HI-Speed","") ControlClick("HI-Speed USB 2.0", "DOCKING", "[CLASS:Button; INSTANCE:1]"); Next button winwaitactive("HI-Speed","DOCKING") controlclick("HI-Speed USB 2.0", "DOCKING", 1);next button winwaitactive("HI-Speed USB 2.0)","") controlclick("HI-Speed USB 2.0", "", 4);reboot Like this? Didnt work. You didn't answer the question about the window title. Get the window handle as soon as possible, and don't bother with the title from then on: run("c:\migration\NCS_DOCK_INSTALL.exe") If Not WinWait("HI-Speed USB", "", 5) Then MsgBox(16, "Error", "Did not see window before timeout!") Exit EndIf $hWin = WinGetHandle("HI-Speed USB") WinActivate($hWin) winwaitactive($hWin) controlclick($hWin, "", "[CLASS:Button; INSTANCE:1]") ; next button And the control could also be: "[CLASSNN:Button1]" Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
warcrow Posted November 28, 2007 Author Share Posted November 28, 2007 Sorry--I'm the only admin here this week (holiday vacations) so I'm covering everything on the helpdesk too for a 70 person office. In the rush of things I must have forgotten some details. Let me try to answer some questions and be more clear to make things easier for everyone (since I'm the one that needs help here). Again--thank you for your time!Below (screenshot) is the info windows for the first button that is not being clicked by the script. I've tried the following code (from what I recall) and have been, so far, unsuccessful:run("c:\migration\NCS_DOCK_INSTALL.exe") WinWaitActive(""HI-Speed USB 2.0") ControlClick("HI-Speed USB 2.0", "DOCKING", "[CLASS:Button; INSTANCE:1]"); Next buttonrun("c:\migration\NCS_DOCK_INSTALL.exe") winwaitactive("HI-Speed","") ControlClick("HI-Speed USB 2.0", "DOCKING", "[CLASS:Button; INSTANCE:1]"); Next buttonrun("c:\migration\NCS_DOCK_INSTALL.exe") winwaitactive("USB","") controlclick("USB", "", 1);next buttonrun("c:\migration\NCS_DOCK_INSTALL.exe") If Not WinWait("HI-Speed USB", "", 5) Then MsgBox(16, "Error", "Did not see window before timeout!") Exit EndIf $hWin = WinGetHandle("HI-Speed USB") WinActivate($hWin) winwaitactive($hWin) controlclick($hWin, "", "[CLASS:Button; INSTANCE:1]"); next buttonand finally....run("c:\migration\NCS_DOCK_INSTALL.exe") If Not WinWait("HI-Speed USB", "", 5) Then MsgBox(16, "Error", "Did not see window before timeout!") Exit EndIf $hWin = WinGetHandle("HI-Speed USB") WinActivate($hWin) winwaitactive($hWin) controlclick($hWin, "", "[CLASSNN:Button1]"); next buttonScreenshot info window for first buttonThe second button works with the following code:winwaitactive("HI-Speed","DOCKING") controlclick("HI-Speed USB 2.0", "DOCKING", 1);next buttonHere is the screenshot of the info window for the second button. Link to comment Share on other sites More sharing options...
warcrow Posted November 28, 2007 Author Share Posted November 28, 2007 Also, FYI--I started a new script and just put in: run ( "c:\migration\NCS_DOCK_INSTALL.exe" ) winwaitactive ( "VGA", "") send("{SPACE}") run ( "c:\migration\NCS_DOCK_INSTALL.exe" ) winwaitactive ( "HI-Speed USB 2.0 Dockstation with VGA Passthrough Driver Install", "") send("{SPACE}") run ( "c:\migration\NCS_DOCK_INSTALL.exe" ) winwaitactive ( "HI-Speed", "") send("{SPACE}") So, just to try something different, you can see I switched to the spacebar (the spacebar works when I manually install because that button is defaulted to). So, it must be an identification issue, right? Is there a chance that autoit isnt reading the right info? Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 28, 2007 Share Posted November 28, 2007 One possibility is that the Button1 control is not ready/enabled when the window comes up. The script as is will attempt ControlClick() within milliseconds of the window coming up. This could slow things down a bit and wait until the control is enabled to click it: Run("c:\migration\NCS_DOCK_INSTALL.exe") If Not WinWait("HI-Speed USB", "", 5) Then MsgBox(16, "Error", "Did not see window before timeout!") Exit EndIf $hWin = WinGetHandle("HI-Speed USB") WinActivate($hWin) WinWaitActive($hWin) Sleep(2000) ; 2sec delay $iTimer = TimerInit() While 1 If ControlCommand($hWin, "", "[CLASSNN:Button1]", "IsEnabled") Then $iTimer = Round(TimerDiff($iTimer) / 1000, 3) ControlClick($hWin, "", "[CLASSNN:Button1]"); next button MsgBox(64, "Click", "Clicked Button1 after " & $iTimer & "secs") ExitLoop EndIf Sleep(20) WEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
warcrow Posted November 28, 2007 Author Share Posted November 28, 2007 It worked! The little msgbox popped up though: MsgBox(64, "Click", "Clicked Button1 after " & $iTimer & "secs") You must be right--it's a timing issue. That would explain why it some times works and doesnt work on different machines--different cpu speeds? Link to comment Share on other sites More sharing options...
warcrow Posted November 28, 2007 Author Share Posted November 28, 2007 (edited) I just ran it twice--both times it just sat there after calling the .exe and didnt click the button. This is odd--I starting to think it's me. :-/-edit-I created a new script--copy and pasted your code and it works again. I didnt touch or change a thing in the previous one. Edited November 28, 2007 by warcrow Link to comment Share on other sites More sharing options...
warcrow Posted November 28, 2007 Author Share Posted November 28, 2007 One possibility is that the Button1 control is not ready/enabled when the window comes up. The script as is will attempt ControlClick() within milliseconds of the window coming up. This could slow things down a bit and wait until the control is enabled to click it: Run("c:\migration\NCS_DOCK_INSTALL.exe") If Not WinWait("HI-Speed USB", "", 5) Then MsgBox(16, "Error", "Did not see window before timeout!") Exit EndIf $hWin = WinGetHandle("HI-Speed USB") WinActivate($hWin) WinWaitActive($hWin) Sleep(2000) ; 2sec delay $iTimer = TimerInit() While 1 If ControlCommand($hWin, "", "[CLASSNN:Button1]", "IsEnabled") Then $iTimer = Round(TimerDiff($iTimer) / 1000, 3) ControlClick($hWin, "", "[CLASSNN:Button1]"); next button MsgBox(64, "Click", "Clicked Button1 after " & $iTimer & "secs") ExitLoop EndIf Sleep(20) WEnd It's not working now. How can something like this be intermitant? I dont understand what the variable could be? Link to comment Share on other sites More sharing options...
warcrow Posted November 29, 2007 Author Share Posted November 29, 2007 Anyone? Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 29, 2007 Share Posted November 29, 2007 It's not working now. How can something like this be intermitant? I dont understand what the variable could be? I'm not clear if it never sees the button enabled, or tries to click and fails. Perhaps this mod will help diagnose the issue: Sleep(2000) ; 2sec delay $iTimer = TimerInit() While 1 If ControlCommand($hWin, "", "[CLASSNN:Button1]", "IsEnabled") Then $iTimer = Round(TimerDiff($iTimer) / 1000, 3) If ControlClick($hWin, "", "[CLASSNN:Button1]") Then ; next button TrayTip("Debug", "Cicked Button1", 5) Else MsgBox(16, "Error", "Attempted to click Button1 and failed.") EndIf MsgBox(64, "Click", "Clicked Button1 after " & $iTimer & "secs") ExitLoop EndIf Sleep(20) WEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
warcrow Posted November 29, 2007 Author Share Posted November 29, 2007 (edited) I used this code (hopefully it's correct on my part):Run("c:\migration\NCS_DOCK_INSTALL.exe") If Not WinWait("HI-Speed USB", "", 5) Then MsgBox(16, "Error", "Did not see window before timeout!") Exit EndIf $hWin = WinGetHandle("HI-Speed USB") WinActivate($hWin) WinWaitActive($hWin) Sleep(2000); 2sec delay $iTimer = TimerInit() While 1 If ControlCommand($hWin, "", "[CLASSNN:Button1]", "IsEnabled") Then $iTimer = Round(TimerDiff($iTimer) / 1000, 3) If ControlClick($hWin, "", "[CLASSNN:Button1]") Then; next button TrayTip("Debug", "Cicked Button1", 5) Else MsgBox(16, "Error", "Attempted to click Button1 and failed.") EndIf MsgBox(64, "Click", "Clicked Button1 after " & $iTimer & "secs") ExitLoop EndIf Sleep(20) WEndWhat happened is, it stalls on the first click. Also, no windows pop up either. I waited a full minute too just to make sure. I took a screenshot along with the info window next to the install so that all the info is present. Edited November 29, 2007 by warcrow Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 29, 2007 Share Posted November 29, 2007 I used this code (hopefully it's correct on my part): What happened is, it stalls on the first click. Also, no windows pop up either. I waited a full minute too just to make sure. I took a screenshot along with the info window next to the install so that all the info is present. I have scripted several InstallShield Wizards, and have had no such trouble with them. Try this (takes the diagnostic reporting to the next level): expandcollapse popupOpt("TrayIconDebug", 1) Global $DebugMsg = "" Run("c:\migration\NCS_DOCK_INSTALL.exe") If Not WinWait("HI-Speed USB", "", 5) Then ; Wait max 5sec MsgBox(16, "Error", "Did not see window before timeout!") Exit EndIf $hWin = WinGetHandle("HI-Speed USB") WinActivate($hWin) If Not WinWaitActive($hWin, "", 5) Then ; Wait max 5sec MsgBox(16, "Error", "Window did not become active before timeout.") Exit EndIf Sleep(2000); 2sec delay after window is active $iTimer = TimerInit() $sButtonText &= ControlGetText($hWin, "", "[CLASSNN:Button1]") $DebugMsg &= "Button1 text read = " & $sButtonText & @LF TrayTip("Debug", $DebugMsg, 5) If ControlFocus($hWin, "", "[CLASSNN:Button1]") Then $DebugMsg &= "Focus: Success" & @LF Else $DebugMsg &= "Focus: Failed" & @LF EndIf TrayTip("Debug", $DebugMsg, 5) If ControlCommand($hWin, "", "[CLASSNN:Button1]", "IsEnabled") Then $DebugMsg &= "IsEnabled = True" & @LF TrayTip("Debug", $DebugMsg, 5) If ControlClick($hWin, "", "[CLASSNN:Button1]") Then; next button $DebugMsg &= "ControlClick: Success" & @LF Else $DebugMsg &= "ControlClick: Failed" & @LF EndIf TrayTip("Debug", $DebugMsg, 5) Else $DebugMsg &= "IsEnabled = False" & @LF EndIf TrayTip("Debug", $DebugMsg, 5) ; All done MsgBox(64, "Debug", "Finished: $DebugMsg = " & @CRLF & $DebugMsg) The tray tips only come up for 5sec max, but if it gets hung, the TrayIconDebug option will allow you to put the mouse over the tray icon and see where the script is. We will run this sucker to ground... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
warcrow Posted November 30, 2007 Author Share Posted November 30, 2007 (edited) So--it looks like we need to force, some how, the windows to become active? Edited November 30, 2007 by warcrow 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