wolstech Posted November 6, 2006 Posted November 6, 2006 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 and i have tried many things. The examples for HotKeySet do not help either... Thanks in advance, wolstech
litlmike Posted November 6, 2006 Posted November 6, 2006 (edited) 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!") EndFunc Edited November 6, 2006 by litlmike _ArrayPermute()_ArrayUnique()Excel.au3 UDF
tresa Posted November 6, 2006 Posted November 6, 2006 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
wolstech Posted November 6, 2006 Author Posted November 6, 2006 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 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
tresa Posted November 6, 2006 Posted November 6, 2006 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 It's located at the end of the help topic HotKeySet......The called function can not be given parameters. They will be ignored.......
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now