Snuggles Posted April 30, 2006 Share Posted April 30, 2006 Hi, I'm fairly new to AutoIt and I've been playing around with it, but I can't create the script that I want just yet. All I want it to do is to press the x key on the keyboard every other second and have this run indefinitely until I close the program to end the script. Could anyone help me with this? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 30, 2006 Moderators Share Posted April 30, 2006 Hi, I'm fairly new to AutoIt and I've been playing around with it, but I can't create the script that I want just yet.All I want it to do is to press the x key on the keyboard every other second and have this run indefinitely until I close the program to end the script. Could anyone help me with this?Look at While/WEnd - Sleep() - Send() in the helpfile. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
herewasplato Posted April 30, 2006 Share Posted April 30, 2006 (edited) ...until I close the program to end the script...Welcome to the forums.What SmOke_N said and...while 1if winexists... thenif winactive... then send xelseexitendifsleepwendYou can fill in the blanks using the help file and the AutoIt Window Info tool. Edited May 1, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Snuggles Posted April 30, 2006 Author Share Posted April 30, 2006 Here is what I have so far: $i = 0 While 1 $i <= 100000 If WinExists("X Test") Then If WinActive("X Test") Then send (x) $i = $i + 1 Wend else exit endif sleep It keeps telling me that my Wend statement has no matching While statement, but I do have a While statement. I can't figure out why this won't work. Link to comment Share on other sites More sharing options...
CyberSlug Posted April 30, 2006 Share Posted April 30, 2006 Your If - EndIf statements are not balanced.The best solution is to get rid of the line If WinExists("X Test") Then since WinActive accounts for the window existing. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Snuggles Posted April 30, 2006 Author Share Posted April 30, 2006 Oh thanks. I still don't understand why it says my Wend has no matching While if there's only one While and one Wend. Did I do something wrong with my While statement? Link to comment Share on other sites More sharing options...
Valuater Posted April 30, 2006 Share Posted April 30, 2006 (edited) maybe $i = 0 While 1 $i <= 100000 If WinExists("X Test") Then If WinActive("X Test") Then Send(x) $i = $i + 1 EndIf EndIf Sleep(10) WEnd the code tags help you see the visual "use" and location of each command... also you should follow cybers suggestion 8) Edited April 30, 2006 by Valuater Link to comment Share on other sites More sharing options...
herewasplato Posted April 30, 2006 Share Posted April 30, 2006 (edited) tryWhile 1 If WinExists("X Test") Then If WinActive("X Test") Then Send("x") Else Exit EndIf Sleep(2000) WEnd Edited April 30, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Snuggles Posted April 30, 2006 Author Share Posted April 30, 2006 (edited) Ah thanks guys. One last question. It says that x is an unknown function. I thought Send(x) was the way to send the x keystroke. I also tried Send("x") with no luck. Edit: nevermind, got it working. Thanks all. =) Edited April 30, 2006 by Snuggles 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