Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

determine defined hotkeys


  • Please log in to reply
No replies to this topic
shimanov
  • Members
  • 610 posts
  • Last active: Jul 18 2006 08:35 PM
  • Joined: 25 Sep 2005
Determines defined hotkeys and their status by retrieving relevant information from the output of ListHotkeys in the debug window.

note: requires DisableDebugWindow

< example >

ListHotkeys output:
Type        Off?        Running        Name
-------------------------------------------------------------------
reg                     1              F1
reg(no)     OFF                        F2
k-hook                                 $F3
k-hook      OFF                        $F4

After call to GetHotkeys, the following global variables are created:
hk_history = 4

hk_history1?name = F1
hk_history1?off = 0
hk_history1?running = 1
hk_history1?type = reg

hk_history2?name = F2
hk_history2?off = 1
hk_history2?running = 0
hk_history2?type = reg(no)

hk_history3?name = $F3
hk_history3?off = 0
hk_history3?running = 0
hk_history3?type = k-hook

hk_history4?name = $F4
hk_history4?off = 1
hk_history4?running = 0
hk_history4?type = k-hook

demonstration:
DisableDebugWindow()

Hotkey, F2, off
Hotkey, $F4, off

Send, {F1}
return

F1::
	GetHotkeys()
	ListVars
return

F2::
return

$F3::
return

$F4::
return

function:
GetHotkeys()
{
	global
	static	hw_debug
	local	old_DetectHiddenWindows, text, ix, jx, line, line0, line1, line2, line3, line4
	
	old_DetectHiddenWindows := A_DetectHiddenWindows
	DetectHiddenWindows, on

		if hw_debug=
		{
			Process, Exist
			WinGet, hw_debug, ID, ahk_class AutoHotkey ahk_pid %ErrorLevel%
		}
		
		enable_debug_window := false
			ListHotkeys
		enable_debug_window := true
		
		ControlGetText, text, Edit1, ahk_id %hw_debug%

	DetectHiddenWindows, %old_DetectHiddenWindows%
	
	StringReplace, text, text, `r`n, |, All UseErrorLevel
		hk_history := ErrorLevel-2

	StringGetPos, ix, text, |, L2
	loop, %hk_history%
	{
		StringGetPos, jx, text, |, % "L" ( 2+A_Index )
		StringMid, line, text, ix+2, jx-( ix+1 )
		
		StringSplit, line, line, %A_Tab%
		
		hk_history%A_Index%?type := line1
		hk_history%A_Index%?off := ( line2 = "OFF" )
		hk_history%A_Index%?running := ( line3 = 1 )
		hk_history%A_Index%?name := line4
		
		ix := jx
	}
}