2018-03-28 22:31:25 +00:00
|
|
|
/*
|
|
|
|
Script to show data flowing from Interception
|
|
|
|
*/
|
2018-03-28 19:39:29 +00:00
|
|
|
#SingleInstance force
|
|
|
|
#Persistent
|
2019-06-08 20:56:58 +00:00
|
|
|
#include Lib\AutoHotInterception.ahk
|
2018-03-28 19:39:29 +00:00
|
|
|
|
|
|
|
OutputDebug DBGVIEWCLEAR
|
|
|
|
|
2019-08-23 20:26:54 +00:00
|
|
|
Gui, Margin, 0, 0
|
2019-06-09 12:51:01 +00:00
|
|
|
DeviceList := {}
|
2018-03-28 21:15:20 +00:00
|
|
|
filterMouseMove := 1
|
2019-06-08 20:56:10 +00:00
|
|
|
filterKeyPress := 0
|
2018-03-28 19:39:29 +00:00
|
|
|
|
|
|
|
MonitorWrapper := new AutoHotInterception("Monitor")
|
2019-06-09 12:51:01 +00:00
|
|
|
Monitor := MonitorWrapper.Instance
|
2018-03-28 19:39:29 +00:00
|
|
|
|
2019-06-09 12:51:01 +00:00
|
|
|
; Device List
|
2018-03-28 19:39:29 +00:00
|
|
|
DeviceList := MonitorWrapper.GetDeviceList()
|
|
|
|
|
2019-08-23 20:26:54 +00:00
|
|
|
marginX := 10
|
|
|
|
marginY := 10
|
|
|
|
idW := 50 ; Width of the ID text
|
|
|
|
vhOff := 7 ; Width to space VIDPID / Handle above/below ID row
|
|
|
|
copyW := 40 ; Width of the Copy buttons
|
2019-08-23 20:54:08 +00:00
|
|
|
outputH := 350 ; Height of the Output boxes
|
2019-08-23 20:26:54 +00:00
|
|
|
rowH := 35 ; Distance between each row of devices
|
|
|
|
|
|
|
|
maxWidths := {K: 0, M: 0} ; Max Width of device entries for each column
|
|
|
|
totalWidths := {K: 0, M: 0} ; Total Width of each column
|
|
|
|
devTypes := ["K", "M"] ; Lookup table for device type
|
|
|
|
starts := {K: 0, M: 10} ; Start IDs for each device type
|
|
|
|
columnTitles := {K: "Keyboards", M: "Mice"} ; Column Titles
|
|
|
|
columnX := {K: 0, M: 0}
|
|
|
|
|
|
|
|
Loop 2 {
|
|
|
|
strings := {}
|
|
|
|
devType := devTypes[A_Index]
|
|
|
|
columnX[devType] := GetColX(devType)
|
|
|
|
|
|
|
|
start := starts[devType]
|
|
|
|
UpdateWidth(0, 1) ; Reset max width
|
|
|
|
|
|
|
|
; Add device entries
|
|
|
|
Loop 10 {
|
|
|
|
i := start + A_Index
|
|
|
|
dev := DeviceList[i]
|
|
|
|
if (!IsObject(dev)){
|
|
|
|
continue
|
|
|
|
}
|
2019-08-23 20:54:08 +00:00
|
|
|
rowY := (marginY * 3) + ((A_Index - 1) * rowH)
|
2019-08-23 20:26:54 +00:00
|
|
|
Gui, Add, Checkbox, % "hwndhwnd x" columnX[devType] " y" rowY " w" idW, % "ID: " dev.id
|
2019-08-23 21:06:56 +00:00
|
|
|
fn := Func("CheckboxChanged").Bind(dev.id)
|
2019-08-23 21:00:10 +00:00
|
|
|
GuiControl, +g, % hwnd, % fn
|
2019-08-23 20:26:54 +00:00
|
|
|
lowest := UpdateLowest(hwnd)
|
|
|
|
strings[A_index] := {vid:FormatHex(dev.VID), pid: FormatHex(dev.PID), handle: StrReplace(dev.Handle, "&", "&&")}
|
|
|
|
Gui, Add, Text, % "hwndhwnd x" columnX[devType] + idW " y" rowY - vhOff, % "VID / PID:`t0x" strings[A_index].vid ", 0x" strings[A_index].pid
|
|
|
|
maxWidths[devType] := UpdateWidth(hwnd)
|
|
|
|
Gui, Add, Text, % "hwndhwnd x" columnX[devType] + idW " y" rowY + vhOff, % "Handle:`t`t" strings[A_index].handle
|
|
|
|
maxWidths[devType] := UpdateWidth(hwnd)
|
2018-03-28 19:39:29 +00:00
|
|
|
}
|
2019-06-09 12:51:01 +00:00
|
|
|
|
2019-08-23 20:26:54 +00:00
|
|
|
; Add copy buttons
|
|
|
|
Loop 10 {
|
|
|
|
i := start + A_Index
|
|
|
|
dev := DeviceList[i]
|
|
|
|
if (!IsObject(dev)){
|
|
|
|
continue
|
|
|
|
}
|
2019-08-23 20:54:08 +00:00
|
|
|
rowY := (marginY * 3) + ((A_Index - 1) * rowH)
|
2019-08-23 21:32:31 +00:00
|
|
|
fn := Func("CopyClipboard").Bind("0x" strings[A_index].vid ", 0x" strings[A_index].pid)
|
2019-08-23 20:26:54 +00:00
|
|
|
xpos := columnX[devType] + idW + maxWidths[devType]
|
|
|
|
Gui, Add, Button, % "x" xpos " y" rowY - vhOff " h14 w" copyW " hwndhwnd", Copy
|
|
|
|
GuiControl, +g, % hwnd, % fn
|
|
|
|
|
|
|
|
fn := Func("CopyClipboard").Bind(strings[A_index].handle)
|
|
|
|
Gui, Add, Button, % "x" xpos " y" rowY + vhOff " h14 w" copyW " hwndhwnd", Copy
|
|
|
|
GuiControl, +g, % hwnd, % fn
|
2018-03-28 19:39:29 +00:00
|
|
|
}
|
2019-08-23 20:26:54 +00:00
|
|
|
|
|
|
|
totalWidths[devType] := idW + maxWidths[devType] + copyW
|
|
|
|
Gui, Add, Text, % "x" columnX[devType] " y5 w" totalWidths[devType] " Center", % columnTitles[devType]
|
2018-03-28 19:39:29 +00:00
|
|
|
}
|
|
|
|
|
2019-08-23 20:26:54 +00:00
|
|
|
lowest += 2 * MarginY
|
|
|
|
|
2019-06-09 12:51:01 +00:00
|
|
|
; Options
|
2019-08-23 20:26:54 +00:00
|
|
|
Gui, Add, CheckBox, % "x" columnX.K " y" lowest " hwndhCbFilterPress", Only show key releases
|
2019-06-09 12:51:01 +00:00
|
|
|
fn := Func("FilterPress")
|
|
|
|
GuiControl, +g, % hCbFilterPress, % fn
|
|
|
|
|
2019-08-23 20:26:54 +00:00
|
|
|
Gui, Add, CheckBox, % "x" columnX.M " w" totalWidths[devType] " yp hwndhCbFilterMove Checked", Filter Movement (Warning: Turning off can cause crashes)
|
2018-03-28 21:15:20 +00:00
|
|
|
fn := Func("FilterMove")
|
|
|
|
GuiControl, +g, % hCbFilterMove, % fn
|
2019-06-09 12:51:01 +00:00
|
|
|
|
2019-08-23 20:26:54 +00:00
|
|
|
lowest += 2 * MarginY
|
|
|
|
|
|
|
|
Gui, Add, Button, % "x" columnX.K " y" lowest " w" totalWidths.K " Center gClearKeyboard", Clear
|
|
|
|
Gui, Add, Button, % "x" columnX.M " yp w" totalWidths.M " gClearMouse Center", Clear
|
|
|
|
|
|
|
|
lowest += 30
|
2018-03-28 21:15:20 +00:00
|
|
|
|
2019-06-09 12:51:01 +00:00
|
|
|
; Output
|
2019-08-23 20:26:54 +00:00
|
|
|
Gui, Add, ListView, % "x" columnX.K " y" lowest " w" totalWidths.K " h" outputH " hwndhLvKeyboard", ID|Code|State|Key Name|Info
|
2019-02-24 19:32:07 +00:00
|
|
|
LV_ModifyCol(4, 100)
|
|
|
|
LV_ModifyCol(5, 150)
|
2019-08-23 20:26:54 +00:00
|
|
|
Gui, Add, ListView, % "x" columnX.M " yp w" totalWidths.M " h" outputH " hwndhLvMouse", ID|Code|State|X|Y|Info
|
2019-02-24 19:32:07 +00:00
|
|
|
LV_ModifyCol(6, 200)
|
2019-08-23 20:26:54 +00:00
|
|
|
|
|
|
|
lowest += outputH
|
|
|
|
|
|
|
|
Gui, Show, % "w" (marginX * 3) + totalWidths.K + totalWidths.M " h" marginY + lowest, AutoHotInterception Monitor
|
2018-03-28 19:39:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
Monitor.Subscribe(Func("KeyboardEvent"), Func("MouseEvent"))
|
|
|
|
return
|
|
|
|
|
2019-08-23 20:26:54 +00:00
|
|
|
GetColX(devType){
|
|
|
|
global marginX, idW, maxWidths, copyW
|
|
|
|
if (devType == "K")
|
|
|
|
return marginX
|
|
|
|
else
|
|
|
|
return (marginX * 2) + idW + maxWidths["K"] + copyW
|
|
|
|
}
|
|
|
|
|
2019-06-09 12:51:01 +00:00
|
|
|
UpdateLowest(hwnd){
|
2019-08-23 20:26:54 +00:00
|
|
|
static max := 0
|
2019-06-09 12:51:01 +00:00
|
|
|
GuiControlGet, cp, pos, % hwnd
|
2019-08-23 20:26:54 +00:00
|
|
|
pos := cpY + cpH
|
|
|
|
if (pos > max){
|
|
|
|
max := pos
|
2019-06-09 12:51:01 +00:00
|
|
|
}
|
2019-08-23 20:26:54 +00:00
|
|
|
return max
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateWidth(hwnd, reset := 0){
|
|
|
|
static max := 0
|
|
|
|
if (reset){
|
|
|
|
max := 0
|
|
|
|
return
|
|
|
|
}
|
|
|
|
GuiControlGet, cp, pos, % hwnd
|
|
|
|
if (cpW > max){
|
|
|
|
max := cpW
|
|
|
|
}
|
|
|
|
return max
|
2019-06-09 12:51:01 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 19:39:29 +00:00
|
|
|
CheckboxChanged(id, hwnd){
|
2019-06-09 12:51:01 +00:00
|
|
|
global Monitor
|
2018-03-28 19:39:29 +00:00
|
|
|
GuiControlGet, state, , % hwnd
|
|
|
|
ret := Monitor.SetDeviceFilterState(id, state)
|
|
|
|
;~ ToolTip % "Changed " id " to " state ". Return value: " ret
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:15:20 +00:00
|
|
|
FilterMove(hwnd){
|
|
|
|
global filterMouseMove
|
|
|
|
GuiControlGet, state, , % hwnd
|
|
|
|
filterMouseMove := state
|
|
|
|
}
|
|
|
|
|
2019-06-08 20:56:10 +00:00
|
|
|
FilterPress(hwnd){
|
|
|
|
global filterKeyPress
|
|
|
|
GuiControlGet, state, , % hwnd
|
|
|
|
filterKeyPress := state
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:15:20 +00:00
|
|
|
ClearKeyboard:
|
|
|
|
Gui, ListView, % hLvKeyboard
|
|
|
|
LV_Delete()
|
|
|
|
return
|
|
|
|
|
|
|
|
ClearMouse:
|
|
|
|
Gui, ListView, % hLvMouse
|
|
|
|
LV_Delete()
|
|
|
|
return
|
|
|
|
|
2018-03-28 19:39:29 +00:00
|
|
|
FormatHex(num){
|
|
|
|
return Format("{:04X}", num)
|
|
|
|
}
|
|
|
|
|
2019-02-24 17:41:51 +00:00
|
|
|
KeyboardEvent(id, code, state, info){
|
2019-06-08 20:56:10 +00:00
|
|
|
global hLvKeyboard, filterKeyPress
|
|
|
|
if (filterKeyPress && state)
|
|
|
|
return
|
2018-03-28 19:39:29 +00:00
|
|
|
Gui, ListView, % hLvKeyboard
|
2019-02-24 19:32:07 +00:00
|
|
|
scanCode := Format("{:x}", code)
|
|
|
|
keyName := GetKeyName("SC" scanCode)
|
|
|
|
row := LV_Add(, id, code, state, keyName, info)
|
2018-03-28 19:39:29 +00:00
|
|
|
LV_Modify(row, "Vis")
|
|
|
|
}
|
|
|
|
|
2019-02-24 17:41:51 +00:00
|
|
|
MouseEvent(id, code, state, x, y, info){
|
2018-03-28 21:15:20 +00:00
|
|
|
global hLvMouse, filterMouseMove
|
2019-02-24 17:41:51 +00:00
|
|
|
if (filterMouseMove && (x != 0 || y != 0))
|
2018-03-28 21:15:20 +00:00
|
|
|
return
|
2018-03-28 19:39:29 +00:00
|
|
|
Gui, ListView, % hLvMouse
|
2019-02-24 17:41:51 +00:00
|
|
|
row := LV_Add(, id, code, state, x, y, info)
|
2018-03-28 19:39:29 +00:00
|
|
|
LV_Modify(row, "Vis")
|
2019-08-23 20:26:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CopyClipboard(str){
|
|
|
|
Clipboard := str
|
2019-08-23 21:14:59 +00:00
|
|
|
Tooltip Copied to Clipboard
|
|
|
|
SetTimer, ClearTooltip, 1000
|
2018-03-28 19:39:29 +00:00
|
|
|
}
|
|
|
|
|
2019-08-23 21:14:59 +00:00
|
|
|
ClearTooltip:
|
|
|
|
ToolTip
|
|
|
|
return
|
|
|
|
|
2018-03-28 19:39:29 +00:00
|
|
|
^Esc::
|
|
|
|
GuiClose:
|
2019-06-08 20:56:10 +00:00
|
|
|
ExitApp
|