Bert Posted September 6, 2005 Posted September 6, 2005 I'm looking for a way to have a script perform a task only when the time is between 07:00 and 17:00. The script would have a while statement so it would loop while running. Once the time is 17:00, the while statement would stop, and the script would exit. I wrote some of the script, but I'm having trouble with the time part. I have no ide how to handle the time issue. I came up with this script, but it doesn't work. Any help would be helpful AutoItSetOption("WinTitleMatchMode", 2) if winexist ("name of window") Then $time = _DateTimeFormat( _NowCalc(),4) if $time == 07:00 to 17:00 while WinWaitActive ("name of window") send("!A") sleep(1500000) Wend else exit EndIf Endif The Vollatran project My blog: http://www.vollysinterestingshit.com/
AutoChris Posted September 6, 2005 Posted September 6, 2005 (edited) I'm looking for a way to have a script perform a task only when the time is between 07:00 and 17:00. The script would have a while statement so it would loop while running. Once the time is 17:00, the while statement would stop, and the script would exit. I wrote some of the script, but I'm having trouble with the time part. I have no ide how to handle the time issue. I came up with this script, but it doesn't work. Any help would be helpfulAutoItSetOption("WinTitleMatchMode", 2)if winexist ("name of window") Then $time = _DateTimeFormat( _NowCalc(),4) if $time == 07:00 to 17:00 while WinWaitActive ("name of window") send("!A") sleep(1500000) Wend else exit EndIfEndif<{POST_SNAPBACK}>I did something a little different in my script which checks for time. If @Hour = 7 Then MyFunction() ElseIf @Hour = 17 Then EndFunction() EndIfI know this isn't quite writing your code for you, but it should point you in the right direction or at least give you some ideas.Edit: Welcome to the forums! Edited September 6, 2005 by SerialKiller
Valuater Posted September 6, 2005 Posted September 6, 2005 maybe like this #include<Date.au3> AutoItSetOption("WinTitleMatchMode", 2) if WinExists("") Then $time = _DateTimeFormat( _NowCalc(),4) while $time >= "07:00" And $time <= "17:00" ;WinWaitActive ("") MsgBox(0,"", $time) send("!A") sleep(10000) $time = _DateTimeFormat( _NowCalc(),4) Wend else exit EndIf hope that helps 8)
Developers Jos Posted September 6, 2005 Developers Posted September 6, 2005 Happy to see you like the Date UDF's but in this case you can keep it real simple like: while @HOUR >= 7 And @HOUR < 17 ; ... whatever is needed here Wend SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Valuater Posted September 6, 2005 Posted September 6, 2005 (edited) Happy to see you like the Date UDF's but in this case you can keep it real simple like:while @HOUR >= 7 And @HOUR < 17 ; ... whatever is needed here Wend <{POST_SNAPBACK}>just a hobbyist following posters code...but.. you missed an "="While @HOUR >= 7 And @HOUR <= 17 ; ... whatever is needed here Wend8)Edit... maybe not? Edited September 6, 2005 by Valuater
Developers Jos Posted September 6, 2005 Developers Posted September 6, 2005 just a hobbyist following posters code...but.. you missed an "="Edit... maybe not?<{POST_SNAPBACK}>Maybe not sounds right.. Think it needs to stop at 17:00 ..... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Bert Posted September 6, 2005 Author Posted September 6, 2005 got it working I did this: AutoItSetOption("WinTitleMatchMode", 2) if WinExists("") Then while @HOUR >= 7 And @HOUR < 17 WinSetState ( "", "", @SW_SHOW) WinWaitActive ("Unicenter ServicePlus Service Desk") send("!A") sleep(1500000) Wend endif I discovered a second problem. I need to window to become active before sending the command. I tried WinSetState, but it isn't working. The Vollatran project My blog: http://www.vollysinterestingshit.com/
Developers Jos Posted September 6, 2005 Developers Posted September 6, 2005 (edited) I discovered a second problem. I need to window to become active before sending the command. I tried WinSetState, but it isn't working.<{POST_SNAPBACK}>WinSetState() doesn't change the Focus it just sets the state of the window.You could also try the Control.... commands, because that can send info to controls in a Window without having the Focus.... Edited September 6, 2005 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
GaryFrost Posted September 6, 2005 Posted September 6, 2005 WinActivate? SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Bert Posted September 7, 2005 Author Posted September 7, 2005 Got it! ;sets the title match to get only a substring in the window title AutoItSetOption("WinTitleMatchMode", 2) ;looks to see if the window exist if WinExists("Window name", "window text") Then ;Sets scope on when the while statement will run while @HOUR >= 7 And @HOUR < 17 ;sets the focus to the window in question WinActivate ( "Window name" , "window text" ) ;makes sure the window is active before sending command. I found if clicking just at that time, the keystroke might be sent to a different window. WinWaitActive ("Window name", "window text" ) ;send keystroke to refresh the window in question. In this case, a (Alt + A) send("!A") ;The script pauses for 25 minutes before looping. To loop for 1 second, you would type sleep(1000) sleep(1500000) ;End while statement Wend ;End if statement endif The Vollatran project My blog: http://www.vollysinterestingshit.com/
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