Showboat Posted July 30, 2007 Share Posted July 30, 2007 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 Link to comment Share on other sites More sharing options...
ChrisL Posted July 30, 2007 Share Posted July 30, 2007 (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 July 30, 2007 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Showboat Posted July 30, 2007 Author Share Posted July 30, 2007 $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. Link to comment Share on other sites More sharing options...
ChrisL Posted July 30, 2007 Share Posted July 30, 2007 (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 July 30, 2007 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
loki1982 Posted July 30, 2007 Share Posted July 30, 2007 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. Link to comment Share on other sites More sharing options...
ChrisL Posted July 30, 2007 Share Posted July 30, 2007 ^^^^ a lot more complicated than i thought...Superstar, many thanks.See the edited versions I missed resetting the timer and the "then" word [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Showboat Posted July 30, 2007 Author Share Posted July 30, 2007 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. Link to comment Share on other sites More sharing options...
ChrisL Posted July 30, 2007 Share Posted July 30, 2007 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. [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
jvanegmond Posted July 30, 2007 Share Posted July 30, 2007 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) github.com/jvanegmond 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