coasty Posted August 23, 2007 Share Posted August 23, 2007 Hi, Doing this is giving me a syntax error on compile; HotKeySet("{ENTER}","ButtonEventHandler($KEY_ENTER)") Can I not pass a var to ButtonEventHandler using HotKeySet? Is there a work-around for this? Thanks Link to comment Share on other sites More sharing options...
xcal Posted August 23, 2007 Share Posted August 23, 2007 You can't determine the value of your var in the function itself? How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Danny35d Posted August 23, 2007 Share Posted August 23, 2007 The only way that you can do it is by calling a function within a function.Example: Global $KEY_ENTER HotKeySet("{ENTER}","ButtonEvent") Func ButtonEvent() ButtonEventHandler($KEY_ENTER) EndFuncNote: Be sure to declare the var you going to use as GLOBAL AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Celeri Posted August 23, 2007 Share Posted August 23, 2007 (edited) Not possible to pass var to function using HotKeySet?Nope. But it all depends what you want to do. In my case, I use hotkeys to set a variable named $Hotkey and $Hotkey is evaluated at different points parts in the program like so: If $Hotkey Then ConsoleWrite("Number "&$Hotkey&" is the winner!") And here's some typical code to setup the hotkeys ... read the comments! Func Set_HOTKEY() For $i = 1 to 8; Keys 1 to 8 on the keyboard HotKeySet($i,"Def_HOTKEY"); Notice all point to the same function - There's a trick! Next EndFunc Func Def_HOTKEY() If @HotKeyPressed > 0 And @HotKeyPressed < 9 Then; @HotKeyPressed can be used to set a variable $Hotkey = @HotKeyPressed; In this case the variable is the hotkey pressed. You could use switch Else; and set up different variables/functions depending on what you want to do and what key is $Hotkey = 0; pressed ... EndIf; The check on the first line is superfluous but you never know;) EndFunc Don't forget to set Global $Hotkey at the top of your program! Edited August 23, 2007 by Celeri I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!) Link to comment Share on other sites More sharing options...
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