guerilla Posted May 17, 2011 Share Posted May 17, 2011 I am new to this (just picked it up today) and I need help with a script. I need to be able to run a script that will press a key (F11) every hour or half hour for 14 days straight. This seems like something that would be relatively simple to do but I have absolutely no idea how to and I am in a bit of a hurry. If someone coud at least point me in the right direction it would be greatly appreciated. Link to comment Share on other sites More sharing options...
dufran3 Posted May 17, 2011 Share Posted May 17, 2011 Look up the following functions Send _Timer_Init Link to comment Share on other sites More sharing options...
guerilla Posted May 17, 2011 Author Share Posted May 17, 2011 Thanks for the quick reply but i am still as lost as can be Link to comment Share on other sites More sharing options...
Bert Posted May 17, 2011 Share Posted May 17, 2011 why are you in a hurry? We are happy to teach you to fish, not just give you fish. The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
guerilla Posted May 17, 2011 Author Share Posted May 17, 2011 (edited) why are you in a hurry? We are happy to teach you to fish, not just give you fish.I have every intention to learn to fish but I need fish soon or I will starve. Analogies aside, I need this quick because my sister would like to take pictures of (ironically) fish eggs. These eggs are see through and she would like to be able to take pictures of them in various stages of development. These eggs do not belong to her and there is only a small window of opportunity to document them before they hatch. F11 is the shortcut to take a picture with a microscope attached to my computer. I am very interested in scripting and would like to learn all about it when I have the time to but for now I do not have that luxury. I would really appreciate it if someone could write it for me (if that is not against the rules/too difficult to ask of someone) if not I could always stay home and press F11 every hour for two weeks Edited May 17, 2011 by guerilla Link to comment Share on other sites More sharing options...
dufran3 Posted May 17, 2011 Share Posted May 17, 2011 here is a start. This presses F11 if the timer goes over 60 minutes. Nothing to do w/ days yet though... AdlibRegister('_Screenshot', 2000) $tStart = TimerInit() While 1 Sleep(10) WEnd Func _Screenshot() If TimerDiff($tStart) > 3600000 Then Send("{F11}") EndIf EndFunc Link to comment Share on other sites More sharing options...
Bert Posted May 17, 2011 Share Posted May 17, 2011 OK, Happy to help! try this simple script: while 1 sleep(60000*30) ;equals 30 minutes send("{F11}") wend The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
dufran3 Posted May 17, 2011 Share Posted May 17, 2011 (edited) Presses F11 after greater than 60 minutes, checks every 2 seconds, all that can be changed by adjusting values. Also, If it has been running for greater than 14 days it will quit. #Include <Date.au3> AdlibRegister('_Screenshot', 2000) $tStart = TimerInit() While 1 Sleep(10) WEnd Func _Screenshot() If _DateDiff( 'D',"2011/05/17 00:00:00",_NowCalc()) > 14 Then Exit If TimerDiff($tStart) > 3600000 Then Send("{F11}") EndIf EndFunc Edited May 17, 2011 by dufran3 Link to comment Share on other sites More sharing options...
monoscout999 Posted May 17, 2011 Share Posted May 17, 2011 fast training....!!! you need A Loop to do a function forever and ever!!.... wiki says... A loop is a sequence of statements which is specified once but which may be carried out several times in succession. The code "inside" the loop (the body of the loop, shown below as xxx) is obeyed a specified number of times, or once for each of a collection of items, or until some condition is met.while and Wend also you need a function inside the loop to check the time elapsed _Timer_Init() Autoit help says.... Returns a timestamp (in milliseconds). and _Timer_Diff() AI help says.... Returns the difference in time from a previous call to _Timer_Init A couple of variables to store the functions returns to use later. $starttime and $timediff You need also a statement to decide what to do when the time elapsed is an hour and you need a function to send the key event when statemen acomplish send() well you start with your loop While 1 = 1 ; this will do every thing you write here while 1 is equal to 1.... that happend.... always and forever Wend so... we add the functions to check the time #Include <Timers.au3> ; the include file containing the function that we are gonna use Local $starttime = _Timer_Init() While 1 ; an easy way to write $timerdiff = _Timer_Diff($starttime) wend now we add the statement and the function that we want to do #Include <Timers.au3> Local $starttime = _Timer_Init() While 1 ; an easy way to write $timerdiff = _Timer_Diff($starttime) If $timerdiff >= 3600000 Then; these are miliseconds... 3600000 ms = 3600 seconds = 60 minutes = 1 hour Send("{F11}") $starttime = _Timer_Init() ; reset the timer EndIf WEnd copy to your SciTe the last code and try try it first with a short time to check if your microscope recive the key send... to run the script first save it and press F5 to stop it press Ctrl+breack or right click in the system tray icon and exit Link to comment Share on other sites More sharing options...
DarkestHour Posted May 17, 2011 Share Posted May 17, 2011 And just adding to MPH's script: $VAR = 0 while 1 If $VAR <> 672 Then sleep(60000*30) ;equals 30 minutes send("{F11}") $VAR = $VAR+1 EndIf wend This will do that for 14 Days. 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