Sign in to follow this  
Followers 0
Elettrone

Problems with HotKeySet and _IsPressed detect method

3 posts in this topic

#1 ·  Posted (edited)

#include <Misc.au3>
HotKeySet("a","Skill_1")

While 1
    Sleep(100)
WEnd

Func Skill_1()
    ;Send("a")
    While _IsPressed("41")
        ToolTip("Is Pressed!")
    WEnd
    ToolTip("")
EndFunc

The code as it is works perfectly, when i press a the key gets detected however when i remove the comment from the Send("a") line it stops working.

I need to understand why and how i can go around this problem if possible at all.

I need hotkey "a" set so that i can perform other functions after sending a so remapping to another key isn't going to work...

I also tried to disable the hotkey "a" within the function in order to actually send "a" but that is not the problem.

Any idea?

Edited by Elettrone

Share this post


Link to post
Share on other sites



You've set hotkey "a" to call Skill_1(). This immediately sends another "a", which calls the function again. So your script never gets past the first line of Skill_1()!

Try putting Send("a") at the end of the function, and the tooltip will display.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thankyou man but no, it is only natural that to really send the key "a" pressing the hotkey"a" i need to disable the hotkey within the function then send "a" but that is not the issue...the issue is that wether the hotkey is disable or enabled if i send "a" within the fuction it will not detect the key and i need the to send "a" as first action, then do the rest of the instructions...

The code becomes like this:

#include <Misc.au3>
HotKeySet("a","Skill_1")

While 1
    Sleep(100)
WEnd

Func Skill_1()
    HotKeySet("a");Disables hotkey "a" to allow Send("a") instruction
    Send("a")
    While _IsPressed("41");This block never gets executed...but why?
        ;Instrucion 1
        ;...
        ;Instrucion n
    WEnd
    ToolTip("")
    HotKeySet("a","Skill_1");Re-enables hotkey "a" when the function is done
EndFunc
Edited by Elettrone

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