AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Window Spy with configurable hotkey

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Tue Apr 13, 2004 8:13 am    Post subject: Window Spy with configurable hotkey Reply with quote

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)

Code:
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

_________________
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Tue Apr 13, 2004 12:40 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Tue Apr 13, 2004 2:32 pm    Post subject: Reply with quote

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.
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group