CHotkeyControl - a replacement for AHK's Hotkey GuiControl

Post your working scripts, libraries and tools
User avatar
evilC
Posts: 2708
Joined: 27 Feb 2014, 12:30

CHotkeyControl - a replacement for AHK's Hotkey GuiControl

02 Aug 2015, 17:59

CHotkeyControl aims to provide a feature-rich replacement for AHK's Hotkey GuiControl that is capable of recognizing any binding that AHK's hotkey system supports - with options for setting pass-through (~), Wild (*) etc.
It uses SetWindowsHookEx DLL calls to simultaneously read and block input from being seen by other apps.

It is currently a work in progress, but the basics are operational.
User avatar
evilC
Posts: 2708
Joined: 27 Feb 2014, 12:30

Re: CHotkeyControl - a replacement for AHK's Hotkey GuiControl

03 Aug 2015, 18:11

Massive update - loads of fixes and optimizations.

I think it is now pretty much ready for use, gonna start trying to use it in some of my projects.
User avatar
evilC
Posts: 2708
Joined: 27 Feb 2014, 12:30

Re: CHotkeyControl - a replacement for AHK's Hotkey GuiControl

04 Aug 2015, 14:43

We made a major usability improvement.

The control is now a ComboBox, and we use a "Cue Banner" to display the currently selected hotkey.
User avatar
evilC
Posts: 2708
Joined: 27 Feb 2014, 12:30

Re: CHotkeyControl - a replacement for AHK's Hotkey GuiControl

05 Aug 2015, 10:05

Another major change - bind mode now only ends on an up event.

Although slightly less user-friendly, it does make the whole thing a lot simpler, and open some doors.

For example, if you end bind mode on the down event, and bind the hotkey at that point, when the user releases the key, the up event for that hotkey will be fired.
You don't seem to be able to do a GetKeyState loop to wait for the key just bound to be released however, I guess because we are hooking and blocking the keys, so AHK didn't see the key go down.

Also we cannot end bind mode on the down event of a non-modifier if we wish to support hotkeys such as a + b
KuroiLight
Posts: 112
Joined: 12 Apr 2015, 20:24
GitHub: KuroiLight

Re: CHotkeyControl - a replacement for AHK's Hotkey GuiControl

07 Aug 2015, 18:04

Finally got around to testing it. Works and its close to what I had in mind. :thumbup:

If you dont want to block input globally you can instead add

Code: [Select all] [Download] GeSHi © Codebox Plus

OnMessage(0x100, "BlockDing")
BlockDing() {
if(A_Gui == YourGuiId)
return 1
}
to avoid the ding windows does.
Windows 10, i5-6600k (4.5GHz), 16GB G.Skill DDR4, 2GB R9 270x | [MyScripts][MySublimeSettings] [Unlicense][MIT License]
User avatar
evilC
Posts: 2708
Joined: 27 Feb 2014, 12:30

Re: CHotkeyControl - a replacement for AHK's Hotkey GuiControl

08 Aug 2015, 05:20

Hmm, interesting idea. My original forays into SetWindowsHookEx were a result of trying to re-write AHK's hotkey system, so for that I needed global hooks. But I suppose for the bind routine, then yeah, you only need to hook inside the application.

Also, new version uploaded - now has basic support for Joystick buttons.
KuroiLight
Posts: 112
Joined: 12 Apr 2015, 20:24
GitHub: KuroiLight

Re: CHotkeyControl - a replacement for AHK's Hotkey GuiControl

08 Aug 2015, 19:27

What I meant was that you can keep you global hook but instead of returning 1 (and blocking all user input) you can add that code and windows wont ding while keys are being pressed inside the window.
Windows 10, i5-6600k (4.5GHz), 16GB G.Skill DDR4, 2GB R9 270x | [MyScripts][MySublimeSettings] [Unlicense][MIT License]
titep
Posts: 20
Joined: 14 Nov 2015, 09:01

Re: CHotkeyControl - a replacement for AHK's Hotkey GuiControl

03 Dec 2015, 07:11

It works great, but when I embed the code of CHotkeyControl into my .ahk file, CHotkey make Morse() goes wrong.
For example, when I hit my key binding three times (captured with Morse()), its return to 000 and 0 instead of 000 only.
@@ What happened?
User avatar
evilC
Posts: 2708
Joined: 27 Feb 2014, 12:30

Re: CHotkeyControl - a replacement for AHK's Hotkey GuiControl

03 Dec 2015, 08:03

Morse() works with AHK hotkeys. CHotkeyControl does not use AHK's hotkey system *at all*, it is entirely reliant on low-level windows hooks.
Therefore CHotkeyControl is totally incompatible with Morse()
titep
Posts: 20
Joined: 14 Nov 2015, 09:01

Re: CHotkeyControl - a replacement for AHK's Hotkey GuiControl

04 Dec 2015, 03:51

@evilC : Thank you, I am just trying to capture word I type like Typing Aid. I use input and loop function to capture letter by letter and then combine them into word. When I type fast, my ahk works unrealiably. That's why I came to CHotkeycontrol ಠ_ಠ Maybe I will try another way...
User avatar
evilC
Posts: 2708
Joined: 27 Feb 2014, 12:30

Re: CHotkeyControl - a replacement for AHK's Hotkey GuiControl

04 Dec 2015, 07:42

I have pretty much abandoned the low-level hook technique (as used in CHotkeyControl) now, because the application becomes un-debuggable while the hooks are running (key / mouse stops working so you can't step through).
So instead I just map a hotkey to every key on the keyboard, like this:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

KuroiLight
Posts: 112
Joined: 12 Apr 2015, 20:24
GitHub: KuroiLight

Re: CHotkeyControl - a replacement for AHK's Hotkey GuiControl

04 Dec 2015, 19:10

Might I ask what debugger you're using? I haven't been using one thus far.
Windows 10, i5-6600k (4.5GHz), 16GB G.Skill DDR4, 2GB R9 270x | [MyScripts][MySublimeSettings] [Unlicense][MIT License]

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Bing [Bot], kczx3 and 15 guests