Sign in to follow this  
Followers 0
guerilla

I need some help

10 posts in this topic

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.

Share this post


Link to post
Share on other sites



Look up the following functions

Send

_Timer_Init

Share this post


Link to post
Share on other sites

Thanks for the quick reply but i am still as lost as can be :unsure:

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 :unsure:

Edited by guerilla

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by dufran3

Share this post


Link to post
Share on other sites

fast training....!!! :unsure:

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0