Sorry I was actually referring to a second version of WinSpy that I found on Reddit here:
I modified the hotkeys for sure and added the process directory info and widened some boxes and added a reload button.
I wonder how others have modified WinSpy to make it more friendly. Definitely added to my toolbox along with UIA.
Code: Select all
#NoEnv
; #NoTrayIcon
{ ;LOAD ICON
RegExMatch(A_ScriptName, "\w+$", A_ScriptName_Extension)
; Script_icon := SubStr(A_ScriptDir, 1, InStr(SubStr(A_ScriptDir,1,-1), "\", 0, 0, 2)-1) . "\ico\computer-desktop.png" ;FOR !OTHERSCRIPTS
; MsgBox, % Script_icon
; If (A_ScriptName_Extension = "ahk") and FileExist(Script_icon)
Menu, Tray, Icon, Shell32.dll, 56
; Menu, Tray, Icon, Script_icon, 56
; Menu, Tray, Icon, Script_icon, 1
}
#SingleInstance
SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1
CoordMode, Pixel, Screen
txtNotFrozen := "Hold Ctrl or Shift to suspend updates`n!F1 toggles freeze status"
txtFrozen := "Updates suspended`n!F1 toggles freeze status"
txtMouseCtrl := "Control Under Mouse Position"
txtFocusCtrl := "Focused Control"
Gui, New, hwndhGui AlwaysOnTop Resize MinSize
Gui, Add, Text, , `nWindow Title, Class and Process:
Gui, Add, Button, gReloadWinSpy vReloadWinSpy Centeryp yp xp+260 w40, RELOAD
Gui, Add, Edit, xm w320 r6 ReadOnly -Wrap vCtrl_Title
Gui, Add, Text,, Mouse Position:
Gui, Add, Edit, w320 r4 ReadOnly vCtrl_MousePos
Gui, Add, Text, w320 vCtrl_CtrlLabel, % txtFocusCtrl ":"
Gui, Add, Edit, w320 r4 ReadOnly vCtrl_Ctrl
Gui, Add, Text,, Active Window Position:
Gui, Add, Edit, w320 r2 ReadOnly vCtrl_Pos
Gui, Add, Text,, Status Bar Text:
Gui, Add, Edit, w320 r2 ReadOnly vCtrl_SBText
Gui, Add, Checkbox, vCtrl_IsSlow, Slow TitleMatchMode
Gui, Add, Text,, Visible Text:
Gui, Add, Edit, w320 r4 ReadOnly vCtrl_VisText
Gui, Add, Text,, All Text:
Gui, Add, Edit, w320 r4 ReadOnly vCtrl_AllText
Gui, Add, Text, w200 r2 vCtrl_Freeze, % txtNotFrozen
Gui, Add, Checkbox, Checked1 yp xp+220 w100 Right vCtrl_FollowMouse, Follow Mouse
; Gui, Show, NoActivate yCenter x0, Window Spy
Gui, Show, % "x" A_ScreenWidth - 350 " yCenter NoActivate", Window Spy
; MsgBox, % GuiWidth " " GuiHeight " " A_ScreenWidth
GetClientSize(hGui, temp)
horzMargin := temp*96//A_ScreenDPI - 320
SetTimer, Update, 250
return
ReloadWinSpy(CtrlHwnd:=0, GuiEvent:="", EventInfo:="", ErrLvl:=""){
Reload
Return
}
GuiSize:
Gui %hGui%:Default
if !horzMargin
return
SetTimer, Update, % A_EventInfo=1 ? "Off" : "On" ; Suspend on minimize
ctrlW := A_GuiWidth - horzMargin
list = Title,MousePos,Ctrl,Pos,SBText,VisText,AllText,Freeze
Loop, Parse, list, `,
GuiControl, Move, Ctrl_%A_LoopField%, w%ctrlW%
GuiWidth := A_GuiWidth
GuiHeight := A_GuiHeight
return
Update:
Gui %hGui%:Default
GuiControlGet, Ctrl_FollowMouse
CoordMode, Mouse, Screen
MouseGetPos, msX, msY, msWin, msCtrl
actWin := WinExist("A")
if Ctrl_FollowMouse
{
curWin := msWin
curCtrl := msCtrl
WinExist("ahk_id " curWin)
}
else
{
curWin := actWin
ControlGetFocus, curCtrl
}
WinGetTitle, t1
WinGetClass, t2
if (curWin = hGui || t2 = "MultitaskingViewFrame") ; Our Gui || Alt-tab
{
UpdateText("Ctrl_Freeze", txtFrozen)
return
}
UpdateText("Ctrl_Freeze", txtNotFrozen)
WinGet, t3, ProcessName
WinGet, t4, PID
WinGet, t5, ID
WinGet, t6, ProcessPath
UpdateText("Ctrl_Title", t1 "`nahk_class " t2 "`nahk_exe " t3 "`nahk_pid " t4 "`nahk_id " t5 "`n" t6)
CoordMode, Mouse, Relative
MouseGetPos, mrX, mrY
CoordMode, Mouse, Client
MouseGetPos, mcX, mcY
PixelGetColor, mClr, %msX%, %msY%, RGB
mClr := SubStr(mClr, 3)
UpdateText("Ctrl_MousePos", "Screen:`t" msX ", " msY " (less often used)`nWindow:`t" mrX ", " mrY " (default)`nClient:`t" mcX ", " mcY " (recommended)"
. "`nColor:`t" mClr " (Red=" SubStr(mClr, 1, 2) " Green=" SubStr(mClr, 3, 2) " Blue=" SubStr(mClr, 5) ")")
UpdateText("Ctrl_CtrlLabel", (Ctrl_FollowMouse ? txtMouseCtrl : txtFocusCtrl) ":")
if (curCtrl)
{
ControlGetText, ctrlTxt, %curCtrl%
cText := "ClassNN:`t" curCtrl "`nText:`t" textMangle(ctrlTxt)
ControlGetPos cX, cY, cW, cH, %curCtrl%
cText .= "`n`tx: " cX "`ty: " cY "`tw: " cW "`th: " cH
WinToClient(curWin, cX, cY)
ControlGet, curCtrlHwnd, Hwnd,, % curCtrl
GetClientSize(curCtrlHwnd, cW, cH)
cText .= "`nClient:`tx: " cX "`ty: " cY "`tw: " cW "`th: " cH
}
else
cText := ""
UpdateText("Ctrl_Ctrl", cText)
WinGetPos, wX, wY, wW, wH
GetClientSize(curWin, wcW, wcH)
UpdateText("Ctrl_Pos", "`tx: " wX "`ty: " wY "`tw: " wW "`th: " wH "`nClient:`tx: 0`ty: 0`tw: " wcW "`th: " wcH)
sbTxt := ""
Loop
{
StatusBarGetText, ovi, %A_Index%
if ovi =
break
sbTxt .= "(" A_Index "):`t" textMangle(ovi) "`n"
}
StringTrimRight, sbTxt, sbTxt, 1
UpdateText("Ctrl_SBText", sbTxt)
GuiControlGet, bSlow,, Ctrl_IsSlow
if bSlow
{
DetectHiddenText, Off
WinGetText, ovVisText
DetectHiddenText, On
WinGetText, ovAllText
}
else
{
ovVisText := WinGetTextFast(false)
ovAllText := WinGetTextFast(true)
}
UpdateText("Ctrl_VisText", ovVisText)
UpdateText("Ctrl_AllText", ovAllText)
return
GuiClose:
ExitApp
WinGetTextFast(detect_hidden)
{
; WinGetText ALWAYS uses the "Slow" mode - TitleMatchMode only affects the
; WinText/ExcludeText parameters. In "Fast" mode, GetWindowText() is used
; to retrieve the text of each control.
WinGet controls, ControlListHwnd
static WINDOW_TEXT_SIZE := 32767 ; Defined in AutoHotkey source.
VarSetCapacity(buf, WINDOW_TEXT_SIZE * (A_IsUnicode ? 2 : 1))
text := ""
Loop Parse, controls, `n
{
if !detect_hidden && !DllCall("IsWindowVisible", "ptr", A_LoopField)
continue
if !DllCall("GetWindowText", "ptr", A_LoopField, "str", buf, "int", WINDOW_TEXT_SIZE)
continue
text .= buf "`r`n"
}
return text
}
UpdateText(ControlID, NewText)
{
; Unlike using a pure GuiControl, this function causes the text of the
; controls to be updated only when the text has changed, preventing periodic
; flickering (especially on older systems).
static OldText := {}
global hGui
if (OldText[ControlID] != NewText)
{
GuiControl, %hGui%:, % ControlID, % NewText
OldText[ControlID] := NewText
}
}
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
{
VarSetCapacity(rect, 16)
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
w := NumGet(rect, 8, "int")
h := NumGet(rect, 12, "int")
}
WinToClient(hWnd, ByRef x, ByRef y)
{
WinGetPos wX, wY,,, ahk_id %hWnd%
x += wX, y += wY
VarSetCapacity(pt, 8), NumPut(y, NumPut(x, pt, "int"), "int")
if !DllCall("ScreenToClient", "ptr", hWnd, "ptr", &pt)
return false
x := NumGet(pt, 0, "int"), y := NumGet(pt, 4, "int")
return true
}
textMangle(x)
{
if pos := InStr(x, "`n")
x := SubStr(x, 1, pos-1), elli := true
if StrLen(x) > 40
{
StringLeft, x, x, 40
elli := true
}
if elli
x .= " (...)"
return x
}
; F8::
!F1::
win_a_toggle := !win_a_toggle
If win_a_toggle
UpdateText("Ctrl_Freeze", txtFrozen)
SetTimer, Update, % (win_a_toggle ? "Off" : "On")
Return
~*Ctrl::
~*Shift::
If !win_a_toggle
{
SetTimer, Update, Off
UpdateText("Ctrl_Freeze", txtFrozen)
}
return
~*Ctrl up::
~*Shift up::
If !win_a_toggle
{
SetTimer, Update, On
}
return