Jump to content

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

Window Spy with configurable hotkey


  • Please log in to reply
2 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
not many ppl know that the window spy from Au3 has hotkey support (ctrl+alt+f) to freeze current info. till now AHK's window spy doesn't have it so it gets difficult to freeze some info in it.

here's a script which has the hotkey Win+q and has the following advanages:
-The info is shown in an editor so can be saved easily by just pressing ctrl+s
(saved to file MyWinSpy.txt in script's folder)
-The mouse position is shown both relative to window and relative to screen.
-The window remains minimized and doesn't hide screen.
-The info changes only when Win+q is pressed and not when u're trying to select something from the window or switching windows.

here's a disadvantage that i notice:
-The currently selected control is shown, instead of the control under mouse.

(remember to alter control as per OS, details in script)

DetectHiddenWindows, On 
DetectHiddenText, On
SetWindelay, 1
Setkeydelay, 0
setbatchlines,10ms

;Configure editor & control here (notepad doesn't like my script ;)
;For windows 98 the control is RICHEDIT20A1
;For windows XP the control is RICHEDIT50W1

SetEnv, Editor, write
SetEnv, EditControl, RICHEDIT50W1


FileDelete, %a_scriptdir%\MyWinSpy.txt
FileAppend, `n, %a_scriptdir%\MyWinSpy.txt
IfWinnotexist,MyWinSpy.txt,,run, %editor% "%a_scriptdir%\MyWinSpy.txt",,min
WinWait, MyWinSpy.txt

#q::
WinGetActiveStats, Title, wW, wH, wX, wY
WinGetText, text, %title%
MouseGetPos, wmX, wmY
PixelGetColor, pix, %wmX%, %wmY%
ControlGetFocus, Control,%title%
StatusBarGetText, SBar,,%title%

SetEnv, dmX, %wmX%
SetEnv, dmY, %wmY%
Envadd, dmX, %wX%
Envadd, dmY, %wY%

IfWinnotexist,MyWinSpy.txt,,run, %editor% "%a_scriptdir%\MyWinSpy.txt",,min
WinWait, MyWinSpy.txt

Setenv, Info,

Setenv, Info, %Info%----------[Window Title]----------`n%title%`n`n
Setenv, Info, %Info%----------[Window Text]-----------`n%text%`n`n
Setenv, Info, %Info%--------[Window Position]---------`nleft: %wX%     top: %wY%      width: %wW%      height: %wH%`n`n
Setenv, Info, %Info%---------[Mouse Position]---------`nRelative to Window	X: %wmX%     Y: %wmY%`n`nRelative to Screen	X: %dmX%     Y: %dmY%`n`n
Setenv, Info, %Info%----------[Pixel Color]-----------`n%pix%`n`n
Setenv, Info, %Info%--------[Status Bar Text]---------`n%SBar%`n`n
Setenv, Info, %Info%-------[Selected Control]---------`n%control%`n`n

ControlSetText, %EditControl%,%info%, MyWinSpy.txt

return

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I was meaning to add that Ctrl-Alt-F hotkey if there's a need (though it won't work if a script or other program already has that hotkey registered). Note that you can shift-alt-tab or alt-tab to Window Spy to get its info to freeze. In other words, the moment the window becomes active by any means, it stops updating.

I think I like your script better than Window Spy because it's so much quicker. There's a similar item on the to-do list but it involves assigning a default or user-defined hotkey to show the main window, which then displays snapshot info similar to yours.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
yes alt+tab freezes it and is good. though i remember some guy asking for a hotkey + saving ability in win spy in some post i'd read. so i thought this script might help in such cases... though while coding it i never intended to completely replace win spy. (though except for the li'l disadvantage i've mentioned, it just might!)

and if u say i might code it in a way so that its optional whether one wants continuous updation + hotkey freeze OR updation by hotkey.....or u can change it to suit ur liking.

....anyways just plz don't devote ur coding time to making a win spy with hotkey... it'd b better to just do it with a script like this one.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat