Sign in to follow this  
Followers 0
SteeLpwnage

help with auto it

7 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

thank u very much :(

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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

Oops, I forgot to put that in..

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

Share this post


Link to post
Share on other sites

The first reply worked gr8 anyway thx again :(

Share this post


Link to post
Share on other sites

Yes, it should, and I guess it does, work, but it should have the dllclose line at the end.


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

Share this post


Link to post
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
Sign in to follow this  
Followers 0