Sign in to follow this  
Followers 0

Pass Function Param with HotKeySet?

3 posts in this topic

I know I could just add another function that does not require a parameter

but I thought it redundant so thought to ask here. Comments in code.


Global $exitflag = 0

HotKeySet("+{ESC}", "Bye"); tried "Bye(0)" and "Bye"&(0)

Global $this = 10, $that = 0
While 1

; I want to add other conditions here that
; use the same function Bye() and pass a parameter
    If $this = $that Then Bye(1)

Func Bye($eflag = 0)
    $exitflag = $eflag

Func OnAutoItExit()
    Local $Title, $Output
        Case $exitflag=0; msg to display if HotKeySet used
            $Title = "Exit Message 0"
            $Output = "This would be message triggered by HotKeySet SHIFT+ESC"
        Case $exitflag=1; msg to display if *not* HotKeySet
            $Title = "Exit Message 1"
            $Output = "This would be message triggered in While..WEnd Loop"

Share this post

Link to post
Share on other sites

#2 ·  Posted (edited)

obviously you understand this will not work

tried "Bye(0)" and "Bye"&(0)

passing a variable is not available AFAIK

but... you might have a look at


or set one hot key as a menu for the input to set many hot keys???

not completely sure of your direction


Edited by Valuater


Share this post

Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks for the tip...Found @HotKeyPressed in help. Problem solved. :o


EDIT: To explain a little: I use the funtion Bye() to break out of loops and exit the program; I have had times where AutoIt would not break out of loop when Xfunction calls deep and exit, and this seems to work wonders for that (I am sure it is my code not autoit). I want to use OnAutoItExit() to trigger exit events like displaying a message dialog or writing to a logfile. So since I am using +ESC to trigger the function Bye() I needed a way to pass a variable to it for a custom message OnAutoItExit(), but I wanted to reuse the function Bye(). Instead, I now just have another function:

HotKeySet("+{ESC}", "HotKeyExit")
Func HotKeyExit()
Edited by rhg

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