Masternap Posted September 26, 2007 Share Posted September 26, 2007 Hi there, I just started "learning" the Autoit script language and wanted to write a script which does the following: Every time when "Q" was pressed then wait 0,1 seconds, press "M". So it should press Q, then wait a bit and then press M. I really have no clue what I have to write into the script, so it would be really nice if someone could help me with the code. Link to comment Share on other sites More sharing options...
ssubirias3 Posted September 26, 2007 Share Posted September 26, 2007 Search the Help file that comes with AutoIt for the following key words:Conditional StatementsIf ThenIsPressedSleepWhile WEndThat should be a good start with plenty of example code under each keyword to get you started. After you've tried working with the examples and if its still not working for you, post your code and the most will help you tweak it so it works.Also be sure to read the FAQs (frequently asked questions) in the help and the sticky messages at the top of this forum. Link to comment Share on other sites More sharing options...
jvanegmond Posted September 26, 2007 Share Posted September 26, 2007 (edited) In my opinion, your script will look like this. Using these functions in this order. HotKeySet(....) While 1 Sleep(...) Wend Func .....() Sleep(...) Send(....) EndFunc Edited September 26, 2007 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Masternap Posted September 26, 2007 Author Share Posted September 26, 2007 Thank you. I now have this script: While 1 If _IsPressed("51", $dll) Then Sleep (100) Send ( "M" ) EndIf WEnd How do I stop it from pressing "M" if I hold down "Q"? If I put in a "ExitLoop" the whole it exits the whole script, that's not what I want. If I press "Q" it should press "M" once, then stop pressing until I press down "Q" again. Link to comment Share on other sites More sharing options...
ssubirias3 Posted September 26, 2007 Share Posted September 26, 2007 How do I stop it from pressing "M" if I hold down "Q"? If I put in a "ExitLoop" the whole it exits the whole script, that's not what I want. If I press "Q" it should press "M" once, then stop pressing until I press down "Q" again.Nice! I love seeing new people take the ball and run with it instead of crying about not being spoon fed! You need some more logic... and since you are showing that you are at least trying a little bit, here's the code for you. Remeber put forth an effort and don't ask a FAQ that's answered in the Help file and Forum over and over and over again... you'll be ok and get help faster than the others. #Include <Misc.au3> While 1 If _IsPressed('51') Then Send("{BACKSPACE}M") Do Sleep(100) Until Not _IsPressed('51') EndIf Sleep(100) WEnd Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 26, 2007 Share Posted September 26, 2007 Just use a variable to store if Q was pressed on the last loop, if so, don't send M again until it loops and Q is not pressed. 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