Guest User

Untitled

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