;------------------------------------------------------------------------------------------- ; Ahk Window Spy 1.3.3 ; by Decarlo ; shows window info: active, under pointer, hidden, all ; hotkey toggles the following modes: ; press 1x - tooltip ; press 2x - snapshot window, press CapsLock to update ; press 3x - polling window, updates with pointer motion ; press 4x - off ; hold for at least 0.4 sec - show control list of active window, if not in another mode. ; press hotkey from control list mode - display Window Chart, including info on hidden windows. ; press/hold Esc to exit, or press hotkey for 0.4 sec ; other features: ; shows pointer coordinates relative: ; to screen, ; to active window, including right/bottom mirror coordinates, ; to window beneath pointer ; shows various attributes corresponding to both window active & window under pointer. ; handles tooltip bugs related to one or more of the following: ; hovering over the tooltip, ; hovering over irretrievable/non-existent control, ; AutoHotkey.ini string present in window title, ; re-size cursors, ; shows win-drag coordinates indicating new window position after dragging ; temporary deactivation of tooltip/mode3 by holding LCtrl, to highlight/double-click. ; Alternatively, 3+ click or select/Enter to activate/Open during navigation. ; add: option to monitor user-specified controls ; history, recent topmost: ; fixed exit-related bugs due to conversion to function form ; converted to function form to reduce global variable list and avoid naming conflicts ; replaced some unnecessary variables with reusable temp var ; added automatic control-size scaling on window re-size ; added window chart mode, which includes info on hidden windows ; changed code for exiting and fixed exiting from tooltip mode using Esc ; added holding of RShift+RCtrl for 2 sec restores to default window size & position ; added remembering of window position ; changed code for toggling AlwaysOnTop and fixed related window activation bug ; changed default snapshot key to CapsLock ; simplified the code ; changed toggle of window AlwaysOnTop to RShift+RCtrl ; fixed bug of snapshot window disappearing on toggling AlwaysOnTop ; added option to show control list: press hotkey for 0.4 sec if not in another mode ; fixed tooltip reappearing in window mode when applying LShift ; added pressing RCtrl toggles AlwaysOnTop ; added pressing LShift refreshes Snapshot ; fixed bug of tooltip reappearing on Monitoring exit ; fixed Ctrl to properly deactivate monitoring to allow highlight/copy ; added right/bottom-border window coordinates relative to within screen ; added right/bottom pointer coordinates relative to within active window ; added Esc as alternative to exit without hotkey toggle ; fixed bug of tooltip reappearing on Snapshot exit. ; added win-drag coordinates ; added window modes ; added PID, process name, colour, & pointer fields ; added display of attributes of window beneath pointer, tooltip mode ; added various modifications to handle specific tooltip peculiarities ; basic active window info in tooltip #!w:: AhkWindowSpy() return AhkWindowSpy() { static flagWindowInfo ; remember last mode used global ws_xGui, ws_yGui, ws_wGui, ws_hGui ; remember last window position & size DetectHiddenWindows, off SetTitleMatchMode, 2 CoordMode, Mouse intervalPointerWindowInfo = 300 ifWinExist, Window Chart 1 { WinClose, Window Chart 1 flagWindowInfo = KeyWait, w EXIT } ifWinExist, Control List 1 { winListIDsVisible = winListIDs = winListPIDs = winListTitles = winListClasses = winProcessList = WinClose, Control List 1,, 3 flagWindowInfo = W WinGet, Win#, List Loop %Win#% { winListItem := win#%A_Index% winListIDsVisible = %winListIDsVisible%%winListItem%`r`n } DetectHiddenWindows, on WinGet, Win#, List Loop %Win#% { winListItem := win#%A_Index% winListIDs = %winListIDs%%winListItem%`r`n } Loop, parse, winListIDs, `n, `r { WinGet, winPID%A_Index%, PID, ahk_id %A_LoopField% winListItem := winPID%A_Index% winListPIDs = %winListPIDs%%winListItem%`r`n ; pid's with windows WinGetTitle, winTitle%A_Index%, ahk_id %A_LoopField% winListItem := winTitle%A_Index% winListTitles = %winListTitles%%winListItem%`r`n ; titles of windows WinGetClass, winClass%A_Index%, ahk_id %A_LoopField% winListItem := winClass%A_Index% winListClasses = %winListClasses%%winListItem%`r`n ; classes of windows } Loop, parse, winListPIDs, `n, `r { if A_LoopField = CONTINUE WinGet, processName%A_Index%, ProcessName, ahk_pid %A_LoopField% winListItem := processName%A_Index% winProcessList=%winProcessList%%winListItem%`r`n ; processes with windows } Sort, winListIDs Sort, winListPIDs, NU Sort, winListTitles, U Sort, winListClasses, U Sort, winProcessList, U sleep 400 if GetKeyState("LWin","p") { KeyWait, w msgbox %Win#% windows found msgbox,, Windows Chart 1, window id's`r`n`r`n%winListIDs% msgbox,, Windows Chart 1, pid's owning windows`r`n`r`n%winListPIDs% msgbox,, Windows Chart 1, titles of windows`r`n`r`n%winListTitles% msgbox,, Windows Chart 1, classes of windows`r`n`r`n%winListClasses% msgbox,, Windows Chart 1, processes with windows`r`n`r`n%winProcessList% } ; Create the ListView Gui, Add, ListView, AltSubmit r33 w700 gWindowChart , Item|ID|PID|Class|Process|win type|Title Loop, %Win#% { LV_Add("", 1, win#%A_Index%, winPID%A_Index%, winClass%A_Index%, processName%A_Index%, "", winTitle%A_Index%) ; 1st param=options temp_LV_1 := win#%A_Index% IfNotInString, winListIDsVisible, %temp_LV_1% LV_Modify(A_Index, "Col6", "hidden") } LV_ModifyCol() ; Auto-size each column LV_ModifyCol(1, "33 Integer Left") ; column heading 33 pixels; left-justification LV_ModifyCol(3, "Integer") ; For sorting purposes - PID is an integer LV_ModifyCol(5, "Sort") ; sort rows by Process LV_ModifyCol(6, 53) ; column heading 53 pixels Loop, %Win#% LV_Modify(A_Index, "", A_Index) ; number the sorted rows Gui, +Resize Gui, Show,, Ahk Window Spy - Window Chart 1 return KeyWait, w EXIT } Loop 8 { sleep 50 if not GetKeyState("w","p") BREAK ; continues with thread if A_Index=8 ; display control list { if flagWindowInfo <> ; exit the current mode { GoSub ws_GuiClose KeyWait, w EXIT } WinGet, controlList, ControlList, A Gui Destroy Gui, Font, 0x183CE7 Gui, Color, 0xD6D3D6 Gui, +Resize w300 Gui, Add, Edit, +AutoSize +VScroll +HScroll w165 h600 ReadOnly, %controlList% Gui, Show, x-2 y100 w175, Control List 1 ControlSend, Edit1, {end}, Control List 1 flagWindowInfo = C KeyWait, w EXIT } } If flagWindowInfo=3 ; toggle to off { GoSub ws_GuiClose EXIT } else If flagWindowInfo=2 ; toggle to window Monitoring { Gui, Show, NoActivate, Ahk Window Spy - auto-refresh ; similar effect as above ControlSetText, Edit1, %Info1Tips%%tooltip1Info%, Ahk Window Spy - flagWindowInfo=3 } else If flagWindowInfo=1 ; toggle to Snapshot { flagWindowInfo=2 Tooltip GuiTopmost=1 Gui, +AlwaysOnTop +Resize +VScroll +HScroll Gui, Font, 0x183CE7 ;s6, Courier ; blue Gui, Color, 0xD6D3D6 ; <light grey; 0xFFFFA5 yellow Gui, Add, Edit, +VScroll +HScroll w301 h400 ReadOnly, %Info1Tips%%tooltip1Info% if ws_xGui = Gui, Show, x-2 y301, Ahk Window Spy - snapshot else Gui, Show, x%ws_xGui% y%ws_yGui%, Ahk Window Spy - snapshot WinWaitActive, Ahk Window Spy - ,, 1 ; this improves responsiveness ControlSend, Edit1, ^{home}, Ahk Window Spy - } else { flagWindowInfo=1 ; activate Tooltip SetTimer, PointerWindowInfo, %intervalPointerWindowInfo% } KeyWait, w return PointerWindowInfo: SetTitleMatchMode, 2 Info1Tips = LCtrl pauses for select/copy/double-clicking.`r`nCapsLock updates info in snapshot mode.`r`nRShift+RCtrl toggles AlwaysOnTop.`r`n`r`n tooltipInfo = pointer x`,y = `t(%xC%`,%yC%) to screen`r`npointer x`,y = `t(%xCA%`,%yCA%`,%xCAm%`,%yCAm%) to win active`r`npointer x`,y = `t(%xCU%`,%yCU%) to win under`r`ncolour, rgb`t%color%`r`nwin active x`,y =`t(%xWinActive%`,%yWinActive%`,%xWinActiveM%`,%yWinActiveM%)`r`nwin under x`,y =`t(%xWinUnder%`,%yWinUnder%)`r`nwin drag x`,y =`t(%xWinDrag%`,%yWinDrag%)`r`nwin active w`,h =`t%widthWinActive%`,%heightWinActive%`r`nwin under w`,h =`t%widthWinUnder%`,%heightWinUnder%`r`nTitle active`t%titleActive%`r`nTitle under`t%titleUnder%`r`nPID active =`t%PIDActive%`r`nPID under =`t%PIDUnder%`r`nprocess active =`t%procActive%`r`nprocess under =`t%procUnder%`r`nwin cnt hidden`ttoggle for info`r`nwin class active`t%classActive%`r`nwin class under`t%classUnder%`r`nwin id active`t%idActive%`r`nwin id under`t%id%`r`npointer`t`t%A_Cursor%`r`ncontrol active`t%controlActive%`r`ncontrol under`t%controlUnder%`r`ncontrol under, text:`t tooltip1Info = %tooltipInfo%`r`n%controlText% tooltip2Info = %tooltipInfo%-bypassed- if ( GetKeyState("RShift","p") AND GetKeyState("RCtrl","p") ) ; toggle window AlwaysOnTop { timeRShiftRCtrl = %A_TickCount% WinGet, IDActive, ID, A if GuiTopmost { Gui, -AlwaysOnTop GuiTopmost= WinW("Ahk Window Spy - ", 3) ; max of 3 sec WinActivate, ahk_id %IDActive% } else { Gui, +AlwaysOnTop GuiTopmost=1 } KeyWait, RCtrl if ( A_TickCount - timeRShiftRCtrl > 1200 ) ; holding RShift+RCtrl restores default window position { ws_xGui = ws_yGui = ifWinExist, Ahk Window Spy - snapshot Gui, Show, x-2 y301 w329 h439 AutoSize NoActivate, Ahk Window Spy - snapshot else Gui, Show, x-2 y301 w329 h439 AutoSize NoActivate, Ahk Window Spy - auto-refresh } } if GetKeyState("CapsLock","p") ; refresh Snapshot ifWinExist, Ahk Window Spy - snapshot { ControlSetText, Edit1,, Ahk Window Spy - sleep 70 ControlSetText, Edit1, %Info1Tips%%tooltip1Info%, Ahk Window Spy - ControlSend, Edit1, ^{home}, Ahk Window Spy - } if GetKeyState("LCtrl","p") ; temporary deactivate { Tooltip ; tooltip off Loop ; prevents updating of values { sleep 100 if not GetKeyState("Ctrl","p") BREAK } } if GetKeyState("Esc","p") { SetTimer, PointerWindowInfo, off { GoTo ws_GuiClose ; avoid GoSub since this timer is turned off *** ; will EXIT } } MouseGetPos, xC, yC, id, controlUnder ; relative to screen WinGet, idActive, ID, A ControlGetFocus, controlActive, ahk_id %idActive% WinGetTitle, titleUnder, ahk_id %id% WinGetTitle, titleActive, A WinGetClass, classUnder, ahk_id %id% WinGetClass, classActive, A WinGetPos, xWinUnder, yWinUnder, widthWinUnder, heightWinUnder, ahk_id %id% WinGetPos, xWinActive, yWinActive, widthWinActive, heightWinActive, A WinGet, PIDUnder, PID, ahk_id %id% WinGet, PIDActive, PID, A WinGet, ProcUnder, ProcessName, ahk_id %id% WinGet, ProcActive, ProcessName, A if flagWindowInfo=1 { ifNotInString, titleUnder, AutoHotkey.ini - ControlGetText, controlText, %controlUnder%, ahk_id %id% } else ControlGetText, controlText, %controlUnder%, ahk_id %id% xCU := xC-xWinUnder ; relative to window under pointer yCU := yC-yWinUnder ; relative to window under pointer xCA := xC-xWinActive ; relative to window active yCA := yC-yWinActive ; relative to window active xCAm := xWinActive + widthWinActive - xC ; mirror coordinate yCAm := yWinActive + heightWinActive - yC ; mirror coordinate xWinActiveM := A_ScreenWidth - xWinActive - widthWinActive ; mirror coordinate yWinActiveM := A_ScreenHeight - yWinActive - heightWinActive ; mirror coordinate PixelGetColor, color, xC, yC , RGB ;--------------------------------------------- GetKeyState, ksLButton, LButton, p GetKeyState, ksRButton, RButton, p if (ksLButton="D" OR ksRButton="D") ;ok { if xD= { xD = %xC% yD = %yC% xWin2 = %xWinUnder% yWin2 = %yWinUnder% } xWinDrag := xWin2 - xD + xC ; new window position x yWinDrag := yWin2 - yD + yC ; new window position y } else { xD= yD= xWinDrag= yWinDrag= } ;--------------------------- ; Display window-info in window edit-control if flagWindowInfo = 2 ; skip tooltip in window mode RETURN if flagWindowInfo = 3 { ControlSetText, Edit1, %Info1Tips%%tooltip1Info%, Ahk Window Spy - RETURN } ;----------------------------; Display window-info in tooltip if classUnder=tooltips_class32 Tooltip else IfWinActive AutoHotkey.ini - ; handle tooltip-related bugs { typeTooltip= IfInString, titleUnder, AutoHotkey.ini - typeTooltip=2 ; sets which tooltip format StringLeft, PointerType, A_Cursor, 4 if PointerType=Size typeTooltip=2 if controlUnder= typeTooltip=2 if classUnder=Shell_TrayWnd { if controlUnder<> typeTooltip= else typeTooltip=2 } if typeTooltip=2 ToolTip, %tooltip2Info% else ToolTip, %tooltip1Info% } else { IfInString, titleUnder, AutoHotkey.ini { IfWinNotActive, ini - AutoHotkey ToolTip, %tooltip2Info% } else ToolTip, %tooltip1Info% } Return ;--------------------------------- ws_GuiClose: ; cannot GoTo external subroutine from Function if WinExist("Ahk Window Spy - ") AND NOT WinExist("Ahk Window Spy - Window Chart") WinGetPos, ws_xGui, ws_yGui, ws_wGui, ws_hGui, Ahk Window Spy - ; remember win position & size SetTimer, PointerWindowInfo, off sleep 300 Gui, Destroy flagWindowInfo= Tooltip return WindowChart: if A_GuiEvent = RightClick { LV_GetText(LV_winId, A_EventInfo, 2) msgbox %LV_winId% ;WinHide, ahk_id %LV_winId% } else if A_GuiEvent = DoubleClick ;DoubleClick { LV_GetText(LV_winId, A_EventInfo, 2) LV_GetText(isHidden, A_EventInfo, 6) if isHidden RETURN ;msgbox %LV_winId% ;WinShow, ahk_id %LV_winId% WinRestore, ahk_id %LV_winId% WinActivate, ahk_id %LV_winId% } return } ;----------------------- End Function: Ahk Window Spy GuiSize: ; Allows the control to grow or shrink in response to user's resizing of window. if A_EventInfo = 1 ; The window has been minimized. No action needed. return ControlGetFocus, gui_control_ID, A if gui_control_ID contains Edit,SysListView GuiControl, Move, %gui_control_ID%, % "W" . (A_GuiWidth - 17) . " H" . (A_GuiHeight - 8) ; xm=x at margin return WinW(windowTitleElement="", secToWait=30) ; WinWait,WinActivate,WinWaitActive { SetTitleMatchMode, 2 WinWait %windowTitleElement%,, %secToWait% WinActivate WinWaitActive,,, %secToWait% ; default 30 sec maximum ifWinNotActive %windowTitleElement% Msgbox, Target window did not activate within %secToWait% sec.`n`nThe originating thread may cause problems if it continues. return } GuiClose: ; Indicate that the script should exit automatically when GUI window is closed. GuiEscape: ; NEXT 2 LINES REPLACE THOSE FROM PREVIOUS VERSION if WinExist("Ahk Window Spy - ") CloseGUI = 1 ; let ws_GuiClose function subroutine handle this Gui Destroy Tooltip return /* THIS ROUTINE FROM PREVIOUS VERSION MAY BE DELETED PointerWindowInfoOff: WinGetPos, ws_xGui, ws_yGui, ws_wGui, ws_hGui, Ahk Window Spy - Gui, Destroy sleep 300 flagWindowInfo= Tooltip return */ ;----------------------------------------------------------------
110.2 Ahk Window Spy 1.3.3
Started by
Decarlo110
, Jul 26 2005 08:10 PM
13 replies to this topic
#1
-
Posted 26 July 2005 - 08:10 PM
1) The Open Source Definition http://www.opensourc...ition_plain.php
2) Intuitive. Logical. Versatile. Adaptable. <>
2) Intuitive. Logical. Versatile. Adaptable. <
That's interesting.
I only tried it briefly, but it behaves a little strangely on my system: pressing Win+Alt+W causes a screen-filling tooltip to appear, which might be normal for the window it was analyzing.
If this or any other script ever reaches the point where it is deemed superior to the current Window Spy (maybe it already is), we could have a poll or discussion about whether the script should be distributed with AutoHotkey.
Thanks for posting it.
I only tried it briefly, but it behaves a little strangely on my system: pressing Win+Alt+W causes a screen-filling tooltip to appear, which might be normal for the window it was analyzing.
If this or any other script ever reaches the point where it is deemed superior to the current Window Spy (maybe it already is), we could have a poll or discussion about whether the script should be distributed with AutoHotkey.
Thanks for posting it.
#2
-
Posted 27 July 2005 - 02:11 AM
on my system: pressing Win+Alt+W causes a screen-filling tooltip to appear, which might be normal for the window it was analyzing.
I've tried to determine the different reasons for the screen-filling behavior on my (Win2000) system, and have sufficiently remedied them, at least on my computer. There are likely other factors present in XP systems, as well as user-specific software configurations; plus the tooltip behavior seems to be one of the more peculiar about AutoHotkey. But i like programs with peculiarities anyway. 8)
Thanks for mentioning the possibility of distributing it along with AutoHotkey; that would be great if it did happen, and hopefully others can find more bugs or help fix them, or even improve the code. Feel free to make any modifications you see fit.
#3
-
Posted 27 July 2005 - 02:35 AM
1) The Open Source Definition http://www.opensourc...ition_plain.php
2) Intuitive. Logical. Versatile. Adaptable. <>
2) Intuitive. Logical. Versatile. Adaptable. <
Have these changes been applied to the code in the first post (the post doesn't appear to be modified...) ? I'd be interested in testing the "patched" version .I've tried to determine the different reasons for the screen-filling behavior on my (Win2000) system, and have sufficiently remedied them, at least on my computer.
#4
-
Posted 27 July 2005 - 02:42 AM
I'd be interested in testing the "patched" version
Sorry, i was unclear; i was only referring to the normal tooltip behavior prior to my applying any specific code to address the screen-filling phenomena. The code is unchanged from the original post. One of the reasons i put in the cursor type field is i noticed on my system that one of the things that caused the screen-filling is when the cursor is a resize arrow when "AutoHotkey.ini" is in the title of the active window.
#5
-
Posted 27 July 2005 - 03:00 AM
1) The Open Source Definition http://www.opensourc...ition_plain.php
2) Intuitive. Logical. Versatile. Adaptable. <>
2) Intuitive. Logical. Versatile. Adaptable. <
Nice script. The fact that its an AHK solution is even nicer.
Perhaps some more features and AHKers can say good bye to AU3Spy
Perhaps some more features and AHKers can say good bye to AU3Spy
#6
-
Posted 26 October 2005 - 06:35 AM
The screen filling occurs when the mouse hovers over the tooltip.
#7
-
Posted 26 October 2005 - 11:48 AM
if winexist("Ahk Window Spy -") { if PIDActive = %PIDUnder% return } else { if PIDActive != %PIDUnder% return }
#8
-
Posted 27 October 2005 - 05:24 PM
This tool should perhabs be renamed AHK Window Info . Anything with the word "Spy", even if it is not doing anything bad, just sounds bad these days.
#9
-
Posted 11 March 2006 - 02:27 PM
I'll make sure this is on the to-do list for serious consideration. It's interesting to note that in spite of the extreme security measures being introduced in Windows Vista, I believe Microsoft is still distributing the program Spy++ with their Visual Studio products (though I haven't checked the latest 8.x versions).
#10
-
Posted 11 March 2006 - 04:32 PM
Thank you for this script.
I am using Autohotkey_l and I get the following error:
Error: Invalid option.
Specifically: VScroll
I googling and searching the forum did not show anybody else mentioning this problem.
Would you happen to know what the problem is?
#12
-
Posted 31 March 2013 - 06:53 AM
You can remove VScroll from all Gui lines and the script should then work better. Note that there are now other scripts https://ahknet.autoh...ormationgetters
#13
-
Posted 31 March 2013 - 09:11 AM