Jump to content

Newbie needs help with "If..."


Masternap
 Share

Recommended Posts

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

Search the Help file that comes with AutoIt for the following key words:

  • Conditional Statements
  • If Then
  • IsPressed
  • Sleep
  • While WEnd
That 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

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...