Jump to content
SugarplumChum

Why isn't this simple script working?

Recommended Posts

SugarplumChum

I want the ''e'' button to hold down ''s'' and ''f'' when it's down and release ''s'' and ''f'' when its released. What am I doing wrong?

HotKeySet("e down","sf1")
HotKeySet("e up","sf2")

While(1)
WEnd

Func sf1()
Send("{s down}")
Send("{f down}")
EndFunc

Func sf2()
Send("{s up}")
Send("{f up}")
EndFunc

Edit: noticed i posted in the wrong section.

Edited by SugarplumChum

Share this post


Link to post
Share on other sites
SugarplumChum

I want the ''e'' button to hold down ''s'' and ''f'' when it's down and release ''s'' and ''f'' when its released. What am I doing wrong?

HotKeySet("e down","sf1")
HotKeySet("e up","sf2")

While(1)
WEnd

Func sf1()
Send("{s down}")
Send("{f down}")
EndFunc

Func sf2()
Send("{s up}")
Send("{f up}")
EndFunc

Share this post


Link to post
Share on other sites
aa2zz6

Does this work?

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep(10)
    ; If E key is pressed hold key S & F down until E is released
    If _IsPressed("45", $dll) Then
        Send("{s down}") ;Holds the s key down
        Send("{f down}") ;Holds the f key down
        While _IsPressed("57", $dll)
            Sleep(10)
        WEnd
    EndIf
WEnd

https://www.autoitscript.com/autoit3/docs/keywords/IfElseEndIf.htm

https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm

https://www.autoitscript.com/autoit3/docs/functions/Send.htm

Edited by aa2zz6
  • Like 1

Share this post


Link to post
Share on other sites
SugarplumChum
6 minutes ago, aa2zz6 said:

Does this work?

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep(10)
    ; If E key is pressed hold key S & F down until E is released
    If _IsPressed("45", $dll) Then
        Send("{s down}") ;Holds the s key down
        Send("{f down}") ;Holds the f key down
        While _IsPressed("57", $dll)
            Sleep(10)
        WEnd
    EndIf
WEnd

https://www.autoitscript.com/autoit3/docs/keywords/IfElseEndIf.htm

https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm

https://www.autoitscript.com/autoit3/docs/functions/Send.htm

It holds s & f down but they dont get released when i release ''e''

Share this post


Link to post
Share on other sites
aa2zz6
2 minutes ago, SugarplumChum said:

It holds s & f down but they dont get released when i release ''e''

Change the while loop to this:

While _IsPressed("45", $dll)
            Sleep(10)
        WEnd

 

  • Like 1

Share this post


Link to post
Share on other sites
JLogan3o13

Threads merged, please stick to one in the future. Also, be sure you have read the forum rules to which you were previously pointed; a second thread on gaming would not bode well for you.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
SugarplumChum
57 minutes ago, aa2zz6 said:

Change the while loop to this:

While _IsPressed("45", $dll)
            Sleep(10)
        WEnd

 

Same thing, I have to press s and f for them to be released again when i need them be released on ''e up''

Edited by SugarplumChum

Share this post


Link to post
Share on other sites
SugarplumChum
15 minutes ago, JLogan3o13 said:

Threads merged, please stick to one in the future. Also, be sure you have read the forum rules to which you were previously pointed; a second thread on gaming would not bode well for you.

Sorry my bad, wont happen again :).

Share this post


Link to post
Share on other sites
aa2zz6

Are you pressing just the "E" key down or are you pressing multiple keys?

Share this post


Link to post
Share on other sites
SugarplumChum

Just the ''E'' Key

Share this post


Link to post
Share on other sites
SugarplumChum

Fixed it =)

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    ; If E key is pressed hold key S & F down until E is released
    If _IsPressed("45", $dll) Then
        Send("{s down}") ;Holds the s key down
        Send("{f down}") ;Holds the f key down
        While _IsPressed("45", $dll)
            Sleep(10)
        WEnd
        Send("{s up}");
        Send("{f up}");
    EndIf
WEnd

Thank you aa2z6 for you help =)!

 

  • Like 1

Share this post


Link to post
Share on other sites
aa2zz6

Glad to help :) 

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

×