Sign in to follow this  
Followers 0
Showboat

Simple script won't work, help please

9 posts in this topic

I am new to autoit and need to make a script that will perfrom a few keystrokes every 5minutes.

I looked around the docs and came up with this! (mostly cut and pastes from other scripts).

$sleepTime = 1000 * 60 * 5;Five minutes = 1000 * 60 * 5

$i=0

Do

Send("{ALT}")

Send("{ALT}")

Send("{F}")

Sleep($sleepTime)

$i=i+1

Until $i=1000

Doesn't seem to work and after a while generates a fatal error!

Any ideas on how to fix it greatly appreciated.

Thx for reading

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$sleepTime = 1000 * 60 * 5;Five minutes = 1000 * 60 * 5
$i=0
$timer = TimerInit()
Do
    If TimerDiff($timer) >= $sleepTime then 
        Send("{ALT}{ALT}F") 
        $i +=1
$timer = TImerInit()
    EndIf
    Sleep (100)
Until $i=1000

Edit: Forgot to reset the timer

Edited by ChrisL

Share this post


Link to post
Share on other sites

$sleepTime = 1000 * 60 * 5;Five minutes = 1000 * 60 * 5
$i=0
$timer = TimerInit()
Do
    If TimerDiff($timer) >= $sleepTime
        Send("{ALT}{ALT}F") 
        $i +=1
    EndIf
    Sleep (100)
Until $i=1000
^^^^ a lot more complicated than i thought...

Superstar, many thanks.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

or do you mean

$sleepTime = 1000 * 60 * 5;Five minutes = 1000 * 60 * 5
$i=0
$timer = TimerInit()
Do
    If TimerDiff($timer) >= $sleepTime then
        Send("{ALT}!F") 
        $i +=1
$timer = TImerInit()
    EndIf
    Sleep (100)
Until $i=1000
Edited by ChrisL

Share this post


Link to post
Share on other sites

I am new to autoit and need to make a script that will perfrom a few keystrokes every 5minutes.

I looked around the docs and came up with this! (mostly cut and pastes from other scripts).

$sleepTime = 1000 * 60 * 5;Five minutes = 1000 * 60 * 5

$i=0

Do

Send("{ALT}")

Send("{ALT}")

Send("{F}")

Sleep($sleepTime)

$i=i+1

Until $i=1000

Doesn't seem to work and after a while generates a fatal error!

Any ideas on how to fix it greatly appreciated.

Thx for reading

Need more information on what your actually trying to do. This is what your doing

1 press alt and release

2 press alt and release

3 send a key press of f

4 wait 5 minutes

5 do this 1000 times

Im guessing you want to hold alt down if so you need Send("{ALTDOWN}") and then Send("{ALTUP}") when your done. If this is not the case and you simply want to press alt 2 times, you might try

Send("{ALT}") 
sleep(500 )
Send("{ALT}")

might be presses alt to fast to do what you need done.

Share this post


Link to post
Share on other sites

Having problems getting them working, it just seems to run! and not press any keys.

BTW should have mentioned about key presses, need it to press ALT - release, press ALT - release, press F - release. Wait 5mins then do it again, and keep doing it 1000 times.

Share this post


Link to post
Share on other sites

Having problems getting them working, it just seems to run! and not press any keys.

BTW should have mentioned about key presses, need it to press ALT - release, press ALT - release, press F - release. Wait 5mins then do it again, and keep doing it 1000 times.

It does send the keystrokes I tried it, what is it your trying to do? Cheat at a game by chance? It could be that whatever your trying to do has some protection against sending keys.

Share this post


Link to post
Share on other sites

Having problems getting them working, it just seems to run! and not press any keys.

BTW should have mentioned about key presses, need it to press ALT - release, press ALT - release, press F - release. Wait 5mins then do it again, and keep doing it 1000 times.

ChrisL has got the right idea. I just want to shed some extra light on how Send works and how keys in general are pressed.

A key is always pressed with a press and release, even simulated ones. AutoIt has an option called SendKeyDownDelay, this is the amount of time in milliseconds that the key is held down. By default the key is pressed 5 milliseconds, although you might want to set it higher like to 150ms. This is very high, but in that time the game might pick it up where else it would not. Use: Opt("SendKeyDownDelay", 150)

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