Jump to content
ImOracle

User defined Hotkey

Recommended Posts

ImOracle

Hello everyone (once again :sweating:),

 

Im creating a program that relies on using Hotkeys and i would like the user to choose which Hotkey should call which function.

So i created a list with labels just like in some games where its display like this:

 

walk forward    -    "W"

walk backwards -  "S"

 

The hard part is, to make it work. I guess i could have a little GUI displayed which said "press a button" then you press the button and the function would be assigned to that pressed button. But i dont wanna make a whole list of "_IsPressed" calls (partially because i know that would look ugly, slow down the app, maybe not even work and so on).

And yes, i know Melba, The answer to this Problem could be used as a "Keylogger" but i simply dont know any other way around it apart from a InputBox that would prompt the user to type in the corresponding KeyCode (_isPressed Codes).

 

Thank you in advance

 

Oracle

Share this post


Link to post
Share on other sites
ImOracle
$var = InputBox("HotFunc", "Enter a Letter")

HotKeySet($var, "_HotFunc")

While 3
    Sleep(333)
WEnd

Func _HotFunc()
    MsgBox(0, "HotKey", @HotKeyPressed)
EndFunc

 

That would be an options for the A-Z keys...

But what about ALT, CTRL, DEL, INS, SHIFT, WIN, and so on...

Guess they could just type it in...

and i guess i thought to complicated once again... :blink:

Share this post


Link to post
Share on other sites
ImOracle

Yea i implemented it using the typing technique, replaced all the ALT,SHIFT,WIN,CTRL using StringReplace with the corresponding Chars (!, #, + and so on) and set the resulting Hotkey to a test function. if the Hotkeyset call would return 1 it was valid and actually saved, if not repeat the whole thing.

 

Just for anyone else who might stumble upon this in a few years.

 

But thanks for the suggestion.

Share this post


Link to post
Share on other sites
ImOracle

Nice! I already knew about the HotKey UDF and thought about implementing it. But i didnt know there were the other ones aswell! That makes things much easier.

 

Thanks Zedna :thumbsup:

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

×