Jump to content

Defining Hotkeys Durring Runtime


Recommended Posts

I am interested in knowing if autoit has the ability to read hotkey combinations from an INI that are put there during run-time?

As in, you run the script, the ini file doesn't exist. It prompts you to create say 3 hotkeys for various functions, then writes those to an INI file, that then is used to define the hotkey functions? Can this be done? Basically I want to be able to have a function so the user can define their own hot key combinations. So they do not have to manually edit an INI file or it be hard coded.

 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Link to comment
Share on other sites

  • Developers

Seems you used the wrong process to your question.
You are supposed to do some research first before posting the question. ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

That is true. I had done my google-fu but came up empty.. However, I now have the issue of, this works for capturing the hotkey, but now how to i define a hotkey with in my script? The captured keys are in hex, and the hotkeyset functions expects a text form such as ^B etc.. Do I have to convert the Hex to text? (yeah? I know that sounds like a duh? but..)

 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Link to comment
Share on other sites

  • Developers

Think it's all quite simple. I use this in AutoitWrapper:

Local $INP_HotKey_Restart = IniRead($AutoIt3WapperIni, "Other", "SciTE_RESTART", '^!{BREAK}')
HotKeySet($INP_HotKey_Restart, 'Run_the_Script')

just define any valid shortcut in the ini and it will change.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Right I get that.. The issue is taking the hotkey defined by the UDF.  0x0642 (ctrl-alt-b)

I need to convert that to ^!b to have placed in the INI and for setting the proper hotkey?

 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Link to comment
Share on other sites

Here is what I am trying to get accomplished..

first you run the application, it will check for the existence of the INI or maybe reg keys? If they don't exist a dialog box will appear asking the user to define 3 hotkeys. Once the hotkeys have been created, write those to the ini or reg keys. Then from that point on, call the hot keys from the store location and use them. Unless the option for changing them is invoked? 

 

I think your example was just reading the stored hotkeys from an INI,, I want to also be able to define them at run time as well.

 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Link to comment
Share on other sites

  • Developers
1 minute ago, zone97 said:

I want to also be able to define them at run time as well.

So what is stopping you from adding those few lines of code?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Ok, maybe i'm not understanding?  I want to present the user with a form, where they can define a hotkey.. Without typing it in.. IE, they don't type ^!b, they press (ctr-alt-b) and the combination is translated into ^!b for the user and stored?

 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Link to comment
Share on other sites

Ok after much tinkering, I figured out my issues. Here are the snippets of code that I used.. I used the 2 UDF's for hotkey creation.

Assigned vars to define stored hotkeys.

Created live hot key inputs (from UDF)

Assigned hotkeys (from second UDF)

Function to read new hot keys, store them in registry and then reassign them.

Worked out nicely.

 

#Include <HotKeyInput.au3>
#Include <HotKey.au3>

...

Local $key1 = RegRead("HKEY_CURRENT_USER\Software\Avaya Answer","Hotkey#1")
Local $key2 = RegRead("HKEY_CURRENT_USER\Software\Avaya Answer","Hotkey#2")
Local $key3 = RegRead("HKEY_CURRENT_USER\Software\Avaya Answer","Hotkey#3")
Local $key4 = RegRead("HKEY_CURRENT_USER\Software\Avaya Answer","Hotkey#4")

...

$Input3     = _GUICtrlHKI_Create($key1, 136, 94, 137, 21)
$Input4     = _GUICtrlHKI_Create($key2, 136, 116, 137, 21)
$Input5     = _GUICtrlHKI_Create($key3, 136, 138, 137, 21)
$Input6     = _GUICtrlHKI_Create($key4, 136, 160, 137, 21)

...

_HotKey_Assign($key1, 'Answer')
_HotKey_Assign($key2, 'Transfer')
_HotKey_Assign($key3, 'Hangup')
_HotKey_Assign($key4, 'VoiceMail')

...

    $key1   = _GUICtrlHKI_GetHotKey($Input3)
    $key2   = _GUICtrlHKI_GetHotKey($Input4)
    $key3   = _GUICtrlHKI_GetHotKey($Input5)
    $key4   = _GUICtrlHKI_GetHotKey($Input6)

    RegWrite("HKEY_CURRENT_USER\Software\Avaya Answer","Hotkey#1","REG_SZ", $key1)
    RegWrite("HKEY_CURRENT_USER\Software\Avaya Answer","Hotkey#2","REG_SZ", $key2)
    RegWrite("HKEY_CURRENT_USER\Software\Avaya Answer","Hotkey#3","REG_SZ", $key3)
    RegWrite("HKEY_CURRENT_USER\Software\Avaya Answer","Hotkey#4","REG_SZ", $key4)

    _HotKey_Release()

    _HotKey_Assign($key1, 'Answer')
    _HotKey_Assign($key2, 'Transfer')
    _HotKey_Assign($key3, 'Hangup')
    _HotKey_Assign($key4, 'VoiceMail')

 

 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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