Jump to content

help with auto it


Recommended Posts

I want this to press certain buttons when some hot key is pressed

for an example in this script

I want it to

when I press w it simulates that i pressed w and clicks the left mouse (wherever the cursor's at)

and etc i need it to do the same thing just different letters on w it presses w on a it presses a and etc.

so can some1 please remodulate this code I need it to work in any window that is open :(

$a = ('1')
While $a = ('1')
    If _IsPressed(57) = 1 Then
        Send('w')
        MouseClick("left")
    EndIf
    If _IsPressed(41) = 1 Then
        Send('a')
        MouseClick("left")
    EndIf
    If _IsPressed(44) = 1 Then
        Send('d')
        MouseClick("left")
    EndIf
    If _IsPressed(53) = 1 Then
        Send('s')
        MouseClick("left")
    EndIf

WEnd
Link to comment
Share on other sites

I've shortened the code a bit, so only the first two letters are there, but this is basically it. Take out the 'ExitLoop' lines if this has to loop continuously.

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep(100)
    If _IsPressed("57", $dll) Then
        Send('w')
        MouseClick("left")
        ExitLoop
    EndIf
    If _IsPressed("41", $dll) Then
        Send('a')
        MouseClick("left")
        ExitLoop
    EndIf
WEnd
Edited by snowmaker

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

1st basic question, what is $a = ('1') for. If you need an infinite loop just do While True.

2nd, since I see wasd I am assuming you want to click while moving in a game. And with multiple calls in a row to determine if the button is still pressed you would probably open the "user32.dll" as suggested in the help for _IsPressed(), and pass its handle.

Look at the example in the manual.

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep ( 250 )
    If _IsPressed("23", $dll) Then
        MsgBox(0,"_IsPressed", "End Key Pressed")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

Edit: oh someone posted reply already doh

Edit again: although I would put DllClose($dll) at the end

Edited by ShawnW
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...