Jump to content

Recommended Posts

Posted

Is it possible to send a value to a function triggered by a HotKeySet?

I tried this at first but it doesn't work.

HotKeySet("q", "q_func(5)")

Func q_func($value)
  $total = $value + 10
  MsgBox(4096,"",$value & " + 10 = " & $total)
endFunc

I altered it a bit like this, some improvement because it at least shows a msgbox with the correct $total but it doesn't wait for me to press the HotKey, it just runs as soon as it reads q_func(5).

HotKeySet("q", q_func(5))

Func q_func($value)
  $total = $value + 10
  MsgBox(4096,"",$value & " + 10 = " & $total)
endFunc
Posted (edited)

Seems to me it is not possible to send a value to a function directly - at least, I couldn't get it done.

However, you could avoid it by using a second function:

HotKeySet("q", "q_func1")
$total = 0
While 1
    Sleep(100)
WEnd


Func q_func1()
  q_func2(5)
endFunc

Func q_func2($value)
  $total = $value + 10
  MsgBox(4096,"",$value & " + 10 = " & $total)
endFunc

Stupid, but working :)

Edited by Marc

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...