/Source/AHK_Window_Info/AHK_Window_Info_v1.7.ahk

http://autohotkey-cn.googlecode.com/ · AutoHotKey · 1915 lines · 1452 code · 247 blank · 216 comment · 14 complexity · 9a6fc7e71cfae84680da5b2dd1711558 MD5 · raw file

  1. ;Reveal information on windows, controls, etc.
  2. ;by toralf
  3. ;requires AHK 1.0.44.04
  4. ;www.autohotkey.com/forum/topic8976.html
  5. ScriptName = AHK Window Info 1.7
  6. ; License: Attribution-NonCommercial-ShareAlike 2.5 licence from Creative Commons
  7. ; for details see: http://creativecommons.org/licenses/by-nc-sa/2.5/legalcode
  8. ;
  9. ; export code by sosaited www.autohotkey.com/forum/viewtopic.php?t=8732&p=53372#53372
  10. ; idea and lot of code of frame drawing by shimanov
  11. ; several ideas from Chris and other users of the AHK forum
  12. ; initial ideas taken from these scripts:
  13. ; Ahk Window Spy 1.3.3 by Decarlo www.autohotkey.com/forum/viewtopic.php?t=4679
  14. ; WinInfo Menu by Jon www.autohotkey.com/forum/viewtopic.php?t=8617
  15. ;changes since 1.6
  16. ; - added a small gap in the mouse picker grid to identify the center (thanks fade2gray)
  17. ; - adjusted groupbox size and tab size
  18. ; - added reset of picker to default color on dimensional change
  19. ;changes since 1.5
  20. ; - Groupboxes with bold text have been set -wrap, to fix line breaks on some windows themes
  21. ; - BGR is made default for color picker
  22. ; - update is stopped when mouse moves over its own gui, allowing easier graping of data, since no Pause key needs to be pressed.
  23. ;changes since 1.4
  24. ; - "H" replaced with Hwnd; "P" and "S" with "Pos" and "Size" on advanced tab for Control
  25. ; - GroupBox names have bold font
  26. ; - Mouse color picker is only updated when mouse tab is visible. Otherwise set to gray
  27. ; - set default for color picker to 15x15, since it only influences CPU load when the mouse tab is visible
  28. ; - controls list items are only updated when advanced tab is visible. Otherwise set to ">>>not updated<<<""
  29. ; - windows statusbar text is only updated when advanced tab is visible. Otherwise set to ">>>not updated<<<""
  30. ; - fast/slow visible/hidden window text are only updated when advanced tab is visible. Otherwise set to ">>>not updated<<<""
  31. ;todo
  32. ; - Window Info should be tested on Windows 9x
  33. ;changes since 1.3
  34. ; - last tab gets remembered between starts
  35. ; - large list hides automatically when tab is not "Advanced"
  36. ; - by default not rectangle is drawn around controls
  37. ; - gui starts NoActivate
  38. ; - fixed a problem with hidden gui and pause key
  39. ; - reduced impact in hidden mode on CPU load to nearly 0
  40. ; - to support 800x600 screen resolutions the advanced tab initial height is 600
  41. ; - instead of auto-update, update of data can be done on mouse click (button can be L/M/R, default M)
  42. ; - when started with "HideGui" turned on: GUI starts hidden, after 500 ms data is collected and GUI shown
  43. ; - changed licence to Attribution-NonCommercial-ShareAlike 2.5 licence from Creative Commons
  44. ;changes since 1.2
  45. ; - added: Control handle to advanced and list view
  46. ; - improved: fixed some spelling mistakes
  47. ; - fixed: option "Show tooltip at cursor" had no effect
  48. ; - fixed: option "Show tooltip at cursor" wasn't remembered between sessions
  49. ; - improved: For all DllCall's the types are put in quotes
  50. ; - changed: coordinates and sizes will have a space after the comma when put on clipboard
  51. ; - changed: the number of characters in the GUI for the list items is limited to 200. Clipboard will receive all
  52. ; - changed: "Introduction - Please Read" button moved to new info tab
  53. ; - changed: Renamed "active control in window" to "focused control in window".
  54. ; - fixed: Window Info refused to minimize while the right-side list was displayed.
  55. ; - changed: While Window Info is minimized, updating of data is turned off
  56. ; - fixed: Coordinates of GUI got stored when GUI got closed minimized
  57. ;changes since 1.1
  58. ; - added: OnExit routine that cleans up frame gui if script exits unexpectedly
  59. ; - changed: Tooltip of control frame disappears when mouse gets moved onto it.
  60. ; - changed: font size of GUI is now 6pt
  61. ;changes since 1.0
  62. ; - improved: specified the font for the GUI, MS Sans Serif, 8 point
  63. ; - changed: for some OS (WIN_2000,WIN_NT4,WIN_95,WIN_98,WIN_ME) the icon is changed to ID 57
  64. ; - improved: small features that simplify maintenance
  65. ; + combine update routines
  66. ; + simplify options actions
  67. ; + simplify Pause Key actions
  68. ; + reorder code
  69. ; - improved: new method to capture fast/slow visible/hidden window text (Thanks Chris)
  70. ; - changed: Gui (advanced) now holds fields for fast/slow visible/hidden window text
  71. ; - added: option to switch color picker between RGB and BGR
  72. ; - improved: color picker only updates when mouse moves or color below mouse changes. This reduces jittery update.
  73. ; - changed: Color picker now has a 15x15 color matrix
  74. ; - changed: checkbox "Show right List" changed to button that alternates between "More Info >>" and "<< Less Info".
  75. ; - added: check for minium required AHK version
  76. ; - added: new option to turn auto-update automatically ON when Gui gets inactive (if it had been turned off (by pause or by the large list))
  77. /*
  78. Requests:
  79. [quote="Chris"]Sometimes pressing Window Info's minimize button fails to work.[/quote]I still can't reproduce it. I tried it 20 times any each time the window minimized
  80. [quote="Chris"]I've made a note to test it on Win9x prior to distribution.[/quote]Please do. Or is there someone else out there to do the testing. Would be very much appreaciated.
  81. [quote="Chris"]Minor typos in source code comments: "or less or" should be "or else" in 2 places.[/quote]The two cases where "or less or" is written are actually correct.
  82. */
  83. AHK_version = 1.0.44.04
  84. If not A_IsCompiled ;if it is a script
  85. CheckAHKVersion(AHK_version) ;check if minimum AHK Version is installed
  86. InformationText =
  87. (LTrim
  88. This Gui will reveal information on windows, controls, etc.
  89. This software is under the GNU General Public License for details see: www.autohotkey.com/docs/license.htm
  90. Move your mouse over the area of interest and see the data in this GUI changing accordingly (auto-update). The auto-update stops when this GUI becomes the active one. To achieve this without moving the mouse you can use Alt+Tab to change to %ScriptName%. Or you can use a hotkey to turn the auto-update off. The default hotkey is the Pause key.
  91. When the data for the large list is collected (advanced tab), the auto-update of the data is stopped automatically to allow you to work with the data. Use the toggle hotkey (see below) to create a new snapshot of data. Or turn on the option, to start updating again when the GUI gets deactivated.
  92. These shortcuts exist:
  93. =================
  94. => Toggle Auto-Update Hotkey (default: Pause):
  95. ---------------------------------------------------------------------------
  96. Toggles (start/stop) auto-updating data in GUI OR creates a new snapshot of data when auto-update has been stopped automatically.
  97. => Left-Mouse Button:
  98. ---------------------------------------
  99. Copies the content of a control to the clipboard. This is achieved in the code with OnMessage(), thus it should not interfere with any of your own hotkeys.
  100. => Middle-Mouse Button:
  101. ---------------------------------------
  102. Toggles AlwaysOnTop status of this window. Click inside the window, it will not work on the titlebar. This is achieved in the code with OnMessage(), thus it should not interfere with any of your own hotkeys.
  103. => Win+s hotkey combination:
  104. ------------------------------------------------
  105. Exports data to file. It will only work, when auto-update has been stopped.
  106. Remarks:
  107. =======
  108. - You can change the toggle auto-update hotkey in the advanced options (you will not see keys that do not produces visible characters, e.g. the default Pause key). A key has to be specified. A single Ctrl, Shift, Alt, Win key or their combinations are not allowed.
  109. - The advanced option "Hide/Show Gui" allows you to create snapshots of data while the GUI is hidden. The toggle auto-update hotkey will toggle the visibility of the GUI. Just before the GUI is shown again the data gets collected and the GUI updated.
  110. - Log to file only works when auto-update has been stopped.
  111. - Specify a file name you want to save the data too. Insert #'s into the filename, if you want %ScriptName% to number the files automatically.
  112. )
  113. #SingleInstance force
  114. ;set working dir, in case this script is called from some other script in a different dir
  115. SetWorkingDir, %A_ScriptDir%
  116. GoSub, ReadIni
  117. GoSub, CreateTrayMenu
  118. GoSub, BuildGui
  119. WindowControlTextSize = 32767 ; Must be 32767 or less or it won't work on Windows 95.
  120. VarSetCapacity(WindowControlText, WindowControlTextSize)
  121. ControlTextSize = 512 ; Must be 32767 or less or it won't work on Windows 95.
  122. VarSetCapacity(ControlText, ControlTextSize)
  123. ;activate auto-update toggle hotkey
  124. HotKey, %HtkPauseAction%, PauseAction, On
  125. ;toggle AOT attribute of GUI with middle mouse click
  126. WM_MBUTTONDOWN = 0x207
  127. OnMessage(WM_MBUTTONDOWN, "ToggleOnTopGui1")
  128. ;initialize Save hotkey, so it can be easily turned on/off
  129. HotKey, #s, BtnSaveExport, Off
  130. ;initialize update on click hotkey, so it can be easily turned on/off
  131. Hotkey, IfWinNotActive, ahk_id %Gui1UniqueID%
  132. Hotkey, ~%CbbHtkUpdate%, UpdateOnClick, Off
  133. Hotkey, IfWinNotActive
  134. ;activate update on click
  135. If RadUpdateOnClick {
  136. Hotkey, IfWinNotActive, ahk_id %Gui1UniqueID%
  137. Hotkey, ~%CbbHtkUpdate%, On
  138. Hotkey, IfWinNotActive
  139. }Else{
  140. ;activate auto-start updating at Gui inactivity
  141. WM_ACTIVATE = 0x6
  142. If ChkAutoStartUpdate
  143. OnMessage(WM_ACTIVATE, "WM_ACTIVATE")
  144. ;set timer once, so that it knows its interval and can be easily turned on/off
  145. UpdateIsStopped := True
  146. SetTimer, UpdateInfo, %CbbUpdateInterval%
  147. If ChkHideGui {
  148. Sleep, 500
  149. Gosub, PauseAction
  150. ToolTip("Press Pause to hide GUI again", 2000)
  151. }Else
  152. UpdateIsStopped := False
  153. }
  154. ;activate copy-on-click for left mouse click
  155. WM_LBUTTONDOWN = 0x201
  156. If ChkCopyToCB
  157. OnMessage(WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
  158. ;set static parameters to draw frames around control and window
  159. Sysget, ScreenWidth, 78 ; get screen size from virtual screen
  160. Sysget, ScreenHeight, 79
  161. frame_cc = 0x0000FF ;set color for frame, 0x00BBGGRR
  162. frame_cw = 0x00FF00 ;set color for frame, 0x00BBGGRR
  163. frame_t = 2 ;set line thickness for frame, 1-10
  164. GoSub, ToogleExportActions
  165. GoSub, PrepareFrameDraw ;create or destroy frame drawing objects
  166. OnExit, ExitSub
  167. Return
  168. ;######## End of Auto-Exec-Section
  169. ExitSub:
  170. GoSub, CleanUpFrameGui
  171. Sleep,50
  172. ExitApp
  173. Return
  174. ReadIni:
  175. SplitPath, A_ScriptName, , , , OutNameNoExt
  176. IniFile = %OutNameNoExt%.ini
  177. IniRead, Gui1Pos , %IniFile%, Settings, Gui1Pos , x0 y0
  178. IniRead, Gui1AOTState , %IniFile%, Settings, Gui1AOTState , 1
  179. IniRead, Tab1 , %IniFile%, Settings, Tab1 , 1
  180. IniRead, RadWindow , %IniFile%, Settings, RadWindow , 2
  181. IniRead, RadControl , %IniFile%, Settings, RadControl , 2
  182. IniRead, SelectedRadList , %IniFile%, Settings, SelectedRadList , 1
  183. IniRead, ChkShowList , %IniFile%, Settings, ChkShowList , 0
  184. IniRead, HtkPauseAction , %IniFile%, Settings, HtkPauseAction , Pause
  185. IniRead, ChkCopyToCB , %IniFile%, Settings, ChkCopyToCB , 1
  186. IniRead, ChkHideGui , %IniFile%, Settings, ChkHideGui , 0
  187. IniRead, ChkUseSaveHotkey , %IniFile%, Settings, ChkUseSaveHotkey , 0
  188. IniRead, ChkExportMousePosScreen , %IniFile%, Export , ChkExportMousePosScreen, 1
  189. IniRead, ChkExportMousePosAWin , %IniFile%, Export , ChkExportMousePosAWin , 0
  190. IniRead, ChkExportMousePosWin , %IniFile%, Export , ChkExportMousePosWin , 1
  191. IniRead, ChkExportMousePointer , %IniFile%, Export , ChkExportMousePointer , 0
  192. IniRead, ChkExportMouseColorRGB , %IniFile%, Export , ChkExportMouseColorRGB , 0
  193. IniRead, ChkExportMouseColorHex , %IniFile%, Export , ChkExportMouseColorHex , 0
  194. IniRead, ChkExportCtrlText , %IniFile%, Export , ChkExportCtrlText , 1
  195. IniRead, ChkExportCtrlClass , %IniFile%, Export , ChkExportCtrlClass , 1
  196. IniRead, ChkExportCtrlPos , %IniFile%, Export , ChkExportCtrlPos , 0
  197. IniRead, ChkExportCtrlSize , %IniFile%, Export , ChkExportCtrlSize , 0
  198. IniRead, ChkExportCtrlListItems , %IniFile%, Export , ChkExportCtrlListItems , 0
  199. IniRead, ChkExportWinTitle , %IniFile%, Export , ChkExportWinTitle , 1
  200. IniRead, ChkExportWinPos , %IniFile%, Export , ChkExportWinPos , 0
  201. IniRead, ChkExportWinSize , %IniFile%, Export , ChkExportWinSize , 0
  202. IniRead, ChkExportWinClass , %IniFile%, Export , ChkExportWinClass , 1
  203. IniRead, ChkExportWinProcess , %IniFile%, Export , ChkExportWinProcess , 1
  204. IniRead, ChkExportWinUID , %IniFile%, Export , ChkExportWinUID , 0
  205. IniRead, ChkExportWinPID , %IniFile%, Export , ChkExportWinPID , 0
  206. IniRead, ChkExportWinStatusText , %IniFile%, Export , ChkExportWinStatusText , 1
  207. IniRead, ChkExportWinText , %IniFile%, Export , ChkExportWinText , 1
  208. IniRead, ChkExportLargeList , %IniFile%, Export , ChkExportLargeList , 1
  209. IniRead, EdtExportFile , %IniFile%, Export , EdtExportFile , AHK_Window_Info_Data_###.txt
  210. IniRead, ChkExportAutoNumber , %IniFile%, Export , ChkExportAutoNumber , 1
  211. IniRead, ChkExportAppend , %IniFile%, Export , ChkExportAppend , 0
  212. IniRead, ChkShowInfoToolTip , %IniFile%, Advanced, ChkShowInfoToolTip , 1
  213. IniRead, ChkDrawRectCtrl , %IniFile%, Advanced, ChkDrawRectCtrl , 0
  214. IniRead, ChkDrawRectWin , %IniFile%, Advanced, ChkDrawRectWin , 0
  215. IniRead, ChkTtpMaster , %IniFile%, Advanced, ChkTtpMaster , 0
  216. IniRead, ChkTtpMSPos , %IniFile%, Advanced, ChkTtpMSPos , 0
  217. IniRead, ChkTtpMWPos , %IniFile%, Advanced, ChkTtpMWPos , 1
  218. IniRead, ChkTtpMColor , %IniFile%, Advanced, ChkTtpMColor , 1
  219. IniRead, ChkTtpCClass , %IniFile%, Advanced, ChkTtpCClass , 1
  220. IniRead, ChkTtpCPos , %IniFile%, Advanced, ChkTtpCPos , 0
  221. IniRead, ChkTtpCSize , %IniFile%, Advanced, ChkTtpCSize , 0
  222. IniRead, ChkTtpWClass , %IniFile%, Advanced, ChkTtpWClass , 1
  223. IniRead, ChkTtpWTitle , %IniFile%, Advanced, ChkTtpWTitle , 1
  224. IniRead, CbbUpdateInterval , %IniFile%, Advanced, CbbUpdateInterval , 100
  225. IniRead, CbbColorPickDim , %IniFile%, Advanced, CbbColorPickDim , 15x15
  226. IniRead, RadColorPick , %IniFile%, Advanced, RadColorPick , 2
  227. IniRead, ChkAutoStartUpdate , %IniFile%, Advanced, ChkAutoStartUpdate , 1
  228. IniRead, CbbHtkUpdate , %IniFile%, Advanced, CbbHtkUpdate , MButton
  229. IniRead, RadUpdateOnClick , %IniFile%, Advanced, RadUpdateOnClick , 0
  230. IniRead, RadUpdateAuto , %IniFile%, Advanced, RadUpdateAuto , 1
  231. Return
  232. CreateTrayMenu:
  233. ;location of icon file
  234. IconFile := A_WinDir "\system" iif(A_OSType = "WIN32_WINDOWS","","32") "\shell32.dll"
  235. ;create traybar menu
  236. ;icon for taskbar and for proces in task manager
  237. If A_OSVersion in WIN_2000,WIN_NT4,WIN_95,WIN_98,WIN_ME
  238. Menu, Tray, Icon, %IconFile%, 57
  239. Else
  240. Menu, Tray, Icon, %IconFile%, 172
  241. Menu, Tray, NoStandard
  242. Menu, Tray, Tip, %ScriptName%
  243. Menu, Tray, Add, Show, GuiShow
  244. Menu, Tray, Default, Show
  245. Menu, Tray, Add, Exit, GuiClose
  246. Menu, Tray, Click, 1
  247. Return
  248. GuiShow:
  249. Gui, 1:Show ;show window again if it has been hidden
  250. Return
  251. BuildGui:
  252. GuiIsVisible := False
  253. Gui, 1: +Resize +LastFound
  254. Gui1UniqueID := WinExist()
  255. Gui, 1:Font, s6, MS Sans Serif
  256. Gui, 1:Margin, 0, 0
  257. Gui, 1:Add, Tab, w287 h145 vTab1 gTab1 AltSubmit -Wrap , Simple|Advanced|Mouse|Options|Info
  258. Gui, 1:Tab, Simple
  259. Gui, 1:Add, Text, x5 y28 , Window Title
  260. Gui, 1:Add, Edit, x+2 yp-3 w211 vEdtEasyWindowTitle,
  261. Gui, 1:Add, Text, x5 y+5, Window Class
  262. Gui, 1:Add, Edit, x+2 yp-3 w206 vEdtEasyWindowClass,
  263. Gui, 1:Add, Text, x5 y+5, Control ClassNN
  264. Gui, 1:Add, Edit, x+2 yp-3 w196 vEdtEasyControlClass,
  265. Gui, 1:Add, Text, x5 y+5, Control Text
  266. Gui, 1:Add, Edit, x+2 yp-3 w216 vEdtEasyControlText,
  267. Gui, 1:Add, Text, x5 y+5, Mouse Position relative to Window
  268. Gui, 1:Add, Edit, x+2 yp-3 w110 vEdtEasyMousePosWin,
  269. Gui, 1:Tab, Advanced
  270. Gui, 1:Add, Text, x5 y28 Section, Pos. rel. to Window
  271. Gui, 1:Add, Edit, x+2 yp-3 w80 vEdtDataMousePosWin,
  272. Gui, 1:Add, Button, x+28 yp-1 vBtnShowList gBtnShowList -Wrap, % iif(ChkShowList,"<< Less Info","More Info >>")
  273. Gui, 1:Font, bold
  274. Gui, 1:Add, GroupBox, xs w274 h114 -wrap, Control
  275. Gui, 1:Font, normal
  276. Gui, 1:Add, Text, xs+4 yp+18, Text
  277. Gui, 1:Add, Edit, x+2 yp-3 w104 vEdtControlText,
  278. Gui, 1:Add, Text, x+5 yp+3, ClassNN
  279. Gui, 1:Add, Edit, x+2 yp-3 w91 vEdtControlClass,
  280. Gui, 1:Add, Text, xs+4 y+5, Pos
  281. Gui, 1:Add, Edit, x+2 yp-3 w60 vEdtControlPos,
  282. Gui, 1:Add, Text, x+5 yp+3, Size
  283. Gui, 1:Add, Edit, x+2 yp-3 w65 vEdtControlSize,
  284. Gui, 1:Add, Text, x+5 yp+3, Hwnd
  285. Gui, 1:Add, Edit, x+2 yp-3 w59 vEdtControlHwnd,
  286. Gui, 1:Add, Text, xs+4 y+3, List`nItems
  287. Gui, 1:Add, Edit, x+4 r3 w237 vEdtListItems,
  288. Gui, 1:Font, bold
  289. Gui, 1:Add, GroupBox, xs w274 h492 -wrap vGrbAdvancedWindow, Window
  290. Gui, 1:Font, normal
  291. Gui, 1:Add, Text, xs+4 yp+18 , Title
  292. Gui, 1:Add, Edit, x+2 yp-3 w244 vEdtWindowTitle,
  293. Gui, 1:Add, Text, xs+4 y+5, Position
  294. Gui, 1:Add, Edit, x+2 yp-3 w88 vEdtWindowPos,
  295. Gui, 1:Add, Text, x+5 yp+3, Size
  296. Gui, 1:Add, Edit, x+2 yp-3 w112 vEdtWindowSize,
  297. Gui, 1:Add, Text, xs+4 y+5, Class
  298. Gui, 1:Add, Edit, x+2 yp-3 w100 vEdtWindowClass,
  299. Gui, 1:Add, Text, x+5 yp+3, Process
  300. Gui, 1:Add, Edit, x+2 yp-3 w94 vEdtWindowProcess,
  301. Gui, 1:Add, Text, xs+4 y+5, Unique ID
  302. Gui, 1:Add, Edit, x+2 yp-3 w77 vEdtWindowUID,
  303. Gui, 1:Add, Text, x+5 yp+3, Process ID
  304. Gui, 1:Add, Edit, x+2 yp-3 w80 vEdtWindowPID,
  305. Gui, 1:Add, Text, xs+4 y+3, StatusbarText (Part# - Text)
  306. Gui, 1:Add, ListBox, xs+4 y+2 r4 w266 vLsbStatusbarText,
  307. Gui, 1:Add, Text, xs+4 y+3 Section, Fast Visible Text
  308. Gui, 1:Add, Edit, y+2 r10 w132 vEdtWindowTextFastVisible,
  309. Gui, 1:Add, Text, x+2 ys, Fast Hidden Text
  310. Gui, 1:Add, Edit, y+2 r10 w132 vEdtWindowTextFastHidden,
  311. Gui, 1:Add, Text, xs Section vTxtWindowTextSlowVisible, Slow Visible Text
  312. Gui, 1:Add, Edit, y+2 r10 w132 vEdtWindowTextSlowVisible,
  313. Gui, 1:Add, Text, x+2 ys vTxtWindowTextSlowHidden, Slow Hidden Text
  314. Gui, 1:Add, Edit, y+2 r10 w132 vEdtWindowTextSlowHidden,
  315. Gui, 1:Tab, Mouse
  316. Gui, 1:Add, Text, x5 y28, Data of/under mouse cursor and Positions relative to
  317. Gui, 1:Add, Text, x5 y+5, Window
  318. Gui, 1:Add, Edit, x+2 yp-3 w106 vEdtMousePosWin,
  319. Gui, 1:Add, Text, x+5 yp+3, Screen
  320. Gui, 1:Add, Edit, x+2 yp-3 w88 vEdtMousePosScreen,
  321. Gui, 1:Add, Text, x5 y+5, Active Window
  322. Gui, 1:Add, Edit, x+2 yp-3 w73 vEdtMousePosAWin,
  323. Gui, 1:Add, Text, x+5 yp+3, Cursor
  324. Gui, 1:Add, Edit, x+2 yp-3 w92 vEdtMousePointer,
  325. Gui, 1:Add, Text, x5 y+5, RGB Color
  326. Gui, 1:Add, Edit, x+2 yp-3 w95 vEdtMouseColorRGB,
  327. Gui, 1:Add, Text, x+5 yp+3, RGB Color
  328. Gui, 1:Add, Edit, x+2 yp-3 w72 vEdtMouseColorHex,
  329. Gui, 1:Font, bold
  330. Gui, 1:Add, GroupBox, x5 y+10 Section w274 h305 -wrap, Color Picker
  331. Gui, 1:Font, normal
  332. Gui, 1:Add, Text, xs+4 yp+18, Dimension:
  333. Gui, 1:Add, ComboBox, x+5 yp-3 w55 vCbbColorPickDim gRefreshControlStates, 1x1|3x3||5x5|7x7|9x9|15x15
  334. Gui, 1:Add, Radio, x+5 yp+3 vRadColorPick gRefreshControlStates, RGB
  335. Gui, 1:Add, Radio, x+5 Checked gRefreshControlStates, BGR
  336. Gui, 1:Add, Text, xs+4 y+5 w10 h5 Section, ;only to create a gap to the color matix
  337. Loop, 15 {
  338. Row = %A_Index%
  339. dy := (Row = 8 OR Row = 9) ? "y+2" : ""
  340. Gui, 1:Add, Progress, xs+5 %dy% w17 h17 vPgbColorPicker%Row%_1,
  341. Loop, 14 {
  342. Column := A_Index + 1
  343. dx := (A_Index = 7 OR A_Index = 8) ? 2 : 0
  344. Gui, 1:Add, Progress, x+%dx% w17 h17 vPgbColorPicker%Row%_%Column%,
  345. }
  346. }
  347. Gui, 1:Tab, Options
  348. Gui, 1:Add, Text, x5 y25 Section , Show window and control data for
  349. Gui, 1:Add, Radio, xs y+5 vRadWindow gRefreshControlStates, Active Window
  350. Gui, 1:Add, Radio, xs y+5 Checked gRefreshControlStates, Window under Mouse Cursor
  351. Gui, 1:Add, Button, x+55 y25 gBtnShowOptions1, Advanced`nOptions
  352. Gui, 1:Add, Text, xs y+25, Show control data for
  353. Gui, 1:Add, Radio, xs y+5 vRadControl gRefreshControlStates, Focused Control in Window
  354. Gui, 1:Add, Radio, xs y+5 Checked gRefreshControlStates, Control under Mouse Cursor
  355. Gui, 1:Add, Checkbox, xs y+15 vChkTtpMaster gRefreshControlStates Checked%ChkTtpMaster%, Show tooltip at cursor
  356. Gui, 1:Add, Button, x+3 yp-5 gBtnShowOptions2, Data Filter Options
  357. Gui, 1:Add, Text, xs y+12 , Draw a rectangle around
  358. Gui, 1:Add, Checkbox, x+5 vChkDrawRectCtrl gChkDrawRectCtrl Checked%ChkDrawRectCtrl%, control (red)
  359. Gui, 1:Add, Checkbox, y+5 vChkDrawRectWin gChkDrawRectWin Checked%ChkDrawRectWin%, window (green)
  360. ExportOptions = ;collect all checkboxes, so they can be parsed in a loop
  361. (LTrim Join,
  362. ChkExportMousePosScreen,ChkExportMousePosAWin,ChkExportMousePosWin
  363. ChkExportMousePointer,ChkExportMouseColorRGB,ChkExportMouseColorHex
  364. ChkExportCtrlText,ChkExportCtrlClass,ChkExportCtrlPos
  365. ChkExportCtrlSize,ChkExportCtrlListItems,ChkExportWinTitle,ChkExportWinPos
  366. ChkExportWinSize,ChkExportWinClass,ChkExportWinProcess
  367. ChkExportWinUID,ChkExportWinPID,ChkExportWinStatusText
  368. ChkExportWinText,ChkExportLargeList
  369. )
  370. Gui, 1:Add, Text, xs y+17 ,Log Data to File
  371. Gui, 1:Add, Button, x+5 yp-5 gBtnShowOptions3, Log Options
  372. Gui, 1:Add, Button, x+5 vBtnSaveExport gBtnSaveExport, Save to file
  373. Gui, 1:Add, Edit, xs w255 vEdtExportFile, %EdtExportFile%
  374. Gui, 1:Add, Button, x+2 yp-1 gBtnBrowseExportFile,...
  375. Gui, 1:Tab, Info
  376. Gui, 1:Add, Text, x5 y25 Section ,
  377. (
  378. This GUI will reveal information on windows, controls, etc.,
  379. but only when this GUI is not the active window.
  380. - To start/stop updating data press the Auto-Update
  381. toggle Hotkey (default: Pause).
  382. - To put the content of a field on the clipboard click with
  383. the left mouse button into the field.
  384. - To toggle the always-on-top state of this GUI use the
  385. middle mouse button.
  386. )
  387. Gui, 1:Add, Button, x70 y+5 vBtnShowInfo gBtnShowInfo, More Information - Please read
  388. Gui, 1:Tab
  389. GuiControl, Choose, Tab1, %Tab1%
  390. Gui, 1:Add, Radio, x290 y2 Section vRadList1 gRadList, Info on all Controls of one window
  391. Gui, 1:Add, Radio, x+5 vRadList2 gRadList, Info on all Windows (Click radio buttons again to refresh list)
  392. Gui, 1:Add, ListView, xs y+5 w370 h339 vLV1 Count200
  393. , Z or Stack Order|Unique ID or Handle|Window PID|Class(NN)|Process Name|Hidden|Title or Text|X|Y|Width|Height|Style|ExStyle|Selected|CurrentCol|CurrentLine|LineCount|Choice|Tab|Enabled|Checked
  394. ;Apply settings
  395. If RadWindow = 1
  396. GuiControl, 1:, RadWindow, 1
  397. If RadControl = 1
  398. GuiControl, 1:, RadControl, 1
  399. If RadColorPick = 1
  400. GuiControl, 1:, RadColorPick, 1
  401. GuiControl, 1:, RadList%SelectedRadList%, 1
  402. GuiControl, 1:ChooseString, CbbColorPickDim, %CbbColorPickDim%
  403. StringSplit, Dim, CbbColorPickDim, x ;prepare color picker dimensions
  404. Dim = %Dim1%
  405. HalfDim := Dim // 2 + 1
  406. GoSub, ShowHideList
  407. If Gui1AOTState {
  408. Gui, 1:+AlwaysOnTop
  409. TitleExtension = - *AOT*
  410. }
  411. If ChkHideGui
  412. ShowOption = Hide
  413. Else
  414. ShowOption = NoActivate
  415. Gui, 1:Show, %Gui1Pos% %ShowOption% AutoSize , %ScriptName% %TitleExtension%
  416. If !ChkHideGui
  417. GuiIsVisible := True
  418. Return
  419. ;###############################################################################
  420. ;### prepare hotkey or mouse interaction with GUI ##########################
  421. ;###############################################################################
  422. WM_LBUTTONDOWN(wParam, lParam, msg, hwnd){ ;Copy-On-Click for controls
  423. global
  424. local Content
  425. If A_GuiControl is space ;Control is not known
  426. Return
  427. If A_GuiControl not contains Edt,Lsb,Pgb ;Control is something else then edit, listbox or progressbar control
  428. Return
  429. ;Check for full text vars
  430. Fulltext = %A_GuiControl%Full
  431. If (%Fulltext% <> "")
  432. Content := %Fulltext%
  433. Else {
  434. If A_GuiControl contains Pgb ;get value from color pickers (progressbar)
  435. Content := %A_GuiControl%
  436. Else
  437. GuiControlGet, Content, , %A_GuiControl% ;get controls content
  438. }
  439. If Content is space ;content is empty or couldn't be retrieved
  440. Return
  441. If A_GuiControl contains Class ;change data for specific fields
  442. Content = ahk_class %Content%
  443. Else If A_GuiControl contains UID
  444. Content = ahk_id %Content%
  445. Else If A_GuiControl contains PID
  446. Content = ahk_pid %Content%
  447. Else If A_GuiControl contains Process
  448. Content = ahk_pname %Content%
  449. Else If A_GuiControl contains Pos,Size
  450. {
  451. StringReplace, Content, Content, x
  452. StringReplace, Content, Content, y
  453. StringReplace, Content, Content, w
  454. StringReplace, Content, Content, h
  455. StringReplace, Content, Content, %A_Space%, `,%A_Space%
  456. }
  457. Else If A_GuiControl contains Pgb
  458. Content = 0x%Content%
  459. ClipBoard = %Content% ;put content in clipboard
  460. If ChkShowInfoToolTip {
  461. If (StrLen(Content) > 200){ ;give feedback (limit size to 200 characters)
  462. StringLeft, Content, Content, 200
  463. Content = %Content% ...
  464. }
  465. ToolTip("ClipBoard = " Content)
  466. }
  467. }
  468. WM_ACTIVATE(wParam, lParam, msg, hwnd){
  469. Global UpdateIsStopped, ChkHideGui
  470. If (wParam AND !ChkHideGui)
  471. UpdateIsStopped := False
  472. }
  473. UpdateOnClick:
  474. UpdateIsStopped := False ;needs to be set if large list had set it to true
  475. GoSub, UpdateInfo ;collect data
  476. Return
  477. PauseAction: ;user has pressed toogle auto-update hotkey
  478. If ChkHideGui { ;user wants hide/show toggle
  479. UpdateIsStopped := False ;needs to be set if large list had set it to true
  480. If GuiIsVisible {
  481. Gui, 1:Hide
  482. }Else{
  483. SetTimer, UpdateInfo, Off ;turn timer off, to collect only once data
  484. UpdateIsStopped := False ;turn update on
  485. UpdateAfterPause := True ;set flag to update all
  486. GoSub, UpdateInfo ;collect data
  487. UpdateAfterPause := False ;turn off flag to update all
  488. UpdateIsStopped := True ;turn update off
  489. SetTimer, UpdateInfo, %CbbUpdateInterval% ;turn timer back on
  490. GoSub, GuiShow ;bring GUI to front
  491. }
  492. GuiIsVisible := not GuiIsVisible
  493. If ChkShowInfoToolTip
  494. ToolTip(iif(UpdateIsStopped,"Press " HtkPauseAction " to hide GUI","Wait for " HtkPauseAction " key to`nupdate data and show GUI"),2000)
  495. }Else {
  496. UpdateIsStopped := not UpdateIsStopped ;toggle update status and show feedback
  497. If UpdateIsStopped ;when stopped, bring GUI to front
  498. GoSub, GuiShow
  499. If ChkShowInfoToolTip ;give feedback
  500. ToolTip(Scriptname "`n----------------------------`nUpdate data : " iif(UpdateIsStopped,"Off","On"))
  501. }
  502. GoSub, ToogleExportActions
  503. GoSub, PrepareFrameDraw ;create or destroy frame drawing objects
  504. Return
  505. ToogleExportActions:
  506. ;Disable Export Save button during update
  507. GuiControl, 1:Enable%UpdateIsStopped%, BtnSaveExport
  508. ;Enable Export Save hotkey when update is stopped and hotkey wanted
  509. If (ChkUseSaveHotkey AND UpdateIsStopped)
  510. HotKey, #s, , On
  511. Else ; ... otherwise de-activate Export Save hotkey
  512. HotKey, #s, , Off UseErrorLevel
  513. Return
  514. PrepareFrameDraw: ;create or destroy frame drawing objects
  515. If (UpdateIsStopped OR (ChkDrawRectCtrl = 0 AND ChkDrawRectWin = 0)){
  516. GoSub, CleanUpFrameGui
  517. ;create GUI Only if Gui doesn't exist yet and is needed.
  518. }Else If ( (ChkDrawRectCtrl OR ChkDrawRectWin) And not FrameGUIExists ){
  519. FrameGUIExists := True
  520. ;create transparent GUI covering the whole screen
  521. Gui, 2:+Lastfound +AlwaysOnTop
  522. Gui, 2:Color, Black
  523. WinSet, TransColor, Black
  524. Gui, 2: -Caption +ToolWindow
  525. Gui, 2:Show, x0 y0 w%ScreenWidth% h%ScreenHeight%, FrameDrawGUI2
  526. UniqueIDGui2 := WinExist()
  527. ;create draw objects for that window
  528. CreateDrawHandles(UniqueIDGui2, ScreenWidth, ScreenHeight, frame_cc, frame_cw)
  529. }
  530. ;set previous control/window to nothing, so that the frames start to draw immediatly
  531. PreviousControlID =
  532. PreviousWindowID =
  533. Return
  534. CleanUpFrameGui:
  535. DeleteObject( h_brushC ) ;destroy objects
  536. DeleteObject( h_brushW )
  537. DeleteObject( h_region )
  538. DeleteObject( hbm_buffer )
  539. DeleteDC( hdc_frame )
  540. DeleteDC( hdc_buffer )
  541. Gui, 2:Destroy ;destroy gui
  542. FrameGUIExists := False
  543. ToolTip, , , , 2 ;remove control frame tooltip
  544. ToolTip, , , , 3 ;remove window frame tooltip
  545. Return
  546. ;###############################################################################
  547. ;### Interactions with GUI controls ########################################
  548. ;###############################################################################
  549. Tab1:
  550. GuiControlGet, Tab1, 1: ;get current value
  551. GoSub, ClearNotUsedControls
  552. If (Tab1 = 1){ ;adjust tab height based on visible tab
  553. GuiControl, 1:Move, Tab1, h145
  554. }Else If (Tab1 = 2) {
  555. GuiControl, 1:Move, Tab1, h570
  556. }Else If (Tab1 = 3) {
  557. GuiControl, 1:Move, Tab1, h430
  558. }Else If (Tab1 = 4) {
  559. GuiControl, 1:Move, Tab1, h274
  560. }Else If (Tab1 = 5) {
  561. GuiControl, 1:Move, Tab1, h174
  562. }
  563. ChkShowList := False
  564. GoSub, ShowHideList
  565. Gui, 1:Show, AutoSize ;autosize GUI
  566. return
  567. ClearNotUsedControls:
  568. If (Tab1 <> 2) {
  569. GuiControl, 1:, EdtListItems, >>>not updated<<<
  570. GuiControl, 1:, LsbStatusbarText, |>>>not updated<<<
  571. GuiControl, 1:, EdtWindowTextFastVisible, >>>not updated<<<
  572. GuiControl, 1:, EdtWindowTextSlowVisible, >>>not updated<<<
  573. GuiControl, 1:, EdtWindowTextFastHidden, >>>not updated<<<
  574. GuiControl, 1:, EdtWindowTextSlowHidden, >>>not updated<<<
  575. }
  576. If (Tab1 <> 3) {
  577. Loop, %Dim% {
  578. Row := A_Index + 8 - HalfDim
  579. Loop, %Dim% {
  580. y++
  581. Control := "PgbColorPicker" (A_Index + 8 - HalfDim) "_" Row
  582. GuiControl, 1:+BackgroundECE9D8,%Control%
  583. }
  584. }
  585. }
  586. Return
  587. ShowHideList:
  588. GuiControl, 1:, BtnShowList, % iif(ChkShowList,"<< Less Info","More Info >>")
  589. GuiControl, 1:Show%ChkShowList%, RadList1 ;show/hide controls
  590. GuiControl, 1:Show%ChkShowList%, RadList2
  591. GuiControl, 1:Show%ChkShowList%, LV1 ;show/hide large list
  592. Return
  593. BtnShowList:
  594. ChkShowList := not ChkShowList
  595. GoSub, ShowHideList
  596. Gui, 1:Show, AutoSize ;autosize GUI
  597. If ChkShowList
  598. GoSub, GetDataForLargeList ;get data
  599. Return
  600. RadList:
  601. LV_Delete() ;clear controls
  602. StringRight, SelectedRadList, A_GuiControl, 1 ;get which got pressed
  603. Loop, 2 ;deactivate the other
  604. If (A_Index <> SelectedRadList)
  605. GuiControl, 1:, RadList%A_Index%, 0
  606. Gui, 1:Submit, NoHide
  607. GoSub, GetDataForLargeList ;get data
  608. Return
  609. GetDataForLargeList:
  610. If (RadList1 = 1){ ;get data depending on choice
  611. WindowUniqueID = %EdtWindowUID%
  612. If EdtWindowUID is not space
  613. GoSub, GetControlListInfo
  614. }
  615. Else
  616. GoSub, GetAllWindowsInfo
  617. Return
  618. RefreshControlStates:
  619. Gui, 1:Submit, NoHide ;get current values of all controls
  620. StringSplit, Dim, CbbColorPickDim, x ;prepare color picker dimensions
  621. Dim = %Dim1%
  622. HalfDim := Dim // 2 + 1
  623. Loop, 15 {
  624. Row = %A_Index%
  625. Loop, 15
  626. GuiControl, 1:+BackgroundDefault ,PgbColorPicker%Row%_%A_Index%
  627. }
  628. Return
  629. ChkDrawRectCtrl:
  630. GuiControlGet, ChkDrawRectCtrl, 1: ;get current value
  631. GoSub, PrepareFrameDraw
  632. ToolTip, , , , 2
  633. Return
  634. ChkDrawRectWin:
  635. GuiControlGet, ChkDrawRectWin, 1: ;get current value
  636. GoSub, PrepareFrameDraw
  637. ToolTip, , , , 3
  638. Return
  639. ;###############################################################################
  640. ;### GUI actions ###########################################################
  641. ;###############################################################################
  642. GuiSize:
  643. If (A_EventInfo = 0) { ;restored, or resized
  644. GuiControl, 1:Move, Tab1, h%A_GuiHeight%
  645. w := A_GuiWidth - 290
  646. h := A_GuiHeight - 22
  647. GuiControl, 1:Move, LV1, w%w% h%h%
  648. h -= 143
  649. GuiControl, 1:Move, GrbAdvancedWindow, h%h%
  650. h := (h - 218) / 2
  651. GuiControl, 1:Move, EdtWindowTextFastVisible, h%h%
  652. GuiControl, 1:Move, EdtWindowTextFastHidden, h%h%
  653. y := A_GuiHeight - h - 24
  654. GuiControl, 1:Move, TxtWindowTextSlowVisible, y%y%
  655. GuiControl, 1:Move, TxtWindowTextSlowHidden, y%y%
  656. y += 15
  657. GuiControl, 1:Move, EdtWindowTextSlowVisible, y%y% h%h%
  658. GuiControl, 1:Move, EdtWindowTextSlowHidden, y%y% h%h%
  659. If (LastEventInfo = 1){ ;Gui got restored
  660. ;start updating again
  661. UpdateIsStopped := False
  662. ;reactivate frame
  663. GoSub, PrepareFrameDraw
  664. }
  665. }Else If (A_EventInfo = 1) { ;minimized
  666. ;stop updating
  667. UpdateIsStopped := True
  668. ;remove frames
  669. GoSub, PrepareFrameDraw
  670. }
  671. LastEventInfo = %A_EventInfo%
  672. Return
  673. WriteIni:
  674. Gui, 1:Submit, NoHide
  675. WinGetPos, PosX, PosY, SizeW, SizeH, %WinNameGui1%
  676. Loop, 2
  677. If (RadList%A_Index% = 1)
  678. IniWrite, %A_Index% , %IniFile%, Settings, SelectedRadList
  679. If (PosX > -4 and PosY > -4)
  680. IniWrite, x%PosX% y%PosY% , %IniFile%, Settings, Gui1Pos
  681. IniWrite, %Gui1AOTState% , %IniFile%, Settings, Gui1AOTState
  682. IniWrite, %Tab1% , %IniFile%, Settings, Tab1
  683. IniWrite, %RadWindow% , %IniFile%, Settings, RadWindow
  684. IniWrite, %RadControl% , %IniFile%, Settings, RadControl
  685. IniWrite, %ChkShowList% , %IniFile%, Settings, ChkShowList
  686. IniWrite, %HtkPauseAction% , %IniFile%, Settings, HtkPauseAction
  687. IniWrite, %ChkCopyToCB% , %IniFile%, Settings, ChkCopyToCB
  688. IniWrite, %ChkHideGui% , %IniFile%, Settings, ChkHideGui
  689. IniWrite, %ChkUseSaveHotkey% , %IniFile%, Settings, ChkUseSaveHotkey
  690. Loop, Parse, ExportOptions, `,
  691. IniWrite, % %A_LoopField% , %IniFile%, Export , %A_LoopField%
  692. IniWrite, %EdtExportFile% , %IniFile%, Export , EdtExportFile
  693. IniWrite, %ChkExportAutoNumber%, %IniFile%, Export , ChkExportAutoNumber
  694. IniWrite, %ChkExportAppend% , %IniFile%, Export , ChkExportAppend
  695. IniWrite, %ChkShowInfoToolTip% , %IniFile%, Advanced, ChkShowInfoToolTip
  696. IniWrite, %ChkDrawRectCtrl% , %IniFile%, Advanced, ChkDrawRectCtrl
  697. IniWrite, %ChkDrawRectWin% , %IniFile%, Advanced, ChkDrawRectWin
  698. IniWrite, %ChkTtpMaster% , %IniFile%, Advanced, ChkTtpMaster
  699. IniWrite, %ChkTtpMSPos% , %IniFile%, Advanced, ChkTtpMSPos
  700. IniWrite, %ChkTtpMWPos% , %IniFile%, Advanced, ChkTtpMWPos
  701. IniWrite, %ChkTtpMColor% , %IniFile%, Advanced, ChkTtpMColor
  702. IniWrite, %ChkTtpCClass% , %IniFile%, Advanced, ChkTtpCClass
  703. IniWrite, %ChkTtpCPos% , %IniFile%, Advanced, ChkTtpCPos
  704. IniWrite, %ChkTtpCSize% , %IniFile%, Advanced, ChkTtpCSize
  705. IniWrite, %ChkTtpWClass% , %IniFile%, Advanced, ChkTtpWClass
  706. IniWrite, %ChkTtpWTitle% , %IniFile%, Advanced, ChkTtpWTitle
  707. IniWrite, %CbbUpdateInterval% , %IniFile%, Advanced, CbbUpdateInterval
  708. IniWrite, %CbbColorPickDim% , %IniFile%, Advanced, CbbColorPickDim
  709. IniWrite, %RadColorPick% , %IniFile%, Advanced, RadColorPick
  710. IniWrite, %ChkAutoStartUpdate% , %IniFile%, Advanced, ChkAutoStartUpdate
  711. IniWrite, %CbbHtkUpdate% , %IniFile%, Advanced, CbbHtkUpdate
  712. IniWrite, %RadUpdateOnClick% , %IniFile%, Advanced, RadUpdateOnClick
  713. IniWrite, %RadUpdateAuto% , %IniFile%, Advanced, RadUpdateAuto
  714. Return
  715. GuiClose:
  716. GuiEscape:
  717. GoSub, WriteIni
  718. ExitApp
  719. Return
  720. ;###############################################################################
  721. ;### GUI for information text ##############################################
  722. ;###############################################################################
  723. BtnShowInfo:
  724. GuiControl, 1:Disable, BtnShowInfo
  725. Gui, 3:+Owner1 +AlwaysOnTop +ToolWindow +Resize
  726. Gui, 3:Font, s8, MS Sans Serif
  727. Gui, 3:Add, Button, gCloseInfoGui, Close
  728. Gui, 3:Add, Edit, w600 h400 vEdtInfoText, %InformationText%
  729. Gui, 3:Show,, Info - %ScriptName%
  730. Return
  731. 3GuiClose:
  732. 3GuiEscape:
  733. CloseInfoGui:
  734. GuiControl, 1:Enable, BtnShowInfo
  735. Gui, 3:Destroy
  736. Return
  737. 3GuiSize:
  738. w := A_GuiWidth - 20
  739. h := A_GuiHeight - 45
  740. GuiControl, 3:Move, EdtInfoText, w%w% h%h%
  741. Return
  742. ;###############################################################################
  743. ;### GUI for options #######################################################
  744. ;###############################################################################
  745. BtnShowOptions1:
  746. ChangeToTab = 1
  747. GoSub, BtnShowOptions
  748. Return
  749. BtnShowOptions2:
  750. ChangeToTab = 2
  751. GoSub, BtnShowOptions
  752. Return
  753. BtnShowOptions3:
  754. ChangeToTab = 3
  755. GoSub, BtnShowOptions
  756. Return
  757. BtnShowOptions:
  758. UpdateIsStopped := True
  759. Hotkey, IfWinNotActive, ahk_id %Gui1UniqueID%
  760. Hotkey, ~%CbbHtkUpdate%, Off
  761. Hotkey, IfWinNotActive
  762. Gui, 1:+Disabled
  763. Gui, 4:+Owner1 +AlwaysOnTop +ToolWindow
  764. Gui, 4:Font, s8, MS Sans Serif
  765. Gui, 4:Add, Tab, Section w300 h390 vTab2 AltSubmit -Wrap, Advanced|ToolTip|Log to File
  766. Gui, 4:Tab, Advanced
  767. Gui, 4:Add, GroupBox, w275 h73, Update data
  768. Gui, 4:Add, Radio, xp+10 yp+22 Checked%RadUpdateOnClick% vRadUpdateOnClick gRadUpdate, on click with
  769. Gui, 4:Add, ComboBox, x+5 yp-3 w80 vCbbHtkUpdate, LButton|MButton||RButton
  770. Gui, 4:Add, Radio, x32 y+8 Checked%RadUpdateAuto% vRadUpdateAuto gRadUpdate, automatically every milliseconds:
  771. Gui, 4:Add, ComboBox, x+5 yp-3 w50 vCbbUpdateInterval, 100||200|300|400|500|1000|2000
  772. Gui, 4:Add, Checkbox, x22 y+20 vChkChangePauseHotkey gChkChangePauseHotkey, Change hotkey to toogle auto-update (default: Pause)
  773. Gui, 4:Add, Hotkey, xp+15 y+5 w150 vHtkPauseAction gHtkPauseAction Disabled, %HtkPauseAction%
  774. Gui, 4:Add, Checkbox, xp-15 y+5 vChkHideGui Checked%ChkHideGui%, Hide/Show GUI with above hotkey`;`nbefore the GUI is shown data will be collected
  775. Gui, 4:Add, Checkbox, y+5 vChkAutoStartUpdate Checked%ChkAutoStartUpdate%, Start updating of data again when Gui gets inactive`nafter auto-update has been turned off.
  776. Gui, 4:Add, Checkbox, y+5 vChkCopyToCB Checked%ChkCopyToCB%, Copy data to clipboard with left click on data field
  777. Gui, 4:Add, Text, y+20, When update is turned off:
  778. Gui, 4:Add, Checkbox, vChkUseSaveHotkey Checked%ChkUseSaveHotkey%, Use Win+S as hotkey to log data to file
  779. Gui, 4:Add, Checkbox, y+20 Section vChkShowInfoToolTip Checked%ChkShowInfoToolTip%, Show info-tooltips
  780. Gui, 4:Tab, ToolTip
  781. Gui, 4:Add, Text, , Check which data you want to see next to the mouse cursor
  782. Gui, 4:Add, Checkbox, vChkTtpMSPos Checked%ChkTtpMSPos%, Mouse position on screen *
  783. Gui, 4:Add, Checkbox, vChkTtpMWPos Checked%ChkTtpMWPos%, Mouse position on window
  784. Gui, 4:Add, Checkbox, vChkTtpMColor Checked%ChkTtpMColor%, Color under mouse pointer
  785. Gui, 4:Add, Checkbox, vChkTtpCClass Checked%ChkTtpCClass%, Control class under mouse pointer *
  786. Gui, 4:Add, Checkbox, vChkTtpCPos Checked%ChkTtpCPos%, Control position
  787. Gui, 4:Add, Checkbox, vChkTtpCSize Checked%ChkTtpCSize%, Control size
  788. Gui, 4:Add, Checkbox, vChkTtpWClass Checked%ChkTtpWClass%, Window class *
  789. Gui, 4:Add, Checkbox, vChkTtpWTitle Checked%ChkTtpWTitle%, Window title *
  790. Gui, 4:Add, Text, , (* = available when Gui is hidden)
  791. Gui, 4:Tab, Log to File
  792. Gui, 4:Add, GroupBox, Section w274 h70 , Log this Mouse Data
  793. Gui, 4:Add, Checkbox, vChkExportMousePosScreen Checked%ChkExportMousePosScreen% xs+4 yp+18, Position on Screen
  794. Gui, 4:Add, Checkbox, vChkExportMousePosAWin Checked%ChkExportMousePosAWin% xs+125 yp, Pos. rel. to active Window
  795. Gui, 4:Add, Checkbox, vChkExportMousePosWin Checked%ChkExportMousePosWin% xs+4 y+5, Pos. rel. to Window
  796. Gui, 4:Add, Checkbox, vChkExportMousePointer Checked%ChkExportMousePointer% xs+125 yp, Cursor Style
  797. Gui, 4:Add, Checkbox, vChkExportMouseColorRGB Checked%ChkExportMouseColorRGB% xs+4 y+5, RGB Color
  798. Gui, 4:Add, Checkbox, vChkExportMouseColorHex Checked%ChkExportMouseColorHex% xs+125 yp, Hex Color
  799. Gui, 4:Add, GroupBox, xs w274 h75 , Log this Control Data
  800. Gui, 4:Add, Checkbox, vChkExportCtrlText Checked%ChkExportCtrlText% xs+4 yp+18, Control Text
  801. Gui, 4:Add, Checkbox, vChkExportCtrlClass Checked%ChkExportCtrlClass% xs+125 yp, Control ClassNN
  802. Gui, 4:Add, Checkbox, vChkExportCtrlPos Checked%ChkExportCtrlPos% xs+4 y+5, Control Position
  803. Gui, 4:Add, Checkbox, vChkExportCtrlSize Checked%ChkExportCtrlSize% xs+125 yp, Control Size
  804. Gui, 4:Add, Checkbox, vChkExportCtrlListItems Checked%ChkExportCtrlListItems% xs+4 y+5, Control List Items
  805. Gui, 4:Add, GroupBox, xs w274 h110 , Log this Window Data
  806. Gui, 4:Add, Checkbox, vChkExportWinTitle Checked%ChkExportWinTitle% xs+4 yp+18, Window Title
  807. Gui, 4:Add, Checkbox, vChkExportWinPos Checked%ChkExportWinPos% xs+4 y+5, Window Position
  808. Gui, 4:Add, Checkbox, vChkExportWinSize Checked%ChkExportWinSize% xs+125 yp, Window Size
  809. Gui, 4:Add, Checkbox, vChkExportWinClass Checked%ChkExportWinClass% xs+4 y+5, Window Class
  810. Gui, 4:Add, Checkbox, vChkExportWinProcess Checked%ChkExportWinProcess% xs+125 yp, Window Process
  811. Gui, 4:Add, Checkbox, vChkExportWinUID Checked%ChkExportWinUID% xs+4 y+5, Window Unique ID
  812. Gui, 4:Add, Checkbox, vChkExportWinPID Checked%ChkExportWinPID% xs+125 yp, Win Process ID
  813. Gui, 4:Add, Checkbox, vChkExportWinStatusText Checked%ChkExportWinStatusText% xs+4 y+5, Statusbar Text
  814. Gui, 4:Add, Checkbox, vChkExportWinText Checked%ChkExportWinText% xs+125 yp, Window Text
  815. Gui, 4:Add, Checkbox, xs y+16 vChkExportLargeList Checked%ChkExportLargeList%, Log Large List Check:
  816. Gui, 4:Add, Button, x+2 yp-5 gBtnExportCheckAll, All
  817. Gui, 4:Add, Button, x+2 gBtnExportCheckNone , None
  818. Gui, 4:Add, Button, x+2 gBtnExportCheckReverse , Rev
  819. Gui, 4:Add, Text, xs y+5, Additional log options:
  820. Gui, 4:Add, Checkbox, y+5 Section vChkExportAutoNumber gChkExportAutoNumber Checked%ChkExportAutoNumber%, Replace "#" in filename with Numbers
  821. Gui, 4:Add, Checkbox, y+5 vChkExportAppend gChkExportAppend Checked%ChkExportAppend%, Append data to file
  822. Gui, 4:Tab
  823. Gui, 4:Add, Button, xm gApplyOptions, Apply Options
  824. Gui, 4:Add, Button, x+5 g4GuiClose, Cancel
  825. If RadUpdateOnClick {
  826. GuiControl, 4:Disable, ChkChangePauseHotkey
  827. GuiControl, 4:Disable, ChkHideGui
  828. GuiControl, 4:Disable, ChkAutoStartUpdate
  829. }
  830. GuiControl, 4:ChooseString, CbbHtkUpdate, %CbbHtkUpdate%
  831. GuiControl, 4:ChooseString, CbbUpdateInterval, %CbbUpdateInterval%
  832. GoSub, ChkExportAutoNumber
  833. GoSub, ChkExportAppend
  834. GuiControl, 4:Choose, Tab2, %ChangeToTab%
  835. Gui, 4:Show,, Options - %ScriptName%
  836. Return
  837. RadUpdate:
  838. If (A_GuiControl = "RadUpdateOnClick"){
  839. GuiControl, 4:, RadUpdateAuto, 0
  840. GuiControl, 4:, ChkChangePauseHotkey, 0
  841. GuiControl, 4:Disable, ChkChangePauseHotkey
  842. GuiControl, 4:Disable, HtkPauseAction
  843. GuiControl, 4:, ChkHideGui, 0
  844. GuiControl, 4:Disable, ChkHideGui
  845. GuiControl, 4:, ChkAutoStartUpdate, 0
  846. GuiControl, 4:Disable, ChkAutoStartUpdate
  847. }Else{
  848. GuiControl, 4:, RadUpdateOnClick, 0
  849. GuiControl, 4:Enable, ChkChangePauseHotkey
  850. GuiControl, 4:Enable, ChkHideGui
  851. GuiControl, 4:Enable, ChkAutoStartUpdate
  852. GuiControl, 4:, ChkAutoStartUpdate, 1
  853. }
  854. Return
  855. ApplyOptions:
  856. Gui, 4:Submit
  857. If ChkCopyToCB
  858. OnMessage( WM_LBUTTONDOWN, "WM_LBUTTONDOWN" ) ;activate copy-on-click
  859. Else
  860. OnMessage( WM_LBUTTONDOWN, "" ) ;deactivate copy-on-click
  861. If ChkAutoStartUpdate
  862. OnMessage(WM_ACTIVATE, "WM_ACTIVATE") ;activate auto-start updating at Gui inactivity
  863. Else
  864. OnMessage(WM_ACTIVATE, "" ) ;deactivate auto-start updating
  865. If RadUpdateAuto {
  866. SetTimer, UpdateInfo, %CbbUpdateInterval%
  867. }Else{
  868. SetTimer, UpdateInfo, Off
  869. Hotkey, IfWinNotActive, ahk_id %Gui1UniqueID%
  870. Hotkey, ~%CbbHtkUpdate%, UpdateOnClick, On
  871. Hotkey, IfWinNotActive
  872. }
  873. GoSub, PauseAction
  874. 4GuiClose:
  875. 4GuiEscape:
  876. UpdateIsStopped := False
  877. Gui, 1:-Disabled
  878. Gui, 4:Destroy
  879. Return
  880. ChkChangePauseHotkey:
  881. GuiControlGet, ChkChangePauseHotkey, 4: ;get current value
  882. If ChkChangePauseHotkey {
  883. ;de-activate current auto-update toggle hotkey
  884. HotKey, %HtkPauseAction%, Off
  885. GuiControl, 4:Enable, HtkPauseAction
  886. }Else
  887. GoSub, HtkPauseAction
  888. Return
  889. HtkPauseAction:
  890. GuiControlGet, HtkPauseAction, 4: ;get current value
  891. If HtkPauseAction {
  892. If HtkPauseAction in ^,+,! ;don't react on simple modifiers
  893. return
  894. ;activate new auto-update toggle hotkey
  895. HotKey, %HtkPauseAction%, PauseAction, On
  896. GuiControl, 4:Disable, HtkPauseAction
  897. GuiControl, 4:, ChkChangePauseHotkey, 0
  898. }Else{
  899. GuiControl, 4:, ChkChangePauseHotkey, 1
  900. GuiControl, 4:Enable, HtkPauseAction
  901. ToolTip("You need to specify a hotkey", 2000)
  902. }
  903. Return
  904. BtnExportCheckAll:
  905. Loop, Parse, ExportOptions, `,
  906. GuiControl, 4:, %A_LoopField%, 1
  907. Return
  908. BtnExportCheckNone:
  909. Loop, Parse, ExportOptions, `,
  910. GuiControl, 4:, %A_LoopField%, 0
  911. Return
  912. BtnExportCheckReverse:
  913. Gui, 1:Submit, NoHide
  914. Loop, Parse, ExportOptions, `,
  915. GuiControl, 4:, %A_LoopField%, % not %A_LoopField%
  916. Return
  917. ChkExportAutoNumber:
  918. Gui, 4:Submit, NoHide
  919. If ChkExportAutoNumber
  920. GuiControl, 4:Disable, ChkExportAppend
  921. Else
  922. GuiControl, 4:Enable, ChkExportAppend
  923. Return
  924. ChkExportAppend:
  925. Gui, 4:Submit, NoHide
  926. If ChkExportAppend
  927. GuiControl, 4:Disable, ChkExportAutoNumber
  928. Else
  929. GuiControl, 4:Enable, ChkExportAutoNumber
  930. Return
  931. ;###############################################################################
  932. ;### getting the data #####################################################
  933. ;###############################################################################
  934. UpdateInfo:
  935. If UpdateIsStopped
  936. Return
  937. If (WinActive("A") = Gui1UniqueID ) ;don't update when window becomes the active one
  938. Return
  939. If (Tab1 > 3 ) ;don't update when tab 4 or tab 5 are visible
  940. Return
  941. SetBatchLines, -1
  942. ;get mouse pos and make sure mouse is not on frames or tooltips or on it's own gui
  943. MouseIsOnFrameGUI := False
  944. GoSub, CheckForFramesAndTipsAndGetMousePos
  945. If MouseIsOnFrameGUI
  946. Return
  947. GoSub, SetWhichWindow
  948. GoSub, SetWhichControl
  949. If (ChkHideGui And ChkTtpMaster And !GuiIsVisible) ;update only small info when gui is hidden if tool tips are wanted
  950. GoSub, UpdateMinimumInfo
  951. Else If (!ChkHideGui Or UpdateAfterPause) ;update only when gui not set to HideGui or if Pause is release and one update is needed
  952. GoSub, UpdateAllInfo
  953. ;draw frames if wanted
  954. If ( ( ChkDrawRectCtrl OR ChkDrawRectWin ) ;user wants to see at least one of the frames
  955. AND PreviousControlID <> ControlID ;the control has changed
  956. AND StatusDrawFrame ){ ;AND the Mouse is not on the active window which should be drawn
  957. If not FrameGUIExists ;create frame gui if it had been destroyed, e.g. by viewing the large list
  958. GoSub, PrepareFrameDraw
  959. DrawFrameAroundControl(ControlID, WindowUniqueID, frame_t)
  960. }
  961. ;memorize IDs
  962. PreviousControlID = %ControlID%
  963. PreviousWindowID = %WindowID%
  964. If UpdateIsStopped { ;when update stopped within this run, behave as if toggle hotkey was pressed
  965. GoSub, ToogleExportActions
  966. GoSub, PrepareFrameDraw ;create or destroy frame drawing objects
  967. GoSub, GuiShow
  968. }
  969. Return
  970. ;check if frames or tool tips are under mouse pointer
  971. CheckForFramesAndTipsAndGetMousePos:
  972. ;get mouse positions relative to screen
  973. CoordMode, Mouse, Screen
  974. MouseGetPos, MouseScreenX, MouseScreenY, MouseWindowUID, MouseControlID
  975. WinGetClass, WindowClass, ahk_id %MouseWindowUID%
  976. WinGetTitle, WindowTitle, ahk_id %MouseWindowUID%
  977. If ( MouseWindowUID = UniqueIDGui2 ;if window is frame gui
  978. OR MouseWindowUID = Gui1UniqueID ;or real gui
  979. OR (WindowClass = "tooltips_class32" ;or window is tooltip
  980. AND ( WindowTitle = PreviousControlID ;and has the title of the last control
  981. OR WindowTitle = PreviousWindowID ;or has the title of the last window
  982. OR InStr(WindowTitle,Scriptname)) ) ) ;{ ;or has a title that contains the script name, then it might be one of the info tooltips
  983. MouseIsOnFrameGUI := True
  984. If (MouseIsOnFrameGUI AND WindowTitle = PreviousControlID) ;remove control frame tooltip if mouse is on it, to be able to see screen below
  985. ToolTip, , , , 2
  986. Return
  987. ;set UID of window for which the following data should be retrieved
  988. SetWhichWindow:
  989. StatusDrawFrame := True
  990. If (RadWindow = 1){ ;for active window
  991. WinGet, WindowUniqueID, ID, A
  992. If (WindowUniqueID <> MouseWindowUID) ;mouse is not in active window, don't redraw frames
  993. StatusDrawFrame := False
  994. }Else ;for window under mouse pointer
  995. WindowUniqueID = %MouseWindowUID%
  996. Return
  997. ;set control ID for which the data should be retrieved
  998. SetWhichControl:
  999. If (RadControl = 1) ;for active control
  1000. ControlGetFocus, ControlID, ahk_id %WindowUniqueID%
  1001. Else ;for control under mouse pointer
  1002. ControlID = %MouseControlID%
  1003. Return
  1004. UpdateMinimumInfo:
  1005. ;optional tooltip
  1006. If ChkTtpMaster {
  1007. InfoString := iif(ChkTtpMSPos,"MScreen: " MouseScreenX "," MouseScreenY "`n")
  1008. . iif(ChkTtpCClass,"Control ClassNN: " MouseControlID "`n")
  1009. . iif(ChkTtpWClass,"Window Class: " WindowClass "`n")
  1010. . iif(ChkTtpWTitle,"Window Title: " WindowTitle "`n")
  1011. StringTrimRight, InfoString, InfoString, 1 ;remove last `n
  1012. If InfoString
  1013. ToolTip(Scriptname "`n----------------------------`n" InfoString)
  1014. }
  1015. Return
  1016. UpdateAllInfo:
  1017. ;ToolTip, UpdateAllInfo - %A_Now% ;??? for debug
  1018. GoSub, GetMouseInfo
  1019. GoSub, GetControlInfo
  1020. ;optional tooltip
  1021. If ChkTtpMaster {
  1022. InfoString := iif(ChkTtpMSPos,"MScreen: " MouseScreenX "," MouseScreenY "`n")
  1023. . iif(ChkTtpMWPos,"MWindow: " MouseWindowX "," MouseWindowY "`n")
  1024. . iif(ChkTtpMColor,"MColor: " MouseColorRGB "`n")
  1025. . iif(ChkTtpCClass,"Control ClassNN: " MouseControlID "`n")
  1026. . iif(ChkTtpCPos,"Control Pos: " ControlX "," ControlY "`n")
  1027. . iif(ChkTtpCSize,"Control Size: " ControlWidth "," ControlHeight "`n")
  1028. . iif(ChkTtpWClass,"Window Class: " WindowClass "`n")
  1029. . iif(ChkTtpWTitle,"Window Title: " WindowTitle "`n")
  1030. StringTrimRight, InfoString, InfoString, 1 ;remove last `n
  1031. If InfoString
  1032. ToolTip(Scriptname "`n----------------------------`n" InfoString)
  1033. }
  1034. GoSub, GetWindowInfo
  1035. If (Tab1 = 2) ;get window text only when advanced tab is active
  1036. GoSub, GetWindowText
  1037. If ChkShowList { ;if large list is shown
  1038. If RadList1 = 1 ;get data depending on choice
  1039. GoSub, GetControlListInfo
  1040. Else
  1041. GoSub, GetAllWindowsInfo
  1042. UpdateIsStopped := True ;give feedback and stop updating
  1043. If ChkShowInfoToolTip
  1044. ToolTip("Stopped to update data to allow working with "
  1045. . iif(SelectedRadList = 1,"list of controls")
  1046. . iif(SelectedRadList = 2,"list of windows")
  1047. . "`nPress Pause key to create a new snapshot", 2000)
  1048. }
  1049. Return
  1050. GetMouseInfo:
  1051. ;get mouse pos relative to windows
  1052. WinGetPos, WindowActiveX, WindowActiveY,,, A
  1053. WinGetPos, WindowX, WindowY,,, ahk_id %MouseWindowUID%
  1054. MouseWindowActiveX := MouseScreenX - WindowActiveX
  1055. MouseWindowActiveY := MouseScreenY - WindowActiveY
  1056. MouseWindowX := MouseScreenX - WindowX
  1057. MouseWindowY := MouseScreenY - WindowY
  1058. GuiControl, 1:, EdtMousePosScreen, x%MouseScreenX% y%MouseScreenY%
  1059. GuiControl, 1:, EdtMousePosWin, x%MouseWindowX% y%MouseWindowY%
  1060. GuiControl, 1:, EdtEasyMousePosWin, x%MouseWindowX% y%MouseWindowY%
  1061. GuiControl, 1:, EdtDataMousePosWin, x%MouseWindowX% y%MouseWindowY%
  1062. GuiControl, 1:, EdtMousePosAWin, x%MouseWindowActiveX% y%MouseWindowActiveY%
  1063. ;get pointer shape
  1064. GuiControl, 1:, EdtMousePointer, %A_Cursor%
  1065. ;get color below mouse pointer
  1066. CoordMode, Pixel, Screen
  1067. PixelGetColor, MouseColorRGB, %MouseScreenX%, %MouseScreenY%, RGB
  1068. StringMid, MouseColorR, MouseColorRGB, 3, 2
  1069. StringMid, MouseColorG, MouseColorRGB, 5, 2
  1070. StringMid, MouseColorB, MouseColorRGB, 7, 2
  1071. GuiControl, 1:, EdtMouseColorRGB, % "R" HEXtoDEC(MouseColorR) " G" HEXtoDEC(MouseColorG)" B" HEXtoDEC(MouseColorB)
  1072. GuiControl, 1:, EdtMouseColorHex, %MouseColorRGB%
  1073. If (Tab1 = 3) { ;Only update color picker when mouse tab is active
  1074. If ( MouseScreenX MouseScreenY <> OldPosition or MouseColorRGB <> OldMouseColorRGB){ ;only update color picker when mouse moves or color changes
  1075. x := MouseScreenX - HalfDim
  1076. Loop, %Dim% {
  1077. x++
  1078. Row := A_Index + 8 - HalfDim
  1079. y := MouseScreenY - HalfDim
  1080. Loop, %Dim% {
  1081. y++
  1082. PixelGetColor, ColorRGB, %x%, %y%, % iif(RadColorPick = 1, "RGB")
  1083. StringTrimLeft, ColorRGB, ColorRGB, 2
  1084. Control := "PgbColorPicker" (A_Index + 8 - HalfDim) "_" Row
  1085. %Control% = %ColorRGB%
  1086. If RadColorPick = 2
  1087. PixelGetColor, ColorRGB, %x%, %y%, RGB
  1088. GuiControl, 1:+Background%ColorRGB%,%Control%
  1089. }
  1090. }
  1091. }
  1092. OldPosition = %MouseScreenX%%MouseScreenY%
  1093. OldMouseColorRGB = %MouseColorRGB%
  1094. }
  1095. Return
  1096. GetControlInfo:
  1097. GuiControl, 1:, EdtControlClass, %ControlID%
  1098. GuiControl, 1:, EdtEasyControlClass, %ControlID%
  1099. ;get Pos, Size, Text
  1100. ControlGetPos, ControlX, ControlY, ControlWidth, ControlHeight, %ControlID%, ahk_id %WindowUniqueID%
  1101. GuiControl, 1:, EdtControlPos, x%ControlX% y%ControlY%
  1102. GuiControl, 1:, EdtControlSize, w%ControlWidth% h%ControlHeight%
  1103. ControlGet, ControlHwnd, Hwnd,, %ControlID%, ahk_id %WindowUniqueID%
  1104. GuiControl, 1:, EdtControlHwnd, %ControlHwnd%
  1105. ;Chris suggests to avoid any call to ControlGetText or WinGetText because they force the OS to copy an
  1106. ; unlimited amount of text across process boundaries. This text could be several megabytes or more if
  1107. ; someone has a big text file or Word document open. Instead use WM_GETTEXT.
  1108. ; ControlGetText, ControlText, %ControlID%, ahk_id %WindowUniqueID%
  1109. MouseGetPos,,,,ControlHWND, 2
  1110. SendMessage, 0xD, ControlTextSize, &ControlText,, ahk_id %ControlHWND% ; 0xD is WM_GETTEXT.
  1111. EdtControlTextFull := ShowOnlyAPartInGui("EdtControlText", ControlText, 100)
  1112. EdtEasyControlTextFull := ShowOnlyAPartInGui("EdtEasyControlText", ControlText, 100)
  1113. If (Tab1 = 2) { ;get control list data only when advanced tab is active
  1114. ControlGet, ControlListItems, List, , %ControlID%, ahk_id %WindowUniqueID%
  1115. EdtListItemsFull := ShowOnlyAPartInGui("EdtListItems", ControlListItems, 200)
  1116. }
  1117. Return
  1118. GetWindowInfo:
  1119. ;get Title, Pos, Size, PID, Process, Class
  1120. WinGetTitle, WindowTitle, ahk_id %WindowUniqueID%
  1121. WinGetPos, WindowX, WindowY, WindowWidth, WindowHeight, ahk_id %WindowUniqueID%
  1122. WinGet, WindowPID, PID, ahk_id %WindowUniqueID%
  1123. WinGet, WindowProcessName, ProcessName, ahk_pid %WindowPID%
  1124. WinGetClass, WindowClass, ahk_id %WindowUniqueID%
  1125. GuiControl, 1:, EdtWindowTitle, %WindowTitle%
  1126. GuiControl, 1:, EdtEasyWindowTitle, %WindowTitle%
  1127. GuiControl, 1:, EdtWindowPos, x%WindowX% y%WindowY%
  1128. GuiControl, 1:, EdtWindowSize, w%WindowWidth% h%WindowHeight%
  1129. GuiControl, 1:, EdtWindowClass, %WindowClass%
  1130. GuiControl, 1:, EdtEasyWindowClass, %WindowClass%
  1131. GuiControl, 1:, EdtWindowProcess, %WindowProcessName%
  1132. GuiControl, 1:, EdtWindowUID, %WindowUniqueID%
  1133. GuiControl, 1:, EdtWindowPID, %WindowPID%
  1134. If (Tab1 = 2) { ;get advanced window data only when advanced tab is active
  1135. ;get and set statusbartext (maximum 10)
  1136. ListOfStatusbarText =
  1137. Loop, 10 {
  1138. StatusBarGetText, StatusBarText, %A_Index%, ahk_id %WindowUniqueID%
  1139. If StatusBarText
  1140. ListOfStatusbarText = %ListOfStatusbarText%%A_Index% - %StatusBarText%|
  1141. }
  1142. If ListOfStatusbarText is space
  1143. ListOfStatusbarText = No text found in statusbar
  1144. GuiControl, 1:, LsbStatusbarText, |%ListOfStatusbarText%
  1145. }
  1146. Return
  1147. GetWindowText:
  1148. EdtWindowTextFastVisible =
  1149. EdtWindowTextSlowVisible =
  1150. EdtWindowTextFastHidden =
  1151. EdtWindowTextSlowHidden =
  1152. ;Suggested by Chris
  1153. WinGet, ListOfControlHandles, ControlListHwnd, ahk_id %WindowUniqueID% ; Requires v1.0.43.06+.
  1154. Loop, Parse, ListOfControlHandles, `n
  1155. {
  1156. text_is_fast := true
  1157. If not DllCall("GetWindowText", "uint", A_LoopField, "str", WindowControlText, "int", WindowControlTextSize){
  1158. text_is_fast := false
  1159. SendMessage, 0xD, WindowControlTextSize, &WindowControlText,, ahk_id %A_LoopField% ; 0xD is WM_GETTEXT
  1160. }
  1161. If (WindowControlText <> ""){
  1162. ControlGet, WindowControlStyle, Style,,, ahk_id %A_LoopField%
  1163. If (WindowControlStyle & 0x10000000){ ; Control is visible vs. hidden (WS_VISIBLE).
  1164. If text_is_fast
  1165. EdtWindowTextFastVisible = %EdtWindowTextFastVisible%%WindowControlText%`r`n
  1166. Else
  1167. EdtWindowTextSlowVisible = %EdtWindowTextSlowVisible%%WindowControlText%`r`n
  1168. }Else{ ; Hidden text.
  1169. If text_is_fast
  1170. EdtWindowTextFastHidden = %EdtWindowTextFastHidden%%WindowControlText%`r`n
  1171. Else
  1172. EdtWindowTextSlowHidden = %EdtWindowTextSlowHidden%%WindowControlText%`r`n
  1173. }
  1174. }
  1175. }
  1176. EdtWindowTextFastVisibleFull := ShowOnlyAPartInGui("EdtWindowTextFastVisible", EdtWindowTextFastVisible, 400)
  1177. EdtWindowTextSlowVisibleFull := ShowOnlyAPartInGui("EdtWindowTextSlowVisible", EdtWindowTextSlowVisible, 400)
  1178. EdtWindowTextFastHiddenFull := ShowOnlyAPartInGui("EdtWindowTextFastHidden", EdtWindowTextFastHidden, 400)
  1179. EdtWindowTextSlowHiddenFull := ShowOnlyAPartInGui("EdtWindowTextSlowHidden", EdtWindowTextSlowHidden, 400)
  1180. Return
  1181. ShowOnlyAPartInGui(Control, FullContent, Limit=200){
  1182. Content = %FullContent%
  1183. If (StrLen(Content) > Limit){ ;limits the control text in the GUI. An unlimited length caused on some PCs 100% CPU load
  1184. StringLeft, Content, Content, %Limit%
  1185. Content = %Content% ...
  1186. }
  1187. GuiControl, 1:, %Control%, %Content%
  1188. Return FullContent
  1189. }
  1190. GetControlListInfo:
  1191. ;get list of controls in z order
  1192. WinGet, ControlList, ControlList, ahk_id %WindowUniqueID%
  1193. ;get all data for these controls
  1194. Loop, Parse, ControlList, `n
  1195. {
  1196. ControlID0 = %A_Index%
  1197. ControlID = %A_LoopField%
  1198. ControlID%A_Index% = %ControlID%
  1199. ControlGetPos, ControlX%A_Index%, ControlY%A_Index%, ControlWidth%A_Index%, ControlHeight%A_Index%, %ControlID%, ahk_id %WindowUniqueID%
  1200. ControlGet, ControlHwnd%A_Index%, Hwnd,, %ControlID%, ahk_id %WindowUniqueID%
  1201. ControlGetText, ControlText%A_Index%, %ControlID%, ahk_id %WindowUniqueID%
  1202. ControlGet, ControlChecked%A_Index%, Checked, , %ControlID%, ahk_id %WindowUniqueID%
  1203. ControlGet, ControlEnabled%A_Index%, Enabled, , %ControlID%, ahk_id %WindowUniqueID%
  1204. ControlGet, ControlVisible%A_Index%, Visible, , %ControlID%, ahk_id %WindowUniqueID%
  1205. ControlGet, ControlTab%A_Index%, Tab, , %ControlID%, ahk_id %WindowUniqueID%
  1206. ControlGet, ControlChoice%A_Index%, Choice, , %ControlID%, ahk_id %WindowUniqueID%
  1207. ControlGet, ControlLineCount%A_Index%, LineCount, , %ControlID%, ahk_id %WindowUniqueID%
  1208. ControlGet, ControlCurrentLine%A_Index%, CurrentLine, , %ControlID%, ahk_id %WindowUniqueID%
  1209. ControlGet, ControlCurrentCol%A_Index%, CurrentCol, , %ControlID%, ahk_id %WindowUniqueID%
  1210. ControlGet, ControlSelected%A_Index%, Selected, , %ControlID%, ahk_id %WindowUniqueID%
  1211. ControlGet, ControlStyle%A_Index%, Style, , %ControlID%, ahk_id %WindowUniqueID%
  1212. ControlGet, ControlExStyle%A_Index%, ExStyle, , %ControlID%, ahk_id %WindowUniqueID%
  1213. }
  1214. ;add all data to listview
  1215. GuiControl, -Redraw, LV1 ; speed up adding data
  1216. LV_Delete() ; remove old data
  1217. Loop, %ControlID0% {
  1218. LV_Add(""
  1219. , A_Index ; Z or Stack Order
  1220. , ControlHwnd%A_Index% ; Unique ID
  1221. , "" ; Window PID
  1222. , ControlID%A_Index% ; Window Class
  1223. , "" ; Window Process Name
  1224. , ControlVisible%A_Index% ; Visible or Hidden?
  1225. , ControlText%A_Index% ; Title or Text
  1226. , ControlX%A_Index% ; X
  1227. , ControlY%A_Index% ; Y
  1228. , ControlWidth%A_Index% ; Width
  1229. , ControlHeight%A_Index% ; Height
  1230. , ControlStyle%A_Index% ; Style
  1231. , ControlExStyle%A_Index% ; ExStyle
  1232. , ControlSelected%A_Index% ; Selected
  1233. , ControlCurrentCol%A_Index% ; CurrentCol
  1234. , ControlCurrentLine%A_Index% ; CurrentLine
  1235. , ControlLineCount%A_Index% ; LineCount
  1236. , ControlChoice%A_Index% ; Choice
  1237. , ControlTab%A_Index% ; Tab
  1238. , ControlEnabled%A_Index% ; Enabled
  1239. , ControlChecked%A_Index%) ; Checked
  1240. }
  1241. LV_ModifyCol() ; Auto-size all columns
  1242. LV_ModifyCol(1, "Integer Left") ; column Z Order
  1243. LV_ModifyCol(3, 0) ; hide column Window PID
  1244. LV_ModifyCol(5, 0) ; hide column Window Process Name
  1245. LV_ModifyCol(7, "150") ; column Text
  1246. GuiControl, +Redraw, LV1
  1247. Return
  1248. GetAllWindowsInfo:
  1249. ;get list of all visible windows in stack order
  1250. DetectHiddenWindows, Off
  1251. WinGet, WinIDs, List
  1252. Loop, %WinIDs%
  1253. winListIDsVisible := winListIDsVisible WinIDs%A_Index% "`n"
  1254. ;get list of all windows in stack order
  1255. DetectHiddenWindows, On
  1256. WinGet, WinIDs, List
  1257. ;get all data for all windows
  1258. Loop, %WinIDs% {
  1259. UniqueID := "ahk_id " WinIDs%A_Index%
  1260. WinGetPos, WindowX%A_Index%, WindowY%A_Index%, WindowWidth%A_Index%, WindowHeight%A_Index%, %UniqueID%
  1261. WinGet, winPID%A_Index%, PID, %UniqueID%
  1262. WinGet, processName%A_Index%, ProcessName, % "ahk_pid " winPID%A_Index%
  1263. WinGetTitle, winTitle%A_Index%, %UniqueID%
  1264. WinGetClass, winClass%A_Index%, %UniqueID%
  1265. }
  1266. DetectHiddenWindows, off
  1267. ;add all data to listview
  1268. GuiControl, -Redraw, LV1 ; speed up adding data
  1269. LV_Delete() ; remove old data
  1270. Loop, %WinIDs% {
  1271. LV_Add(""
  1272. , A_Index ; Z or Stack Order
  1273. , WinIDs%A_Index% ; Unique ID
  1274. , winPID%A_Index% ; Window PID
  1275. , winClass%A_Index% ; Window Class
  1276. , processName%A_Index% ; Process Name
  1277. , iif(InStr(winListIDsVisible,WinIDs%A_Index%),"","Hidden") ; Visible or Hidden?
  1278. , winTitle%A_Index% ; Title or Text
  1279. , WindowX%A_Index% ; X
  1280. , WindowY%A_Index% ; Y
  1281. , WindowWidth%A_Index% ; Width
  1282. , WindowHeight%A_Index%) ; Height
  1283. }
  1284. LV_ModifyCol() ; Auto-size all columns
  1285. LV_ModifyCol(1, "Integer Left") ; column Stack Order
  1286. LV_ModifyCol(4, "100") ; column Class
  1287. LV_ModifyCol(7, "150") ; column Title
  1288. GuiControl, +Redraw, LV1
  1289. Return
  1290. ;draw frames around controls and/or windows
  1291. DrawFrameAroundControl(ControlID, WindowUniqueID, frame_t){
  1292. global h_brushC, h_brushW, ChkDrawRectCtrl, ChkDrawRectWin
  1293. ;get coordinates of Window and control again
  1294. ;(could have been past into the function but it seemed too much parameters)
  1295. WinGetPos, WindowX, WindowY, WindowWidth, WindowHeight, ahk_id %WindowUniqueID%
  1296. ControlGetPos, ControlX, ControlY, ControlWidth, ControlHeight, %ControlID%, ahk_id %WindowUniqueID%
  1297. ;find upper left corner relative to screen
  1298. StartX := WindowX + ControlX
  1299. StartY := WindowY + ControlY
  1300. ;show ID in upper left corner
  1301. CoordMode, ToolTip, Screen
  1302. ;show frame gui above AOT apps
  1303. Gui, 2: +AlwaysOnTop
  1304. If ChkDrawRectWin {
  1305. ;if windows upper left corner is outside the screen
  1306. ; it is assumed that the window is maximized and the frame is made smaller
  1307. If ( WindowX < 0 AND WindowY < 0 ){
  1308. WindowX += 4
  1309. WindowY += 4
  1310. WindowWidth -= 8
  1311. WindowHeight -= 8
  1312. }
  1313. ;remove old rectangle from screen and save/buffer screen below new rectangle
  1314. BufferAndRestoreRegion( WindowX, WindowY, WindowWidth, WindowHeight )
  1315. ;draw rectangle frame around window
  1316. DrawFrame( WindowX, WindowY, WindowWidth, WindowHeight, frame_t, h_brushW )
  1317. ;show tooltip above window frame when enough space
  1318. If ( WindowY > 22)
  1319. WindowY -= 22
  1320. ;Show tooltip with windows unique ID
  1321. ToolTip, %WindowUniqueID%, WindowX, WindowY, 3
  1322. }
  1323. Else
  1324. ;remove old rectangle from screen and save/buffer screen below new rectangle
  1325. BufferAndRestoreRegion( StartX, StartY, ControlWidth, ControlHeight )
  1326. If ChkDrawRectCtrl {
  1327. ;draw rectangle frame around control
  1328. DrawFrame( StartX, StartY, ControlWidth, ControlHeight, frame_t, h_brushC )
  1329. ;show tooltip above control frame when enough space, or below
  1330. If ( StartY > 22)
  1331. StartY -= 22
  1332. Else
  1333. StartY += ControlHeight
  1334. ;show control tooltip left of window tooltip if position identical (e.g. Windows Start Button on Taskbar)
  1335. If (StartY = WindowY
  1336. AND StartX < WindowX + 50)
  1337. StartX += 50
  1338. ;Show tooltip with controls unique ID
  1339. ToolTip, %ControlID%, StartX, StartY, 2
  1340. }
  1341. ;set back ToolTip position to default
  1342. CoordMode, ToolTip, Relative
  1343. }
  1344. ;###############################################################################
  1345. ;### export the data ######################################################
  1346. ;###############################################################################
  1347. BtnBrowseExportFile:
  1348. Gui, 1:Submit, NoHide
  1349. SelectFile("EdtExportFile", EdtExportFile, "email")
  1350. Return
  1351. BtnSaveExport:
  1352. Gui, 1:Submit, NoHide
  1353. ;return if no filename is given
  1354. If EdtExportFile is space
  1355. {
  1356. ToolTip("No filename for export specified.", 3000)
  1357. MsgBox, 48, Problem , No export filename is given.
  1358. Return
  1359. }
  1360. ;return if no data is selected for export
  1361. NumberOfExports = 0
  1362. Loop, Parse, ExportOptions, `,
  1363. NumberOfExports := NumberOfExports + %A_LoopField%
  1364. If (NumberOfExports = 0){
  1365. ToolTip("No data selected for export.", 3000)
  1366. Return
  1367. }
  1368. ;get filename
  1369. If (ChkExportAutoNumber){
  1370. FileNameForExport := GetAvailableFileName(EdtExportFile)
  1371. If not FileNameForExport {
  1372. ToolTip("Could get filename for export.`n" ErrorLevel, 3000)
  1373. Return
  1374. }
  1375. }Else
  1376. FileNameForExport = %EdtExportFile%
  1377. GuiControl, 1:Disable, BtnSaveExport
  1378. GoSub, ExportDataToFile
  1379. GuiControl, 1:Enable, BtnSaveExport
  1380. If ChkShowInfoToolTip
  1381. ToolTip("Data exported to file: " FileNameForExport, 3000)
  1382. Return
  1383. ExportDataToFile:
  1384. If ChkExportAppend
  1385. FileAppend, `n===========next snapshot===========`n, %FileNameForExport%
  1386. Else
  1387. FileDelete, %FileNameForExport%
  1388. ExportString := "Data exported from " ScriptName " at " A_Now "`n`nMouse Data`n"
  1389. . iif(ChkExportMousePosScreen,"Mouse position relative to Screen :`n" EdtMousePosScreen "`n`n")
  1390. . iif(ChkExportMousePosWin,"Mouse position relative to window under mouse pointer :`n" EdtMousePosWin "`n`n")
  1391. . iif(ChkExportMousePosAWin,"Mouse position relative to active window :`n" EdtMousePosAWin "`n`n")
  1392. . iif(ChkExportMousePointer,"Mouse cursor style :`n" EdtMousepointer "`n`n")
  1393. . iif(ChkExportMouseColorRGB,"Pixel Color in RGB format under mouse pointer :`n" EdtMouseColorRGB "`n`n")
  1394. . iif(ChkExportMouseColorHex,"Pixel Color in Hex format (RGB) mouse pointer :`n" EdtMouseColorHex "`n`n")
  1395. . "`nControl data for "
  1396. . iif(RadControl = 1,"active control of " iif(RadWindow = 1,"active window","window under mouse pointer") ,"control under mouse pointer")
  1397. . "`n"
  1398. . iif(ChkExportCtrlText,"Control text :`n" EdtControlText "`n`n")
  1399. . iif(ChkExportCtrlClass,"Control classNN :`n" EdtControlClass "`n`n")
  1400. . iif(ChkExportCtrlPos,"Control position :`n" EdtControlPos "`n`n")
  1401. . iif(ChkExportCtrlSize,"Control size :`n" EdtControlSize "`n`n")
  1402. . iif(ChkExportCtrlListItems,"Control list items :`n" EdtListItems "`n`n")
  1403. . "`nWindow data for "
  1404. . iif(RadWindow = 1,"active window","window under mouse pointer")
  1405. . "`n"
  1406. . iif(ChkExportWinTitle,"Window title :`n" EdtWindowTitle "`n`n")
  1407. . iif(ChkExportWinPos,"Window position :`n" EdtWindowPos "`n`n")
  1408. . iif(ChkExportWinSize,"Window size :`n" EdtWindowSize "`n`n")
  1409. . iif(ChkExportWinClass,"Window class :`n" EdtWindowClass "`n`n")
  1410. . iif(ChkExportWinProcess,"Window process name:`n" EdtWindowprocess "`n`n")
  1411. . iif(ChkExportWinUID,"Window unique ID :`n" EdtWindowUID "`n`n")
  1412. . iif(ChkExportWinPID,"Window PID :`n" EdtWindowPID "`n`n")
  1413. FileAppend, %ExportString%, %FileNameForExport%
  1414. ExportString =
  1415. If ChkExportWinStatusText {
  1416. StringReplace, StatusbarText, ListOfStatusbarText, |, `n, All
  1417. ExportString = `n######## Window Statusbar Text (Part# - Text) :`n%StatusbarText%`n`n
  1418. }
  1419. If ChkExportWinText
  1420. ExportString := ExportString
  1421. . iif(EdtWindowTextFastVisible,"`n######## Fast Visible Window Text :`n" EdtWindowTextFastVisible "`n`n")
  1422. . iif(EdtWindowTextSlowVisible,"`n######## Slow Visible Window Text :`n" EdtWindowTextSlowVisible "`n`n")
  1423. . iif(EdtWindowTextFastHidden,"`n######## Fast Hidden Window Text :`n" EdtWindowTextFastHidden "`n`n")
  1424. . iif(EdtWindowTextSlowHidden,"`n######## Slow Hidden Window Text :`n" EdtWindowTextSlowHidden "`n`n")
  1425. FileAppend, %ExportString%, %FileNameForExport%
  1426. If ChkExportLargeList {
  1427. If LV_GetCount() {
  1428. ExportString := "`n########"
  1429. . iif(RadList3,"Data of all controls of the " iif(RadWindow = 1,"active window","window under the mousepointer") ,"Data of all windows")
  1430. ExportString = %ExportString% :`n
  1431. (LTrim Join`s
  1432. ######## Z or Stack Order, Unique ID, Window PID, Window Class,
  1433. Process Name, Hidden, Title or Text, X, Y, Width, Height, Style,
  1434. ExStyle, Selected, CurrentCol, CurrentLine, LineCount, Choice,
  1435. Tab, Enabled, Checked
  1436. )
  1437. Columns := LV_GetCount("Col")
  1438. Loop, % LV_GetCount() {
  1439. Row = %A_Index%
  1440. Loop %Columns% {
  1441. LV_GetText(Text, Row , A_Index)
  1442. ExportString = %ExportString%%Text%,
  1443. }
  1444. StringTrimRight,ExportString,ExportString,1 ;remove last comma
  1445. ExportString = %ExportString%`n ;start new line
  1446. }
  1447. }
  1448. If ExportString
  1449. FileAppend, %ExportString%, %FileNameForExport%
  1450. }
  1451. Return
  1452. ;###############################################################################
  1453. ;### small helper functions ################################################
  1454. ;###############################################################################
  1455. iif(expr, a, b=""){
  1456. If expr
  1457. Return a
  1458. Return b
  1459. }
  1460. ToggleOnTopGui1(wParam, lParam, msg, hwnd) {
  1461. Global Gui1UniqueID, Gui1AOTState
  1462. WinGetTitle, CurrentTitle , ahk_id %Gui1UniqueID%
  1463. If (Gui1AOTState){
  1464. Gui, 1: -AlwaysOnTop
  1465. StringTrimRight, CurrentTitle, CurrentTitle, 8
  1466. WinSetTitle, ahk_id %Gui1UniqueID%, , %CurrentTitle%
  1467. }Else {
  1468. Gui, 1: +AlwaysOnTop
  1469. WinSetTitle, ahk_id %Gui1UniqueID%, , %CurrentTitle% - *AOT*
  1470. }
  1471. Gui1AOTState := not Gui1AOTState
  1472. }
  1473. ToolTip(Text, TimeOut=1000){
  1474. ToolTip, %Text%
  1475. SetTimer, RemoveToolTip, %TimeOut%
  1476. Return
  1477. }
  1478. RemoveToolTip:
  1479. ToolTip
  1480. Return
  1481. HEXtoDEC(HEX){
  1482. StringUpper, HEX, HEX
  1483. Loop, % StrLen(HEX) {
  1484. StringMid, Col, HEX, % (StrLen(HEX) + 1) - A_Index, 1
  1485. If Col is integer
  1486. DEC1 := Col * 16 ** (A_Index - 1)
  1487. Else
  1488. DEC1 := (Asc(Col) - 55) * 16 ** (A_Index - 1)
  1489. DEC += %DEC1%
  1490. }
  1491. return DEC
  1492. }
  1493. SelectFile(Control, OldFile, Text){
  1494. Gui, 1:+OwnDialogs
  1495. StringReplace, OutputVar, OldFile, #, *, All
  1496. IfExist %A_ScriptDir%\%OutputVar%
  1497. StartFolder = %A_ScriptDir%
  1498. Else IfExist %OldFile%
  1499. SplitPath, OldFile, , StartFolder
  1500. Else
  1501. StartFolder =
  1502. FileSelectFile, SelectedFile, S18, %StartFolder%, Select file for %Text%, Text file (*.txt)
  1503. If SelectedFile {
  1504. StringReplace, SelectedFile, SelectedFile, %A_ScriptDir%\
  1505. GuiControl, 1: ,%Control%, %SelectedFile%
  1506. }
  1507. }
  1508. CheckAHKVersion(AHK_version){
  1509. StringSplit, A, A_AHKVERSION, .
  1510. StringSplit, B, AHK_version, .
  1511. Ax = 0
  1512. Bx = 0
  1513. Loop, %A0%{ ; create unique number for both versions, max. verion 999.999.999.999 leads to 999999999999
  1514. Ax := Ax + A%A_Index% * 1000 ** ( A0 - A_Index )
  1515. Bx := Bx + B%A_Index% * 1000 ** ( A0 - A_Index )
  1516. }
  1517. If ( Bx > Ax ) {
  1518. msgbox, 16, Old AHK version,
  1519. (LTrim
  1520. This script requires a newer version of AHK.
  1521. Installed version = %A_AHKVERSION%
  1522. Required version = %AHK_version%
  1523. Please download latest version and install it.
  1524. This Program will exit and open the webpage
  1525. where you can download the latest AHK version.
  1526. )
  1527. run, http://www.autohotkey.com/download
  1528. ExitApp
  1529. }
  1530. }
  1531. ;############# Get next free/available File Name ##########################
  1532. GetAvailableFileName(ExportFileName){
  1533. ;separate FileName and FileDir
  1534. SplitPath, ExportFileName, FileName, FileDir
  1535. ;return ExportFileName if FileName doesn't contain "#"
  1536. If (InStr(FileName, "#") = 0)
  1537. Return, ExportFileName
  1538. ;add "\" to FileDir again
  1539. If FileDir
  1540. FileDir = %FileDir%\
  1541. ;split FileName with #
  1542. StringSplit, NameArray, FileName, #
  1543. ;Search from StartID = 1
  1544. StartID = 1
  1545. Loop {
  1546. Number := A_Index + StartID - 1
  1547. ;untill number is too large ...
  1548. If ( StrLen(Number) > NameArray0 - 1 ) {
  1549. ErrorLevel =
  1550. (LTrim
  1551. All files exist for >%ExportFileName%<
  1552. with all "#" between %StartID% and %Number%.
  1553. )
  1554. Return 0
  1555. }
  1556. ;otherwise fill number with leading zeros
  1557. Loop, % NameArray0 - 1 - StrLen(Number)
  1558. Number = 0%Number%
  1559. ;split number in an array
  1560. StringSplit, NumberArray, Number
  1561. ;mix and concatenate the names array with the numbers array
  1562. FileName =
  1563. Loop, %NameArray0%
  1564. FileName := FileName . NameArray%A_Index% . NumberArray%A_Index%
  1565. ;check if GivenFileName doesn't exist
  1566. If not FileExist(FileDir . FileName)
  1567. Return FileDir . FileName
  1568. }
  1569. }
  1570. ;############# destroy draw objects #######################################
  1571. DeleteObject( p_object ) {
  1572. ;deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources
  1573. DllCall( "gdi32.dll\DeleteObject", "uint", p_object )
  1574. }
  1575. DeleteDC( p_dc ) {
  1576. ;deletes the specified device context (DC).
  1577. DllCall( "gdi32.dll\DeleteDC", "uint", p_dc )
  1578. }
  1579. ;############# create draw objects ########################################
  1580. CreateDrawHandles(UniqueID, ScreenWidth, ScreenHeight, frame_cc, frame_cw){
  1581. global hdc_frame, hdc_buffer, h_region, h_brushC, h_brushW
  1582. ;Get handle to display device context (DC) for the client area of a specified window
  1583. hdc_frame := DllCall( "GetDC"
  1584. , "uint", UniqueID )
  1585. ;create buffer to store old color data to remove drawn rectangles
  1586. hdc_buffer := DllCall( "gdi32.dll\CreateCompatibleDC"
  1587. , "uint", hdc_frame )
  1588. ;Create Bitmap buffer to remove drawn rectangles
  1589. hbm_buffer := DllCall( "gdi32.dll\CreateCompatibleBitmap"
  1590. , "uint", hdc_frame
  1591. , "int", ScreenWidth
  1592. , "int", ScreenHeight )
  1593. ;Select Bitmap buffer in buffer to remove drawn rectangles
  1594. DllCall( "gdi32.dll\SelectObject"
  1595. , "uint", hdc_buffer
  1596. , "uint", hbm_buffer )
  1597. ;create a dummy rectangular region.
  1598. h_region := DllCall( "gdi32.dll\CreateRectRgn"
  1599. , "int", 0
  1600. , "int", 0
  1601. , "int", 0
  1602. , "int", 0 )
  1603. ;specify the color of the control frame.
  1604. h_brushC := DllCall( "gdi32.dll\CreateSolidBrush"
  1605. , "uint", frame_cc )
  1606. ;specify the color of the window frame.
  1607. h_brushW := DllCall( "gdi32.dll\CreateSolidBrush"
  1608. , "uint", frame_cw )
  1609. }
  1610. ;############# remove old rectangle and save screen below new rectangle ###
  1611. BufferAndRestoreRegion( p_x, p_y, p_w, p_h ) {
  1612. global hdc_frame, hdc_buffer
  1613. static buffer_state, old_x, old_y, old_w, old_h
  1614. ;Copies the source rectangle directly to the destination rectangle.
  1615. SRCCOPY = 0x00CC0020
  1616. ;remove previously drawn rectangle (restore previoulsy buffered color data)
  1617. if ( buffer_state = "full")
  1618. ;perform transfer of color data of rectangle from source DC into destination DC
  1619. ; from buffer to screen, erasing the previously darwn reactangle
  1620. DllCall( "gdi32.dll\BitBlt"
  1621. , "uint", hdc_frame
  1622. , "int", old_x
  1623. , "int", old_y
  1624. , "int", old_w
  1625. , "int", old_h
  1626. , "uint", hdc_buffer
  1627. , "int", 0
  1628. , "int", 0
  1629. , "uint", SRCCOPY )
  1630. else
  1631. buffer_state = full
  1632. ;remember new rectangle for next loop (to be removed)
  1633. old_x := p_x
  1634. old_y := p_y
  1635. old_w := p_w
  1636. old_h := p_h
  1637. ; Store current color data of new rectangle in buffer
  1638. DllCall( "gdi32.dll\BitBlt"
  1639. , "uint", hdc_buffer
  1640. , "int", 0
  1641. , "int", 0
  1642. , "int", p_w
  1643. , "int", p_h
  1644. , "uint", hdc_frame
  1645. , "int", p_x
  1646. , "int", p_y
  1647. , "uint", SRCCOPY )
  1648. }
  1649. ;############# draw frame #################################################
  1650. DrawFrame( p_x, p_y, p_w, p_h, p_t, h_brush ) {
  1651. global hdc_frame, h_region
  1652. ; modify dummy rectangular region to desired reactangle
  1653. DllCall( "gdi32.dll\SetRectRgn"
  1654. , "uint", h_region
  1655. , "int", p_x
  1656. , "int", p_y
  1657. , "int", p_x+p_w
  1658. , "int", p_y+p_h )
  1659. ; draw region frame with thickness (width and hight are the same)
  1660. DllCall( "gdi32.dll\FrameRgn"
  1661. , "uint", hdc_frame
  1662. , "uint", h_region
  1663. , "uint", h_brush
  1664. , "int", p_t
  1665. , "int", p_t )
  1666. }