ccddtt Posted March 17, 2008 Share Posted March 17, 2008 Hi, I want run a program in assign time. like open IE visit a URL, if in 3000 second open the URL is not finished. open a messagesbox show messages "error". how can I control the assign time ? Thanks Link to comment Share on other sites More sharing options...
Dampe Posted March 17, 2008 Share Posted March 17, 2008 I suggest reading the help file Check out the following topics: @HOUR @SEC @MIN Link to comment Share on other sites More sharing options...
FreeFry Posted March 17, 2008 Share Posted March 17, 2008 I think the more appropriate way would be to use the IE udf: #include <IE.au3> $ieObj = _IECreate("www.google.com", 0, 1, 0) _IELoadWait($ieObj, 0, 3000) If @error Then MsgBox(0, "Error", "The page was not loaded in 3 seconds, exiting") Exit EndIf Link to comment Share on other sites More sharing options...
ccddtt Posted March 17, 2008 Author Share Posted March 17, 2008 I suggest reading the help fileCheck out the following topics:@HOUR@SEC@MINI red this :#include <Date.au3>Global $Sec, $Min, $Hour, $Time; 计算当前时间$StartTicks = _TimeToTicks(@HOUR,@MIN,@SEC); 计算 45 分钟后的时间$EndTicks = $StartTicks + 45 * 60 * 1000_TicksToTime($EndTicks,$Hour,$Min,$Sec)MsgBox(262144,'' , 'New Time:' & $Hour & ":" & $Min & ":" & $Sec) above . I thik "$Sec, $Min, $Hour, $Time" is not for me question Link to comment Share on other sites More sharing options...
ccddtt Posted March 17, 2008 Author Share Posted March 17, 2008 I think the more appropriate way would be to use the IE udf: #include <IE.au3> $ieObj = _IECreate("www.google.com", 0, 1, 0) _IELoadWait($ieObj, 0, 3000) If @error Then MsgBox(0, "Error", "The page was not loaded in 3 seconds, exiting") Exit EndIf thank you very much! but you answer is only for IE. how about for program? (like this ? Run("Notepad.exe", "", @SW_MAXIMIZE,3000) ??? hehe I not find this in help file....) Link to comment Share on other sites More sharing options...
FreeFry Posted March 17, 2008 Share Posted March 17, 2008 (edited) Well I guess it depends on what you want to call "Loaded" in that case, you could just check if the window is visible: Opt("WinTitleMatchMode", 4) Run("notepad") $LoadTime = _LoadWaitApp("[CLASS:Notepad]", "", 3000) If @error Then MsgBox(0, "Error", "The program was not loaded in 3 seconds, exiting") Exit EndIf MsgBox(0, "Program loaded", "Program was loaded in " & Round($LoadTime/1000, 2) & " seconds") Func _LoadWaitApp($s_wTitle, $s_wText = "", $i_TimeOut = 15000) Local $i_tHandle = TimerInit(), $i_tDiff = 0 Do Sleep(250) $i_tDiff = TimerDiff($i_tHandle) Until BitAND(WinGetState($s_wTitle, $s_wText), 2) Or $i_tDiff > $i_TimeOut ; Wait untill the window is visible, or the timer runs out If TimerDiff($i_tHandle) > $i_TimeOut Then SetError(1) Return 0 ; Timeout was hit Else SetError(0) Return $i_tDiff ; Returns the time it took for the app to launch EndIf EndFunc Edited March 17, 2008 by FreeFry Link to comment Share on other sites More sharing options...
ccddtt Posted March 17, 2008 Author Share Posted March 17, 2008 YES! Grate!,thank you very much! I will learn you post script thanks Well I guess it depends on what you want to call "Loaded" in that case, you could just check if the window is visible: Opt("WinTitleMatchMode", 4) Run("notepad") $LoadTime = _LoadWaitApp("[CLASS:Notepad]", "", 3000) If @error Then MsgBox(0, "Error", "The program was not loaded in 3 seconds, exiting") Exit EndIf MsgBox(0, "Program loaded", "Program was loaded in " & Round($LoadTime/1000, 2) & " seconds") Func _LoadWaitApp($s_wTitle, $s_wText = "", $i_TimeOut = 15000) Local $i_tHandle = TimerInit(), $i_tDiff = 0 Do Sleep(250) $i_tDiff = TimerDiff($i_tHandle) Until BitAND(WinGetState($s_wTitle, $s_wText), 2) Or $i_tDiff > $i_TimeOut ; Wait untill the window is visible, or the timer runs out If TimerDiff($i_tHandle) > $i_TimeOut Then SetError(1) Return 0 ; Timeout was hit Else SetError(0) Return $i_tDiff ; Returns the time it took for the app to launch EndIf EndFunc 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