Sign in to follow this  
Followers 0
wolstech

Help with HotkeySet Command

5 posts in this topic

Hi, I am writing a script that watches certain letters and then executes a function with one parameter. My code follows.

Func logit($key)
    MsgBox(0,"test","letter " & $key & " pressed!")
EndFunc

HotKeySet("a","logit(a)")

$x = 0
While 1
    $x = ($x + 1); Does nothing, just there to have something to loop...
WEnd

I currently exit via tray icon but will add an escape key as well.

My problem here is that when I run this, AU3Check comes back saying

"ERROR: logit(a)(): undefined function." And it marks the HotKeySet command as the line with the error.

I do not understand this as the functon is clearly defined and has no syntax errors. I can only get it to work if i don't send a parameter to the function, and alter the function to not accept parameters. Someone please explain what is wrong with my code. I want to get this down, but haven't :whistle: and i have tried many things. The examples for HotKeySet do not help either...

Thanks in advance,

wolstech

Share this post


Link to post
Share on other sites



How I would write it. Has been tested.

Global $key
HotKeySet("a","logit")

$x = 0
While 1
    Sleep (100)
WEnd

Func logit()
    MsgBox(0,"test","letter " & $key & " pressed!")
EndFuncoÝ÷ Ûú®¢×-ìºwjy趭¥ªÚ*.q©ëzÚâz÷­èh¶G²¾&­áè´§²>·¬±çfiÊèjëh×6
HotKeySet("a","logit")

While 1
    Sleep (100)
WEnd

Func logit()
    MsgBox(0,"test","letter " & @HotKeyPressed & " pressed!")
EndFunc

Share this post


Link to post
Share on other sites

Thanks! No wonder all my attempts weren't working. I didn't see in the docs where it says you can't use a param on a hotkeyset command. Is it even in there, and if so, where? I missed it.

Thanks for the scripts, both tresa and litlmikes :whistle:

An hotkey func cannot get param

you can retrieve the hotkey via the

@HotKeyPressed macro

HotKeySet("a","logit")

While 1
    Sleep (100)
WEnd

Func logit()
    MsgBox(0,"test","letter " & @HotKeyPressed & " pressed!")
EndFunc

Share this post


Link to post
Share on other sites

Thanks! No wonder all my attempts weren't working. I didn't see in the docs where it says you can't use a param on a hotkeyset command. Is it even in there, and if so, where? I missed it.

Thanks for the scripts, both tresa and litlmikes :whistle:

It's located at the end of the help topic HotKeySet

......

The called function can not be given parameters. They will be ignored.

......

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