sYs73m Posted September 10, 2007 Share Posted September 10, 2007 Hello! I've been trying to teach myself AutoIT, but I've been having a hard time making this script work. Odds are, I'm way off and don't know what I'm doing. Here is basically what I'm looking to do; I wanted to set a script up to do a keystroke, wait a designated amount of time, hit another keystroke, wait another designated amount of time, then I want the it to basically restart, and endlessly repeat itself until I manually turn off the script. Can anyone help me with this? I can post what I have if you want, but I'm trying to save face so I'd rather not, that way ya'll don't laugh at me! Thanks. Link to comment Share on other sites More sharing options...
Björn Kaiser Posted September 10, 2007 Share Posted September 10, 2007 i will just give you some hints While 1 SendKeys("ABC") Sleep(100) WEnd Or something close to that. I dont have the helpfile here right now. And you would need to set a hotkey to exit the script or you have to close it from the tray menu. "I teleported home one nightWith Ron and Sid and Meg.Ron stole Meggie's heart awayAnd I got Sidney's leg."- A poem about matter transference beams. Link to comment Share on other sites More sharing options...
sYs73m Posted September 10, 2007 Author Share Posted September 10, 2007 (edited) i will just give you some hints While 1 SendKeys("ABC") Sleep(100) WEnd Or something close to that. I dont have the helpfile here right now. And you would need to set a hotkey to exit the script or you have to close it from the tray menu.Yeah, it would be a manual close from the tray. I'm going to assume that the "Sleep(100)" is in seconds, although I don't understand what the "While 1" part is. I'll play with it some more. Thanks. Anyone else who can help, please do. Edit: Tried playing with what you gave me, got an error when I try to run it. I'm pretty new so I'm sorry if I'm not getting it.. Edited September 10, 2007 by sYs73m Link to comment Share on other sites More sharing options...
Björn Kaiser Posted September 10, 2007 Share Posted September 10, 2007 (edited) Yeah, it would be a manual close from the tray.I'm going to assume that the "Sleep(100)" is in seconds, although I don't understand what the "While 1" part is. I'll play with it some more. Thanks. Anyone else who can help, please do."While 1 ... WEnd" is an infinite loop, it will run until you exit the loop or the script. Sleep() uses miliseconds. oh and Read The Fine Manual. It helps. Really!edit: i knew i messed something up.Replace SendKeys() with Send() Edited September 10, 2007 by Björn Kaiser "I teleported home one nightWith Ron and Sid and Meg.Ron stole Meggie's heart awayAnd I got Sidney's leg."- A poem about matter transference beams. Link to comment Share on other sites More sharing options...
MISIIM Posted September 10, 2007 Share Posted September 10, 2007 (edited) Sleep is in milliseconds so 1000 = 1 second. It is actually Send() not SendKeys(). Edited September 10, 2007 by MISIIM Link to comment Share on other sites More sharing options...
ofLight Posted September 10, 2007 Share Posted September 10, 2007 HotKeySet("`","_Go") HotKeySet('{esc}', '_Exit') While 1 ToolTip("Press tilde to Start "&@LF&"Press ESC to Exit") Sleep(100) WEnd Func _Go() While 1 Send("{F1}") ;the Key you want to send Sleep(5000) ;Time you want to Wait, 5second ;More Sends... .. . ;More Sleeps... .. . Send(8) Sleep(5*60*1000) ;<<-------- 5 minutes Wend EndFunc Func _Exit() ToolTip(' '&@CRLF&' EXITING '&@CRLF&' ') Sleep(500) Exit EndFunc There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly Link to comment Share on other sites More sharing options...
sYs73m Posted September 10, 2007 Author Share Posted September 10, 2007 Okay, here is what I have so far, and it's mostly working; While 1 Sleep(5000) Send("{F2}") Sleep(5000) Send("3") Sleep(5000) Send("Q") Sleep(5000) Send("A") Sleep(2000) Send("D") Sleep(2000) Send("T") Sleep(40000) WEnd Pushing F2 works, pushing 3 works, pushing Q works, but after it pushes Q, it ignores the A, D and T function. Any suggestions? Thanks, ofLight, but that looks really confusing to me. I'll give it a shot if what I'm doing is useless/broken. Link to comment Share on other sites More sharing options...
Björn Kaiser Posted September 10, 2007 Share Posted September 10, 2007 ....Pushing F2 works, pushing 3 works, pushing Q works, but after it pushes Q, it ignores the A, D and T function. Any suggestions?...maybe the program/window you are trying to send input to got inactive.you can either check if the window is active every time or you can use ControlSend() as that works also with inactive windows. "I teleported home one nightWith Ron and Sid and Meg.Ron stole Meggie's heart awayAnd I got Sidney's leg."- A poem about matter transference beams. Link to comment Share on other sites More sharing options...
Zedna Posted September 10, 2007 Share Posted September 10, 2007 Thanks, ofLight, but that looks really confusing to me. I'll give it a shot if what I'm doing is useless/broken. Try this one first of all Run("c:\Program Files\AutoIt3\AutoIt.chm") Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
sYs73m Posted September 10, 2007 Author Share Posted September 10, 2007 Try this one first of all Run("c:\Program Files\AutoIt3\AutoIt.chm")/bonk Thanks everyone for their help, I managed to get it working. ofLight, I worked with yours for a bit and it was flawless, bar the fact that it bogged down the entire computer. I chopped some of it out, such as the start/stop feature. Thanks a bunch. Link to comment Share on other sites More sharing options...
sYs73m Posted September 10, 2007 Author Share Posted September 10, 2007 (edited) maybe the program/window you are trying to send input to got inactive.you can either check if the window is active every time or you can use ControlSend() as that works also with inactive windows.It wasn't that. Not sure why it wasn't working. I just started from scratch and it worked fine. Maybe I had some unknown typo in there...Edit: I've spent a good ten minutes looking for one thing; When I installed AutoIt, it asked me if I wanted to edit, or run, a script when I double-clicked it. How can I change this? I want it to run it, instead of editing it.Anyone know how I can change the setting? Searching the FAQ didn't help much either, kept getting release note updates and stuff, heh.. Edited September 10, 2007 by sYs73m Link to comment Share on other sites More sharing options...
ofLight Posted September 10, 2007 Share Posted September 10, 2007 Donno the awnser to that one but reinstalling is Easy nuff There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly Link to comment Share on other sites More sharing options...
crash748 Posted September 11, 2007 Share Posted September 11, 2007 It wasn't that. Not sure why it wasn't working. I just started from scratch and it worked fine. Maybe I had some unknown typo in there...Edit: I've spent a good ten minutes looking for one thing; When I installed AutoIt, it asked me if I wanted to edit, or run, a script when I double-clicked it. How can I change this? I want it to run it, instead of editing it.Anyone know how I can change the setting? Searching the FAQ didn't help much either, kept getting release note updates and stuff, heh..Have you install SciTE4AutoIt3.exe it was an editor which was really usefull to write your script.. In the installation you will be ask what you want to do when double clicking your script (Run or Edit).http://www.autoitscript.com/autoit3/scite/downloads 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