tamandt Posted June 11, 2008 Share Posted June 11, 2008 This function was 100% working until i added support for timeouts. Now it does not go past the winwait, even if the window exists. Here is the code: expandcollapse popupFunc LoopControlClick($title,$text,$control,$x=-1,$y=-1,$timeout=20000000) $seconds=$timeout/1000 $result=WinWait($title,$seconds) DMsg($result) If $result=1 Then If $x=-1 Then $xvar=GetCenter($title,$text,$control,0) $yvar=GetCenter($title,$text,$control,1) Else $xvar=$x $yvar=$y EndIf $timer=0 Do $state=0 $state+=ControlCommand($title,$text,$control,"IsEnabled") $state+=ControlCommand($title,$text,$control,"IsVisible") If $state<>2 Then Sleep(200) $timer+=200 EndIf If $timer>=$timeout Then ExitLoop EndIf Until $state=2 $status=0 If $timer<$timeout Then Do WinActivate($title) WinWaitActive($title,"",.5) $status=ControlClick($title,$text,$control,"Left",1,$xvar,$yvar) If $status<>1 Then Sleep(200) EndIf Until $status=1 EndIf EndIf EndFunc Link to comment Share on other sites More sharing options...
DW1 Posted June 11, 2008 Share Posted June 11, 2008 WinWait's timeout is in seconds, not milliseconds. You have it waiting for about five and a half hours if you don't supply a smaller timeout in the function. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
martin Posted June 11, 2008 Share Posted June 11, 2008 This function was 100% working until i added support for timeouts. Now it does not go past the winwait, even if the window exists. Here is the code: expandcollapse popupFunc LoopControlClick($title,$text,$control,$x=-1,$y=-1,$timeout=20000000) $seconds=$timeout/1000 $result=WinWait($title,$seconds) DMsg($result) If $result=1 Then If $x=-1 Then $xvar=GetCenter($title,$text,$control,0) $yvar=GetCenter($title,$text,$control,1) Else $xvar=$x $yvar=$y EndIf $timer=0 Do $state=0 $state+=ControlCommand($title,$text,$control,"IsEnabled") $state+=ControlCommand($title,$text,$control,"IsVisible") If $state<>2 Then Sleep(200) $timer+=200 EndIf If $timer>=$timeout Then ExitLoop EndIf Until $state=2 $status=0 If $timer<$timeout Then Do WinActivate($title) WinWaitActive($title,"",.5) $status=ControlClick($title,$text,$control,"Left",1,$xvar,$yvar) If $status<>1 Then Sleep(200) EndIf Until $status=1 EndIf EndIf EndFuncI expect it worked when you had WInWait($title) but if you want to add a time out then it must be in the third parameter not the second WimnWait($title,'',$seconds) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
tamandt Posted June 11, 2008 Author Share Posted June 11, 2008 WinWait's timeout is in seconds, not milliseconds. You have it waiting for about five and a half hours if you don't supply a smaller timeout in the function.Understood, which is why i divide it by 1000. But the window does exist, so it should go on.I need the huge # because by default I do not want the script to continue on until the window exists.... which except the ones i specify optional timeouts, always will. Link to comment Share on other sites More sharing options...
tamandt Posted June 11, 2008 Author Share Posted June 11, 2008 I expect it worked when you had WInWait($title)but if you want to add a time out then it must be in the third parameter not the secondWimnWait($title,'',$seconds)Wow that was really stupid of me. Thanks that was it. 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