Jump to content
Sign in to follow this  
MichaelDavid

SetHotKey without function call

Recommended Posts

MichaelDavid

Hi folks,

I am new to autoit and would like to remap a large number of keys, e.g. a->b, b->c, c->d etc. I can do this with the SetHotKey function, but then I need to define a separate function for all the keys that I want to rename.

Is there no better way? E.g. specifying the target key directly instead of a function, as in SetHotKey("a", "b"). Ideally I would like to do something like (pseudo-code):

hashmap remap

foreach key in remap do

SetHotKey(key, remap[key])

Can such a thing be done? Alternatively, I would have to generate my autoit script using an external programming language, and I would rather avoid this.

Any help is greatly appreciated.

Michael.

Share this post


Link to post
Share on other sites
WideBoyDixon

You can remap all keys to the same function and check the value of @HotKeyPressed in your function.

Share this post


Link to post
Share on other sites
MichaelDavid

Perfect, thank you.

Michael.

You can remap all keys to the same function and check the value of @HotKeyPressed in your function.

Share this post


Link to post
Share on other sites
Richard Robertson

The problem with remapping keys is that you are going to run into the problem of trying to send a hotkeyed key. If you have "a" hotkeyed, and you have "b" send "a", it will just end up calling your hotkey again.

Share this post


Link to post
Share on other sites
martin

The problem with remapping keys is that you are going to run into the problem of trying to send a hotkeyed key. If you have "a" hotkeyed, and you have "b" send "a", it will just end up calling your hotkey again.

If you do want to use Send within your HotKey function that might not be a problem. Maybe something like this would work. (Haven't tried.)

Global $HotDog = false
   
   Func AllHotKeys()
     if $Hotdog then
      HotKeySet(@HotKeyPressed,"")
      Send(@HotKeyPressed)
      HotKeySet(@HotKeyPressed,"AllHotKeys")
      return
     endif
    
   $HotDog = true
   
   ; other stuff which might include Send
   
    $HotDog = false
   EndFunc


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.