#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Resources\CV.ico #AutoIt3Wrapper_Outfile=CV.exe #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Description=Control Viewer #AutoIt3Wrapper_Res_Fileversion=0.2019.11.15 #AutoIt3Wrapper_Res_ProductName=CV.exe #AutoIt3Wrapper_Res_ProductVersion=0.0 #AutoIt3Wrapper_Res_Language=1000 #AutoIt3Wrapper_Res_Icon_Add=Resources\201.ico,201 #AutoIt3Wrapper_Res_Icon_Add=Resources\202.ico,202 #AutoIt3Wrapper_Res_Icon_Add=Resources\203.ico,203 #AutoIt3Wrapper_Res_Icon_Add=Resources\204.ico,204 #AutoIt3Wrapper_Res_Icon_Add=Resources\205.ico,205 #AutoIt3Wrapper_Res_Icon_Add=Resources\206.ico,206 #AutoIt3Wrapper_Res_Icon_Add=Resources\207.ico,207 #AutoIt3Wrapper_Res_Icon_Add=Resources\208.ico,208 #AutoIt3Wrapper_Res_Icon_Add=Resources\209.ico,209 #AutoIt3Wrapper_Res_Icon_Add=Resources\210.ico,210 #AutoIt3Wrapper_Res_Icon_Add=Resources\214.ico,214 #AutoIt3Wrapper_Res_Icon_Add=Resources\217.ico,217 #AutoIt3Wrapper_Res_File_Add=Resources\100.cur,RT_CURSOR,100 #AutoIt3Wrapper_Res_File_Add=Resources\101.cur,RT_CURSOR,101 #AutoIt3Wrapper_Res_File_Add=Resources\102.cur,RT_CURSOR,102 #AutoIt3Wrapper_Res_File_Add=Resources\103.cur,RT_CURSOR,103 #AutoIt3Wrapper_Res_File_Add=Resources\104.cur,RT_CURSOR,104 #AutoIt3Wrapper_Res_File_Add=Resources\105.cur,RT_CURSOR,105 #AutoIt3Wrapper_Res_File_Add=Resources\106.cur,RT_CURSOR,106 #AutoIt3Wrapper_Res_File_Add=Resources\107.cur,RT_CURSOR,107 #AutoIt3Wrapper_Res_File_Add=Resources\108.cur,RT_CURSOR,108 #AutoIt3Wrapper_Res_File_Add=Resources\About.png,PNG,ABOUT ;~ #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;~ #AutoIt3Wrapper_Run_Au3Stripper=y ;~ #Au3Stripper_Parameters=/rcwl #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ============================================== What's New in Version 0.2019.11.15 fixed: much higher CPU due to IPC introduced in v. 0.2019.11.10 What's New in Version 0.2019.11.14 added: RegisterMsg(WM_THEMECHANGED) to update the colors when needed. fixed: Labels ( aided repaint on WM_THEMECHANGED ). What's New in Version 0.2019.11.13 added: Menu for color choose or system default What's New in Version 0.2019.11.12 fixed: Not "Use Coloring", was not hiding all coloring. What's New in Version 0.2019.11.11 fixed: Elevate would not work in x64. fixed: ListView colors would not work in x64. fixed: Controls info. not loading to tab in x64. What's New in Version 0.2019.11.10 fixed: TaskSched would not work in x64. fixed: running a 2nd time, would not restore previously running. What's New in Version 0.2019.11.9 changed: Coloring using selected fixed: x64 support (choose color would crash in x64) What's New in Version 0.2019.11.8 added: Changed Coloring using musicstashall's code What's New in Version 0.2019.11.7 added: Coloring the controls by default, is now optional. What's New in Version 0.2019.05.30 added: CloneGUI: "msctls_statusbar32" controls fixed: startup /Tray on multi-user setup What's New in Version 0.2019.04.26 fixed: CloneGUI: broke on the compiled version theĀ "ConsoleWrite()" for the generated code. added: options to copy code to clipboard or save to file and optionally edit it. What's New in Version 0.2019.04.19 fixed: GetProcessTimes() crashing on multi-user setup What's New in Version 0.2019.04.18 added: Elevate / DeElevate added: TaskSched. entries for OnDemand(UAC bypass) or OnLogon What's New in Version 0.2019.03.18 added: "Generate events for all controls" for the "While" loop. fixed: "GUICtrlCreateGroup('', -99,..." alignment. What's New in Version 0.2019.03.17 added: Clone GUI ( basic cloning ) What's New in Version 0.2019.02.21 (unreleased) added: ($Menu[22]) Browse self folder What's New in Version 0.2018.12.26 bug fixed: would crash if "UIA highlight" enabled when unavailable change tray items handling added timestamp, to capture and report What's New in Version 0.2018.12.22 bug fixed: negative values would be wrong when saved to ini added green icon for "Extras" TAB if Emergency HotKey enabled added/adapted UIA Spy from https://github.com/jvanegmond/au3_uiautomation circa 2015 ( added just for the Screenshot to show more detail, there are newer tools dedicated to this approach ) be aware that enabling "UI Automation" investigation may crash some executables. What's New in Version 0.2018.12.19 added "Save to INI" instead of registry ( if "CV.ini" is found in the same folder, it will save there ) changed "Controls" listview headers, to auto-resize changed hotkey from Ctrl+Alt+Shift+"Pause" to "Break" ( should be the same on your keyboard ) added an option to do ProcessClose(PID) right after WinClose(PID) repeatedly failed. added an option to do ProcessClose(AutoIt*.exe) if all prior exit techniques failed changed emergency hotkey's extra key, to be user declared ( in registry or CV.ini ) What's New in Version 0.2018.12.18 added "/Tray" command line to start on the tray area ( but does not auto-enable HotKeys for emergency ) added a flag for when is in tray to save CPU cycles ( went from 0.03 to 0.01, not THAT important ) changed the GUI resize behaviour ( use "/Reset" command line to force it's default position ) added an auto-reset GUI position, in case of changed monitor(s) resolution, on start and restore from tray fixed the frame transparency not changing on the fly added "Visible Text" to Window TAB changed the "Text" in Control TAB to show multi-line changed F5 key to refresh the AutoIt TAB, even if not focused on the listview What's New in Version 0.2018.12.17 Corrected minor stuff and added options to the context menu What's New in Version 0.2018.12.16 ..just realized that there was a boo-boo in my code. Changed TrayIcon $TRAY_EVENT_PRIMARYDOUBLE to $TRAY_EVENT_PRIMARYUP . as the DClick is on 2nd press and not the 2nd release, so the easiest fix it to just 1 click on the way up. Added a notification for when the script is loaded again while hidden and on the tray, to restore itself and behave as expected. ============================================== #ce ;~ #include ;~ _DebugMsgBox_DefaulText("Please contact the developer." & @CRLF & "(https://www.autoitscript.com/forum/files/file/478-control-viewer-mod/)") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "UDFs\ColorChooser.au3" #include "UIA\UIAutomation.au3" #include #include #include ; get from https://www.autoitscript.com/forum/topic/193277-ipc-udf-via-filemapping/ ;~Opt('GUICloseOnESC', 0) Opt('GUIResizeMode', BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) Opt('MustDeclareVars', 1) Opt('WinTitleMatchMode', 3) Opt('WinWaitDelay', 0) Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Global Const $GUI_NAME = 'Control Viewer' Global Const $GUI_VERSION = '1.1' ;~Global Const $GUI_UNIQUE = $GUI_NAME & '_' & $GUI_VERSION & '_CvrXp' Global Const $GUI_UNIQUE = $GUI_NAME & '_CvrXp' Global Const $REG_KEY_NAME = 'HKCU\Software\Y''s\' & $GUI_NAME Global $GUI_INI = ScriptFullPathOnly() & ".ini" _FMIPC_Create(StringStripWS($GUI_UNIQUE & @UserName, 8)) If @error Then _FMIPC_Write(StringStripWS($GUI_UNIQUE & @UserName, 8), "DoSelfShow", 2) Exit 0 EndIf Global Const $Style[31][2] = _ [[0x00000004, 'DS_3DLOOK'], _ [0x00000001, 'DS_ABSALIGN'], _ [0x00000800, 'DS_CENTER'], _ [0x00001000, 'DS_CENTERMOUSE'], _ [0x00002000, 'DS_CONTEXTHELP'], _ [0x00000400, 'DS_CONTROL'], _ [0x00000008, 'DS_FIXEDSYS'], _ [0x00000020, 'DS_LOCALEDIT'], _ [0x00000080, 'DS_MODALFRAME'], _ [0x00000010, 'DS_NOFAILCREATE'], _ [0x00000100, 'DS_NOIDLEMSG'], _ [0x00000040, 'DS_SETFONT'], _ [0x00000200, 'DS_SETFOREGROUND'], _ [0x00000002, 'DS_SYSMODAL'], _ [0x00800000, 'WS_BORDER'], _ [0x00C00000, 'WS_CAPTION'], _ [0x40000000, 'WS_CHILD'], _ [0x02000000, 'WS_CLIPCHILDREN'], _ [0x04000000, 'WS_CLIPSIBLINGS'], _ [0x08000000, 'WS_DISABLED'], _ [0x00400000, 'WS_DLGFRAME'], _ [0x00020000, 'WS_GROUP'], _ [0x00100000, 'WS_HSCROLL'], _ [0x01000000, 'WS_MAXIMIZE'], _ [0x20000000, 'WS_MINIMIZE'], _ [0x80000000, 'WS_POPUP'], _ [0x00040000, 'WS_SIZEBOX'], _ [0x00080000, 'WS_SYSMENU'], _ [0x00010000, 'WS_TABSTOP'], _ [0x10000000, 'WS_VISIBLE'], _ [0x00200000, 'WS_VSCROLL']] Global Const $ExStyle[21][2] = _ [[0x00000010, 'WS_EX_ACCEPTFILES'], _ [0x00040000, 'WS_EX_APPWINDOW'], _ [0x00000200, 'WS_EX_CLIENTEDGE'], _ [0x02000000, 'WS_EX_COMPOSITED'], _ [0x00000400, 'WS_EX_CONTEXTHELP'], _ [0x00010000, 'WS_EX_CONTROLPARENT'], _ [0x00000001, 'WS_EX_DLGMODALFRAME'], _ [0x00080000, 'WS_EX_LAYERED'], _ [0x00400000, 'WS_EX_LAYOUTRTL'], _ [0x00004000, 'WS_EX_LEFTSCROLLBAR'], _ [0x00000040, 'WS_EX_MDICHILD'], _ [0x08000000, 'WS_EX_NOACTIVATE'], _ [0x00100000, 'WS_EX_NOINHERITLAYOUT'], _ [0x00000004, 'WS_EX_NOPARENTNOTIFY'], _ [0x00001000, 'WS_EX_RIGHT'], _ [0x00002000, 'WS_EX_RTLREADING'], _ [0x00020000, 'WS_EX_STATICEDGE'], _ [0x00000080, 'WS_EX_TOOLWINDOW'], _ [0x00000008, 'WS_EX_TOPMOST'], _ [0x00000020, 'WS_EX_TRANSPARENT'], _ [0x00000100, 'WS_EX_WINDOWEDGE']] Global $__g_TaskSched_URI_Folder = '\' ; '\MyFolder' Global $__g_TaskSched_URI_Name = '\' & StringReplace(ScriptNameOnly(), " ", "") & '_for_' & StringReplace(@UserName, " ", "") Global $__g_TaskSched_InfoURI = $__g_TaskSched_URI_Folder & $__g_TaskSched_URI_Name Global $__g_TaskSched_InfoDescription = ScriptNameOnly() & ' for ' & @UserName & ' on LogOn' Global $__g_TaskSched_InfoAuthor = StringUpper(@LogonDomain) & '\' & @UserName ; @ComputerName & '\' & @UserName Global $__g_TaskSched_TriggerDelay = 0 ; delay 10 sec. Global $__g_TaskSched_TriggerOnLogon = 1 ; 1 = True / 0 = False Global $__g_TaskSched_ExecCommand = @ScriptFullPath ; ScriptFullPathOnly() & '.exe' Global $__g_TaskSched_ExecArguments = "/FromTaskSched" Global $__g_TaskSched_ExecWorkingDirectory = @ScriptDir Global $__g_TaskSched_CanBeAdmin = _CanBeAdmin() Global $__g_TaskSched_TriggerType = 0 If _TaskSched_AlreadyInstalled("_OnLogon") Then $__g_TaskSched_TriggerType = 2 If _TaskSched_AlreadyInstalled("_OnDemand") Then $__g_TaskSched_TriggerType = 1 If $__g_TaskSched_TriggerType And Not StringInStr($CmdLineRaw, "/FromTaskSched") Then _TaskSched_Run() EndIf Global $_XPos = 50 ; 8 ; ((-1) - Default) Global $_YPos = 50 ; 8 ; ((-1) - Default) ;~Global $_About = 0 ; (1/0) Global $_ProgmanPos = "0,0,640,480" Global $_EmergencyTryPClose = 1 Global $_EmergencyTryPAu3Exe = 1 Global $_EmergencyTryPCloseKey = 0x5A Global $_EmergencyTryPAu3ExeKey = 0x41 Global $_Width = 421 Global $_Height = 653 Global $_Top = 1 ; (0/1) Global $_ColoringCtrls = 1 ; (0/1) Global $_Position = 0 ; (0 - Absolute; 1 - Window; 2 - Client; 3 - Control) Global $_Color = 0 ; (0 - RGB; 1 - BGR) Global $_Crosshair = 1 ; (0/1) Global $_Highlight = 1 ; (0/1) Global $_Frame = 0xFF0000 Global $_Alpha = 192 Global $_Fade = 1 ; (0/1) Global $_Code = 1 ; (0 - ANSI; 1 - Unicode; 2 - Unicode (Big Endian); 3 - UTF8) Global $_CloneGui = 1 ; (0 - ClipPut; 1 - SaveToMyDocuments; 3 - Ask "SaveAs" menu) Global $_CloneEditGuiFile = 1 Global $_Icon = 1 ; (0/1) Global $_Tab = 0 ; (0 - Window; 1 - Control; 2 - Capture; 3 - AutoIt) Global $_Rgb[9] = [0x000000, 0x9C9C9C, 0xE00000, 1, 1, 0, $COLOR_BTNTEXT, $COLOR_GRAYTEXT, $COLOR_HOTLIGHT] ; (Visible, Hidden, Missing) Global $_Column[12] = [98 + 48 * @AutoItX64, 176 - 48 * @AutoItX64, 38, 44, 124, 44, 82 + 48 * @AutoItX64, 124, 140, 60, 267, 100] ; (Handle, Class, NN, ID | Process, PID, Handle, Class, Title, Version, Path, CmdLine) Global $_Crop[2] = [349, 223] ; (Width, Height) Global $_Capture = 0 ; (0/1) Global $_All = 0 ; (0/1) Global $_AllJustAutoItv3 = 0 ; (0/1) Global $_EmergencyCloseOn = 0, $g_EmergencyCloseIsOn = 0, $g_iTray_IsNotOn = 1 Global $_UiaSpy = 0, $_UiaSpyLink = "https://github.com/jvanegmond/au3_uiautomation" Global $g_iStartOnTray = False Global $g_ctrl_CloneGui[10] = [0, 0, 0, 0, 0] If StringInStr($CmdLineRaw, "/T") Then $g_iStartOnTray = Not $g_iStartOnTray ; "/Tray" command line to start hidden in the tray area If StringInStr($CmdLineRaw, "/Elevated") Then $g_iStartOnTray = False If IsItBootRun(60) Then $g_iStartOnTray = True Global Const $SBS_SIZEBOX = 0x08, $SBS_SIZEGRIP = 0x10 Global Const $WM_MYMSG = $WM_USER + 12321 ; for tray Icon "Show GUI" Global $hSizebox = 0, $_SM_CYMENU = 20, $_SM_CXSIZEFRAME = 4, $hAutoItCreated Global $hDLLuser32 = DllOpen('user32.dll') _ApplicationCheck() _ReadRegistry() GUIRegisterMsg($WM_MYMSG, "WM_MYMSG") Func WM_MYMSG($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $lParam If $wParam = 12321 Then Emergency_Tray_ShowGui() Return 1 EndFunc ;==>WM_MYMSG Global $hWnd[2], $hForm, $hFrame, $hPopup = 0, $hFrameIsShown, $LabelOther[30] Global $hPic[2], $hHeader[2], $hTab, $hAutoIt, $hListView, $hIL, $Combo[2], $Dummy[7], $Group, $Icon[2], $Input[32], $Label[9], $Menu[28], $Pic, $Tab, $BttnEC[7], $UIA_Ctrls[9] Global $Accel[5][2] = [['^a'], ['^d'], ['^!t'], ['^!h'], ['{ENTER}']] Global $Col[2] = [0xFF000000, 0] Global $hCursor[8], $hBitmap, $hAbout = 0, $hRoot = 0, $hOver = 0, $hPrev = 0, $hRect = 0, $hDesktop = 0 Global $Browser = False, $Ctrl = False, $Enum = False, $Fade = False, $Hold = False, $Refresh = False Global $Count, $Data, $ID, $Item, $Key, $List, $Msg, $Alpha = 0, $Area = 0, $Resize = -1 Global $dX, $dY, $Xi, $Yi, $Xk, $Yk, $Xn, $Yn, $Xp, $Yp, $Ci, $Cp, $Wp, $Hp Global $hFile, $hInstance = _WinAPI_GetModuleHandle(0) Global $PathDlg = @WorkingDir Global $tPoint, $tRect Global $HotKeyd = 0 Global $_ExmptPid = 0 Global $_ExmptStr = FileRead(@ScriptDir & "\CV.EXEMPT.TXT") Emergency_Exempt($_ExmptStr, 1) If Not @Compiled Then For $i = 0 To 7 $hCursor[$i] = _WinAPI_LoadCursorFromFile(@ScriptDir & '\Resources\' & (100 + $i) & '.cur') Next Else For $i = 0 To 7 $hCursor[$i] = _WinAPI_LoadCursor($hInstance, 100 + $i) Next EndIf If _WinAPI_IsThemeActive() Then $Col[0] = 0xFF000000 + _WinAPI_GetSysColor($COLOR_HIGHLIGHT) ; 0xFF3E60C5 $Col[1] = 0x1E000000 + _WinAPI_GetSysColor($COLOR_HIGHLIGHT) ; 0x1E3E60C5 EndIf If _WinAPI_GetSystemMetrics($SM_SWAPBUTTON) Then $Key = 0x02 Else $Key = 0x01 EndIf OnAutoItExitRegister('AutoItExit') _GDIPlus_Startup() ;~_About() Global $a_ProgmanPos = GetProgmanPos() Func GetProgmanPos() Local $e = 0, $s = $_ProgmanPos, $a = WinGetPos("[CLASS:Progman;]") If UBound($a) = 4 Then $s = $a[0] & "," & $a[1] & "," & $a[2] & "," & $a[3] Else $a = StringSplit($_ProgmanPos, ",", 2) EndIf If $s <> $_ProgmanPos Then $_XPos = 50 ; monitor(s) or resolusion changed, $_YPos = 50 ; can not trust the GUI will be visible again, $e = 1 ; so we reset it to default position. $_ProgmanPos = $s EndIf Return SetError(0, $e, $a) EndFunc ;==>GetProgmanPos _GUICreate() Global $hAutoitContextDummy, $hAutoitContext, $hAutoitMenuItem_showhide, $hAutoitMenuItem_show, _ $hAutoitMenuItem_hide, $hAutoitMenuItem_processclose, $hAutoitMenuItem_BrowseToFile $hAutoitContextDummy = GUICtrlCreateDummy() $hAutoitContext = GUICtrlCreateContextMenu($hAutoitContextDummy) $hAutoitMenuItem_showhide = GUICtrlCreateMenu("Show / Hide Form", $hAutoitContext) $hAutoitMenuItem_show = GUICtrlCreateMenuItem("Show", $hAutoitMenuItem_showhide) $hAutoitMenuItem_hide = GUICtrlCreateMenuItem("Hide", $hAutoitMenuItem_showhide) Global $hAutoitMenuItem_SetTopmost_Menu = GUICtrlCreateMenu("Set Form Topmost", $hAutoitContext) Global $hAutoitMenuItem_SetTopmost_Yes = GUICtrlCreateMenuItem("Yes", $hAutoitMenuItem_SetTopmost_Menu) Global $hAutoitMenuItem_SetTopmost_No = GUICtrlCreateMenuItem("No", $hAutoitMenuItem_SetTopmost_Menu) $hAutoitMenuItem_processclose = GUICtrlCreateMenuItem("ProcessClose(BY PID)", $hAutoitContext) Global $hAutoitMenuItem_process_CloseByName = GUICtrlCreateMenuItem("ProcessClose(BY NAME)", $hAutoitContext) $hAutoitMenuItem_BrowseToFile = GUICtrlCreateMenuItem("Browse Folder", $hAutoitContext) Global $hAutoitMenuItem_ClipPutCmdLine = GUICtrlCreateMenuItem("ClipPut( CmdLine )", $hAutoitContext) Global $hAutoitMenuItem_ClipPutTitle = GUICtrlCreateMenuItem("ClipPut( Title )", $hAutoitContext) Global $hAutoitMenuItem_ClipPutHandle = GUICtrlCreateMenuItem("ClipPut( Handle )", $hAutoitContext) GUICtrlCreate_Label_ColorUp() GUIRegisterMsg($WM_THEMECHANGED, "_WM_THEMECHANGED") ;~ #EndRegion Initialization #Region Body If $g_iStartOnTray Then Emergency_Tray_On() If $_EmergencyCloseOn Then _GUICtrlTab_SetItemImage($hTab, 4, 5) Global $UIA_oUIElement, $UIA_controlPos, $UIA_lastKnownPos[4], $UIA_hFrame[4] ; for UIA Spy/highlight ; main loop While 1 If $g_iTray_IsNotOn Then ; ..save CPU if not in use If (($hRoot) And (Not _WinAPI_IsWindowVisible($hRoot))) Then _ShowFrame(0) _Update(1) $hRoot = 0 $hOver = 0 EndIf If (($hOver) And (Not _WinAPI_IsWindowVisible($hOver))) Or (($hRect) And (Not WinActive($hForm))) Then _ShowFrame(0) $hOver = 0 EndIf If _IsDown(0x11) Then ; 11 CTRL key If Not $Ctrl Then _SendMessage($hForm, $WM_SETCURSOR) EndIf $Ctrl = 1 Else If $Ctrl Then _SendMessage($hForm, $WM_SETCURSOR) EndIf $Ctrl = 0 EndIf EndIf If $_ExmptPid Then If Not ProcessExists($_ExmptPid) Then $_ExmptPid = 0 $_ExmptStr = FileRead(@ScriptDir & "\CV.EXEMPT.TXT") Emergency_Exempt($_ExmptStr, 1) GUICtrlSetState($BttnEC[3], $GUI_ENABLE) GUICtrlSetState($Tab, $GUI_FOCUS) EndIf EndIf _FMIPC_ReadSlower() $Msg = GUIGetMsg() If $HotKeyd Then $Msg = $HotKeyd ; mod. by argumentum Switch $Msg Case 0 ContinueLoop Case $GUI_EVENT_CLOSE If _IsDown(0x10) Then ; SHIFT key ShellExecute(@ScriptDir) ;;; ...I use this while coding, not realy needed ContinueLoop EndIf If $g_EmergencyCloseIsOn And Not _IsDown(0x11) Then ; CTRL key Emergency_Tray_On() ContinueLoop EndIf GUIDelete() _FMIPC_Close() Exit Case $GUI_EVENT_RESIZED hListView_AUTOSIZE_USEHEADER() Case $BttnEC[0], $BttnEC[1], $BttnEC[2], $BttnEC[3], $BttnEC[4], $BttnEC[5] _WinAPI_SetPriorityClass($HIGH_PRIORITY_CLASS) Emergency_HotKey_GuiMsg($Msg) _WinAPI_SetPriorityClass($NORMAL_PRIORITY_CLASS) Case $hAutoitMenuItem_show AutoitMenuItemDo($Msg) Case $hAutoitMenuItem_hide, $hAutoitMenuItem_process_CloseByName, $hAutoitMenuItem_ClipPutTitle, $hAutoitMenuItem_ClipPutHandle AutoitMenuItemDo($Msg) Case $hAutoitMenuItem_processclose, $hAutoitMenuItem_BrowseToFile, $hAutoitMenuItem_SetTopmost_Yes, $hAutoitMenuItem_SetTopmost_No, $hAutoitMenuItem_ClipPutCmdLine AutoitMenuItemDo($Msg) Case $g_ctrl_CloneGui[0] GUICtrlSetState($g_ctrl_CloneGui[0], $GUI_DISABLE) ShowMenu($hForm, $g_ctrl_CloneGui[0], $g_ctrl_CloneGui[2]) GUICtrlSetState($g_ctrl_CloneGui[0], $GUI_ENABLE) Case $g_ctrl_CloneGui[3] ;= GUICtrlCreateMenuItem("All controls", $g_ctrl_CloneGui[2]) GUICtrlSetState($g_ctrl_CloneGui[0], $GUI_DISABLE) _CloneGui(0) GUICtrlSetState($g_ctrl_CloneGui[0], $GUI_ENABLE) Case $g_ctrl_CloneGui[4] ;= GUICtrlCreateMenuItem("Checked controls", $g_ctrl_CloneGui[2]) GUICtrlSetState($g_ctrl_CloneGui[0], $GUI_DISABLE) _CloneGui(1) GUICtrlSetState($g_ctrl_CloneGui[0], $GUI_ENABLE) Case $UIA_Ctrls[1] $_UiaSpy = _NotInt($_UiaSpy) If $_UiaSpy Then GUICtrlSetState($UIA_Ctrls[1], $GUI_CHECKED) GUICtrlSetState($UIA_Ctrls[2], $GUI_ENABLE) Else GUICtrlSetState($UIA_Ctrls[1], $GUI_UNCHECKED) GUICtrlSetState($UIA_Ctrls[2], $GUI_DISABLE) EndIf Case $Icon[0] _ShowFrame(0) _WinAPI_SetFocus($hListView) If Not @Compiled Then GUICtrlSetImage($Icon[0], @ScriptDir & '\Resources\201.ico') Else GUICtrlSetImage($Icon[0], @ScriptFullPath, 201) EndIf $Browser = 1 $Xp = -1 $Yp = -1 $Cp = -1 $hRoot = 0 $hOver = 0 $hPrev = _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, $IDI_APPLICATION)) If $hPrev Then _WinAPI_SetSystemCursor($hCursor[0], $IDI_APPLICATION, 1) EndIf Opt('GUIOnEventMode', 1) GUISetState(@SW_DISABLE, $hForm) While _IsDown($Key) _UIA__Show() ;~ If $hRect Then ;~ WinSetOnTop($hFrame, '', 1) ;~ EndIf ;~ Sleep(1) $tPoint = _WinAPI_GetMousePos() $Xi = DllStructGetData($tPoint, 1) $Yi = DllStructGetData($tPoint, 2) If $Fade Then $Ci = -1 EndIf If ($Xi <> $Xp) Or ($Yi <> $Yp) Or ($Ci <> $Cp) Then $hBitmap = _Capture_X3($Xi - 11, $Yi - 11, 23, 23, 69, 69) $Ci = @extended If $hBitmap Then If $Ci <> $Cp Then GUICtrlSetBkColor($Label[0], $Ci) Switch $_Color Case 0 ; RGB $Data = $Ci Case 1 ; BGR $Data = _WinAPI_SwitchColor($Ci) EndSwitch GUICtrlSetData($Input[2], '0x' & Hex($Data, 6)) EndIf Else If $Ci <> $Cp Then GUICtrlSetBkColor($Label[0], _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE))) GUICtrlSetData($Input[2], '') EndIf EndIf _SetBitmap($hPic[0], $hBitmap) If $_Capture Then _SetBitmap($hPic[1], _Capture_X1($Xi - Floor(($_Crop[0] - 10) / 2), $Yi - Floor(($_Crop[1] - 10) / 2), $_Crop[0] - 10, $_Crop[1] - 10, $Col[0], 0, 1), 1) If BitAND(GUICtrlGetState($Label[4]), $GUI_SHOW) Then GUICtrlSetState($Label[4], $GUI_HIDE) EndIf EndIf $Xp = $Xi $Yp = $Yi $Cp = $Ci EndIf $hWnd[0] = _WinAPI_GetAncestor(_WinAPI_WindowFromPoint($tPoint), $GA_ROOT) Switch $_Position Case 0 ; Absolute For $i = 0 To 1 _SetData($Input[$i], DllStructGetData($tPoint, $i + 1)) Next Case 1, 2 ; Window, Client If ($hWnd[0] = $hForm) Or ($hWnd[0] = $hFrame) Then If _WinAPI_IsWindow($hRoot) Then $Data = $hRoot Else $Data = 0 EndIf Else $Data = $hWnd[0] EndIf If $Data Then Switch $_Position Case 1 ; Window $tRect = _WinAPI_GetWindowRect($Data) Case 2 ; Client $tRect = _WinAPI_GetClientRect($Data) If _WinAPI_ScreenToClient($Data, $tRect) Then For $i = 1 To 2 DllStructSetData($tRect, $i + 2, DllStructGetData($tRect, $i + 2) - DllStructGetData($tRect, $i)) DllStructSetData($tRect, $i, -DllStructGetData($tRect, $i)) Next Else $tRect = 0 EndIf EndSwitch Else $tRect = 0 EndIf ;~ If True Then If _WinAPI_PtInRect($tRect, $tPoint) Then For $i = 0 To 1 _SetData($Input[$i], DllStructGetData($tPoint, $i + 1) - DllStructGetData($tRect, $i + 1)) Next Else For $i = 0 To 1 _SetData($Input[$i], '') Next EndIf ;~ EndIf Case 3 ; Control If ($hWnd[0] = $hForm) Or ($hWnd[0] = $hFrame) Then If $hOver Then $tRect = _WinAPI_GetWindowRect($hOver) Else $tRect = 0 EndIf If _WinAPI_PtInRect($tRect, $tPoint) Then For $i = 0 To 1 _SetData($Input[$i], DllStructGetData($tPoint, $i + 1) - DllStructGetData($tRect, $i + 1)) Next Else For $i = 0 To 1 _SetData($Input[$i], '') Next EndIf EndIf EndSwitch If ($hWnd[0] = $hForm) Or ($hWnd[0] = $hFrame) Then If ($hOver) And (Not _WinAPI_IsWindowVisible($hOver)) Then If $hRect Then _ShowFrame(0) EndIf $Xp = -1 $Yp = -1 $Cp = -1 EndIf ContinueLoop EndIf $hWnd[1] = 0 $List = _WinAPI_EnumChildWindows($hWnd[0], 0) If @error Then $Count = 0 Else $Count = $List[0][0] For $i = $Count To 1 Step -1 If Not _WinAPI_IsWindowVisible($List[$i][0]) Then ContinueLoop EndIf $tRect = _WinAPI_GetWindowRect($List[$i][0]) If _WinAPI_PtInRect($tRect, $tPoint) Then $hWnd[1] = $List[$i][0] ExitLoop EndIf Next EndIf Switch $_Position Case 0, 1, 2 ; Absolute, Window, Client Case 3 ; Control If $hWnd[1] Then For $i = 0 To 1 _SetData($Input[$i], DllStructGetData($tPoint, $i + 1) - DllStructGetData($tRect, $i + 1)) Next Else For $i = 0 To 1 _SetData($Input[$i], '') Next EndIf EndSwitch If ($hWnd[0] = $hRoot) And ($hWnd[1] = $hOver) Then ContinueLoop EndIf If ($hWnd[0] = $hRoot) Then ;~ _SetWindowInfo($hWnd[0], 1) Else _SetWindowInfo($hWnd[0]) EndIf _GUICtrlListView_BeginUpdate($hListView) If ($hWnd[0] = $hRoot) And (_GUICtrlListView_GetItemCount($hListView) = $Count) Then $Item = _GUICtrlListView_FindText($hListView, $hWnd[1], -1, 0) ;~ If ($hWnd[1]) And ($Item = -1) Then ;~ EndIf Else $Enum = 1 _GUICtrlListView_DeleteAllItems($hListView) $Item = -1 For $i = 1 To $Count _GUICtrlListView_AddItem($hListView, $List[$i][0]) _GUICtrlListView_AddSubItem($hListView, $i - 1, $List[$i][1], 1) ;~ _GUICtrlListView_AddSubItem($hListView, $i - 1, StringLeft(ControlGetText($hWnd[0], '', $List[$i][0]), 80), 4) $ID = _WinAPI_GetDlgCtrlID($List[$i][0]) If $ID > 0 Then _GUICtrlListView_AddSubItem($hListView, $i - 1, $ID, 3) EndIf Next For $i = 1 To $Count If ($List[$i][0] = $hWnd[1]) Then $Item = $i - 1 EndIf If ($List[$i][1]) And (IsString($List[$i][1])) Then $ID = 1 $Data = $List[$i][1] For $j = $i To UBound($List) - 1 If $List[$j][1] = $Data Then $List[$j][1] = $ID $ID += 1 EndIf Next EndIf Next For $i = 1 To $Count _GUICtrlListView_AddSubItem($hListView, $i - 1, $List[$i][1], 2) If _WinAPI_IsWindowVisible($List[$i][0]) Then _GUICtrlListView_SetItemChecked($hListView, $i - 1) EndIf Next $Enum = 0 hListView_AUTOSIZE_USEHEADER() EndIf If $Item = -1 Then $Item = _GUICtrlListView_GetSelectedIndices($hListView) If $Item Then _GUICtrlListView_SetItemSelected($hListView, $Item, 0, 0) _GUICtrlListView_SetItemFocused($hListView, $Item, 0) EndIf _SetControlInfo(0) Else _GUICtrlListView_SetItemSelected($hListView, $Item, 1, 1) _GUICtrlListView_EnsureVisible($hListView, $Item, 1) EndIf _GUICtrlListView_EndUpdate($hListView) If $hWnd[1] Then _ShowFrame(1, $tRect, $hWnd[0]) Else _ShowFrame(0) EndIf $hRoot = $hWnd[0] $hOver = $hWnd[1] WEnd If $hDesktop Then _WinAPI_DeleteObject($hDesktop) EndIf $hDesktop = _Capture_Desktop() If Not $_Capture Then _SetBitmap($hPic[1], _Capture_X1($Xp - Floor(($_Crop[0] - 10) / 2), $Yp - Floor(($_Crop[1] - 10) / 2), $_Crop[0] - 10, $_Crop[1] - 10, $Col[0], 0, 1), 1) If BitAND(GUICtrlGetState($Label[4]), $GUI_SHOW) Then GUICtrlSetState($Label[4], $GUI_HIDE) EndIf EndIf _ShowFrame(0) _UIA__Hide() If $hPrev Then _WinAPI_SetSystemCursor($hPrev, $IDI_APPLICATION, 1) EndIf $hPrev = 0 $hOver = 0 $Browser = 0 If Not @Compiled Then GUICtrlSetImage($Icon[0], @ScriptDir & '\Resources\202.ico') Else GUICtrlSetImage($Icon[0], @ScriptFullPath, 202) EndIf GUISetState(@SW_ENABLE, $hForm) Opt('GUIOnEventMode', 0) WinActivate($hForm) If Not FileExists(GUICtrlRead($Input[15])) Then GUICtrlSetState($Icon[1], $GUI_DISABLE) Else GUICtrlSetState($Icon[1], $GUI_ENABLE) EndIf If Not $hRoot Then GUICtrlSetState($Menu[0], $GUI_DISABLE) GUICtrlSetState($g_ctrl_CloneGui[0], $GUI_DISABLE) Else GUICtrlSetState($Menu[0], $GUI_ENABLE) GUICtrlSetState($g_ctrl_CloneGui[0], $GUI_ENABLE) EndIf Case $Icon[1] $Data = GUICtrlRead($Input[15]) If $Data Then _WinAPI_ShellOpenFolderAndSelectItems($Data) ;~ If @error Then ;~ EndIf EndIf Case $Dummy[0] $Data = GUICtrlRead($Dummy[0]) If Not _GUICtrlListView_GetSelectedIndices($hListView) Then _GUICtrlListView_SetItemSelected($hListView, $Data, 1, 1) EndIf Case $Dummy[1] $Data = GUICtrlRead($Dummy[1]) $Data = Ptr(_GUICtrlListView_GetItemText($hListView, $Data)) If ($Data) And (_WinAPI_IsWindow($Data)) Then _SetControlInfo($Data) ;~ Else ;~ _SetControlInfo(0) EndIf Case $Dummy[2] If Not _GetCursor($Xi, $Yi, $hForm) Then ContinueLoop EndIf $ID = _IsCrop($Xi, $Yi, $dX, $dY) Switch $ID Case 0 If (Not $hDesktop) Or (Not _IsDown(0x11)) Then ; 11 CTRL key _IsPressed ContinueLoop EndIf $Xk = Default $Yk = Default $Xn = $Xp $Yn = $Yp $dX = $Xi $dY = $Yi $Resize = 2 Case 1, 5 $Resize = 3 Case 2, 6 $Resize = 4 Case 3, 7 $Resize = 5 Case 4, 8 $Resize = 6 Case Else ContinueLoop EndSwitch $Wp = 0 $Hp = 0 Opt('GUIOnEventMode', 1) While _IsDown($Key) ;~ Sleep(1) If Not _GetCursor($Xi, $Yi, $hForm) Then ContinueLoop EndIf Switch $ID Case 0 $Xp = $Xn - $Xi + $dX $Yp = $Yn - $Yi + $dY Case 1 If $Xi - $dX < 38 Then $Xi = 38 + $dX EndIf If $Xi - $dX > 191 Then $Xi = 191 + $dX EndIf If $Yi - $dY < 173 Then $Yi = 173 + $dY EndIf If $Yi - $dY > 263 Then $Yi = 263 + $dY EndIf $_Crop[0] = 349 - 2 * ($Xi - $dX - 38) $_Crop[1] = 223 - 2 * ($Yi - $dY - 173) Case 2 If $Yi - $dY < 173 Then $Yi = 173 + $dY EndIf If $Yi - $dY > 263 Then $Yi = 263 + $dY EndIf $_Crop[1] = 223 - 2 * ($Yi - $dY - 173) Case 3 If $Xi - $dX < 229 Then $Xi = 229 + $dX EndIf If $Xi - $dX > 382 Then $Xi = 382 + $dX EndIf If $Yi - $dY < 173 Then $Yi = 173 + $dY EndIf If $Yi - $dY > 263 Then $Yi = 263 + $dY EndIf $_Crop[0] = 349 + 2 * ($Xi - $dX - 382) $_Crop[1] = 223 - 2 * ($Yi - $dY - 173) Case 4 If $Xi - $dX < 229 Then $Xi = 229 + $dX EndIf If $Xi - $dX > 382 Then $Xi = 382 + $dX EndIf $_Crop[0] = 349 + 2 * ($Xi - $dX - 382) Case 5 If $Xi - $dX < 229 Then $Xi = 229 + $dX EndIf If $Xi - $dX > 382 Then $Xi = 382 + $dX EndIf If $Yi - $dY < 301 Then $Yi = 301 + $dY EndIf If $Yi - $dY > 391 Then $Yi = 391 + $dY EndIf $_Crop[0] = 349 + 2 * ($Xi - $dX - 382) $_Crop[1] = 223 + 2 * ($Yi - $dY - 391) Case 6 If $Yi - $dY < 301 Then $Yi = 301 + $dY EndIf If $Yi - $dY > 391 Then $Yi = 391 + $dY EndIf $_Crop[1] = 223 + 2 * ($Yi - $dY - 391) Case 7 If $Xi - $dX < 38 Then $Xi = 38 + $dX EndIf If $Xi - $dX > 191 Then $Xi = 191 + $dX EndIf If $Yi - $dY < 301 Then $Yi = 301 + $dY EndIf If $Yi - $dY > 391 Then $Yi = 391 + $dY EndIf $_Crop[0] = 349 - 2 * ($Xi - $dX - 38) $_Crop[1] = 223 + 2 * ($Yi - $dY - 391) Case 8 If $Xi - $dX < 38 Then $Xi = 38 + $dX EndIf If $Xi - $dX > 191 Then $Xi = 191 + $dX EndIf $_Crop[0] = 349 - 2 * ($Xi - $dX - 38) EndSwitch Switch $ID Case 0 Case 1, 3, 5, 7 If _IsDown(0x10) Then ; 10 SHIFT key If $_Crop[0] > $_Crop[1] Then $_Crop[0] = $_Crop[1] Else $_Crop[1] = $_Crop[0] EndIf EndIf EndSwitch If ($Xp <> $Xk) Or ($Yp <> $Yk) Or ($Wp <> $_Crop[0]) Or ($Hp <> $_Crop[1]) Then If $hDesktop Then $hBitmap = _Capture_X1($Xp - Floor(($_Crop[0] - 10) / 2), $Yp - Floor(($_Crop[1] - 10) / 2), $_Crop[0] - 10, $_Crop[1] - 10, $Col[0], 0, 1, 0, $hDesktop) Else $hBitmap = _Capture_X1(0, 0, $_Crop[0] - 10, $_Crop[1] - 10, $Col[0], $Col[1], 0, 0) If $_Crop[0] - 10 < 187 Then If BitAND(GUICtrlGetState($Label[4]), $GUI_SHOW) Then GUICtrlSetState($Label[4], $GUI_HIDE) EndIf Else If BitAND(GUICtrlGetState($Label[4]), $GUI_HIDE) Then GUICtrlSetState($Label[4], $GUI_SHOW) EndIf EndIf EndIf $tPoint = _WinAPI_CreatePoint(36 + Floor((349 - $_Crop[0]) / 2), 171 + Floor((223 - $_Crop[1]) / 2)) _WinAPI_ClientToScreen($hForm, $tPoint) $Xi = DllStructGetData($tPoint, 1) $Yi = DllStructGetData($tPoint, 2) If Not $hPopup Then $hPopup = GUICreate('', 100, 100, $Xi, $Yi, BitOR($WS_DISABLED, $WS_POPUP), BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST), $hForm) GUISetState(@SW_SHOWNOACTIVATE, $hPopup) Switch $ID Case 0 Case Else GUICtrlSetState($Pic, $GUI_HIDE) EndSwitch EndIf _WinAPI_UpdateLayeredWindowEx($hPopup, $Xi, $Yi, $hBitmap, 255, 1) ;~ _WinAPI_DeleteObject($hBitmap) $Wp = $_Crop[0] $Hp = $_Crop[1] $Xk = $Xp $Yk = $Yp EndIf WEnd Opt('GUIOnEventMode', 0) GUICtrlSetPos($Pic, 36 + Floor((349 - $_Crop[0]) / 2), 171 + Floor((223 - $_Crop[1]) / 2), $_Crop[0], $_Crop[1]) If $hDesktop Then _SetBitmap($hPic[1], _Capture_X1($Xp - Floor(($_Crop[0] - 10) / 2), $Yp - Floor(($_Crop[1] - 10) / 2), $_Crop[0] - 10, $_Crop[1] - 10, $Col[0], 0, 1, 0, $hDesktop), 1) Else _SetBitmap($hPic[1], _Capture_X1(0, 0, $_Crop[0] - 10, $_Crop[1] - 10, $Col[0], $Col[1]), 1) EndIf Switch $ID Case 0 Case Else GUICtrlSetState($Pic, $GUI_SHOW) EndSwitch GUIDelete($hPopup) $hPopup = 0 $Resize = -1 ;~ If True Then _SendMessage($hForm, $WM_SETCURSOR) ;~ EndIf Case $Dummy[3] If Not _ShellSaveDlg($hForm) Then MsgBox(16, $GUI_NAME, 'Unable to save image.', 0, $hForm) EndIf Case $Dummy[4] $Data = _GUICtrlListView_GetSelectedIndices($hAutoIt) If $Data Then $Data = _GUICtrlListView_GetItemText($hAutoIt, $Data, 6) If $Data Then _WinAPI_ShellOpenFolderAndSelectItems($Data) ;~ If @error Then ;~ EndIf EndIf EndIf Case $Dummy[5] $Data = _GUICtrlListView_GetSelectedIndices($hAutoIt) If $Data Then $Data = _GUICtrlListView_GetItemText($hAutoIt, $Data, 1) If $Data Then If _ShellKillProcess($Data, $hForm) Then _SetAutoItInfo() EndIf EndIf EndIf Case $Dummy[6] _GUICtrlTab_ClickTab($hTab, 3) _SetAutoItInfo() Case $Combo[0] $Data = _GUICtrlComboBox_GetCurSel($Combo[0]) If $Data <> $_Position Then $_Position = $Data For $i = 0 To 1 GUICtrlSetData($Input[$i], '') Next EndIf Case $Combo[1] $Data = _GUICtrlComboBox_GetCurSel($Combo[1]) If $Data <> $_Color Then $_Color = $Data $Data = GUICtrlRead($Input[2]) If $Data Then GUICtrlSetData($Input[2], '0x' & Hex(_WinAPI_SwitchColor(Number($Data)), 6)) EndIf EndIf Case $Label[1] $Data = _ColorChooser_Dialog(0, $_Rgb[0], $hForm, 0, 0, BitOR($CC_FLAG_SOLIDCOLOR, $CC_FLAG_CAPTURECOLOR)) If ($Data <> -1) And ($Data <> $_Rgb[0]) Then $_Rgb[0] = $Data GUICtrlSetBkColor($Label[1], $Data) ;~ If True Then _WinAPI_InvalidateRect($hListView) ;~ EndIf If $_Tab = 3 Then _WinAPI_InvalidateRect($hAutoIt) EndIf EndIf Case $Label[2] $Data = _ColorChooser_Dialog(1, $_Rgb[1], $hForm, 0, 0, BitOR($CC_FLAG_SOLIDCOLOR, $CC_FLAG_CAPTURECOLOR)) If ($Data <> -1) And ($Data <> $_Rgb[1]) Then $_Rgb[1] = $Data GUICtrlSetBkColor($Label[2], $Data) _GUICreate_Aux1() ;~ If True Then _WinAPI_InvalidateRect($hListView) ;~ EndIf If $_Tab = 3 Then _WinAPI_InvalidateRect($hAutoIt) EndIf EndIf Case $Label[3] $Data = _ColorChooser_Dialog(2, $_Rgb[2], $hForm, 0, 0, BitOR($CC_FLAG_SOLIDCOLOR, $CC_FLAG_CAPTURECOLOR)) If ($Data <> -1) And ($Data <> $_Rgb[2]) Then $_Rgb[2] = $Data GUICtrlSetBkColor($Label[3], $Data) _GUICreate_Aux1() ;~ If True Then _WinAPI_InvalidateRect($hListView) ;~ EndIf If $_Tab = 3 Then _WinAPI_InvalidateRect($hAutoIt) EndIf EndIf Case $Menu[1] ; "Copy To Clipboard" $Data = _CreateReport() If $Data Then ClipPut($Data) EndIf Case $Menu[2] ; "Save As..." If Not _ShellReportDlg($hForm) Then MsgBox(16, $GUI_NAME, 'Unable to save report.', 0, $hForm) EndIf Case $Menu[3] ; "Exit" GUIDelete() _FMIPC_Close() Exit Case $Menu[22] ShellExecute(@ScriptDir) Case $Menu[24] _TaskSched_FromGui(2) Case $Menu[25] _TaskSched_FromGui(1) Case $Menu[26] _EleDeElevate() Case $Menu[4] ; "Always On Top" $_Top = _NotInt($_Top) If $_Top Then GUICtrlSetState($Menu[4], $GUI_CHECKED) Else GUICtrlSetState($Menu[4], $GUI_UNCHECKED) EndIf WinSetOnTop($hForm, '', $_Top) Case $Menu[27] ; "Use Coloring" $_ColoringCtrls = _NotInt($_ColoringCtrls) If $_ColoringCtrls Then GUICtrlSetState($Menu[27], $GUI_CHECKED) Else GUICtrlSetState($Menu[27], $GUI_UNCHECKED) EndIf GUIDelete() _FMIPC_Close() ShellExecute(@ScriptFullPath) Exit 0 Case $Menu[5] ; "Crosshair" $_Crosshair = _NotInt($_Crosshair) If $_Crosshair Then GUICtrlSetState($Menu[5], $GUI_CHECKED) Else GUICtrlSetState($Menu[5], $GUI_UNCHECKED) EndIf GUICtrlSetBkColor($Label[0], _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE))) GUICtrlSetData($Input[2], '') _SetBitmap($hPic[0], 0) Case $Menu[6] ; "Capture While Tracking" $_Capture = _NotInt($_Capture) If $_Capture Then GUICtrlSetState($Menu[6], $GUI_CHECKED) Else GUICtrlSetState($Menu[6], $GUI_UNCHECKED) EndIf Case $Menu[20] $_All = _NotInt($_All) If $_All Then GUICtrlSetState($Menu[20], $GUI_CHECKED) GUICtrlSetState($Menu[21], $GUI_ENABLE) Else GUICtrlSetState($Menu[20], $GUI_UNCHECKED) GUICtrlSetState($Menu[21], $GUI_DISABLE) EndIf _SetAutoItInfo() Case $Menu[21] $_AllJustAutoItv3 = _NotInt($_AllJustAutoItv3) If $_AllJustAutoItv3 Then GUICtrlSetState($Menu[21], $GUI_CHECKED) Else GUICtrlSetState($Menu[21], $GUI_UNCHECKED) EndIf _SetAutoItInfo() Case $Menu[7], $Menu[8], $Menu[9], $Menu[10] ; "ANSI", "Unicode", "Unicode (Big Endian)", "UTF8" If BitAND(GUICtrlRead($Msg), $GUI_CHECKED) Then ContinueLoop EndIf _SetData($Input[30], '') For $i = 7 To 10 GUICtrlSetState($Menu[$i], $GUI_UNCHECKED) Next Switch $Msg Case $Menu[7] $_Code = 0 Case $Menu[8] $_Code = 1 Case $Menu[9] $_Code = 2 Case $Menu[10] $_Code = 3 EndSwitch GUICtrlSetState($Msg, $GUI_CHECKED) Case $g_ctrl_CloneGui[6], $g_ctrl_CloneGui[7], $g_ctrl_CloneGui[8] For $i = 6 To 8 GUICtrlSetState($g_ctrl_CloneGui[$i], $GUI_UNCHECKED) Next Switch $Msg Case $g_ctrl_CloneGui[6] $_CloneGui = 0 Case $g_ctrl_CloneGui[8] $_CloneGui = 2 Case $g_ctrl_CloneGui[7] $_CloneGui = 1 EndSwitch ConsoleWrite('- $_CloneGui = ' & $_CloneGui & @CRLF) GUICtrlSetState($Msg, $GUI_CHECKED) Case $g_ctrl_CloneGui[9] If $_CloneEditGuiFile Then $_CloneEditGuiFile = 0 GUICtrlSetState($g_ctrl_CloneGui[9], $GUI_UNCHECKED) Else $_CloneEditGuiFile = 1 GUICtrlSetState($g_ctrl_CloneGui[9], $GUI_CHECKED) EndIf ConsoleWrite('- $_CloneEditGuiFile = ' & $_CloneEditGuiFile & @CRLF) Case $Menu[8] ; "Unicode" _SetData($Input[30], '') $_Code = 1 Case $Menu[9] ; "Unicode (Big Endian)" _SetData($Input[30], '') $_Code = 2 Case $Menu[10] ; "UTF8" _SetData($Input[30], '') $_Code = 3 Case $Menu[11] ; "Highlight Controls" _ShowFrame(0) $_Highlight = _NotInt($_Highlight) If $_Highlight Then GUICtrlSetState($Menu[11], $GUI_CHECKED) GUICtrlSetState($Menu[12], $GUI_ENABLE) GUICtrlSetState($Menu[17], $GUI_ENABLE) GUICtrlSetState($Menu[18], $GUI_ENABLE) Else GUICtrlSetState($Menu[11], $GUI_UNCHECKED) GUICtrlSetState($Menu[12], $GUI_DISABLE) GUICtrlSetState($Menu[17], $GUI_DISABLE) GUICtrlSetState($Menu[18], $GUI_DISABLE) EndIf Case $Menu[13], $Menu[14], $Menu[15], $Menu[16] ; "25%", "50%", 75%", "100%" ;~ If BitAND(GUICtrlRead($Msg), $GUI_CHECKED) Then ContinueLoop ; this was not working ; v0.2018.12.18 _ShowFrame(0) For $i = 13 To 16 GUICtrlSetState($Menu[$i], $GUI_UNCHECKED) Next Switch $Msg Case $Menu[13] $_Alpha = 64 Case $Menu[14] $_Alpha = 128 Case $Menu[15] $_Alpha = 192 Case $Menu[16] $_Alpha = 255 EndSwitch GUICtrlSetState($Msg, $GUI_CHECKED) Case $Menu[17] ; "Fade In" $_Fade = _NotInt($_Fade) If $_Fade Then GUICtrlSetState($Menu[17], $GUI_CHECKED) Else GUICtrlSetState($Menu[17], $GUI_UNCHECKED) EndIf Case $Menu[18] ; "Color..." _ShowFrame(0) $Data = _ColorChooser_Dialog(100, $_Frame, $hForm, 0, 0, BitOR($CC_FLAG_SOLIDCOLOR, $CC_FLAG_CAPTURECOLOR)) If ($Data <> -1) And ($Data <> $_Frame) Then $_Frame = $Data EndIf Case $Menu[19] ; "About..." _ShellAboutDlg($hForm) Case $Accel[0][1] ; Ctrl+A _HK_SelectAll() Case $Accel[2][1] ; Ctrl+Alt+T _SendMessage($hForm, $WM_COMMAND, $Menu[4], 0) Case $Accel[3][1] ; Ctrl+Alt+H _SendMessage($hForm, $WM_COMMAND, $Menu[11], 0) Case $Accel[7][1] ; Ctrl+Alt+C _SendMessage($hForm, $WM_COMMAND, $Menu[27], 0) Case $Accel[4][1] _HK_Edit() Case $Tab GUICtrlSetState($Tab, $GUI_FOCUS) EndSwitch WEnd #EndRegion Body #Region Additional Functions Func _ColorChooser_Dialog($iElement, $iColor = 0, $hParent = 0, $iRefType = 0, $iReturnType = 0, $iFlags = -1, $sTitle = 'Color') If $iElement < 6 Then Local $i, $a[6] = ['Visible', 'Hidden', 'Missing','???','???','???'] Local $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_AddMenuItem($hMenu, Chr(160) & "Cancel " & $a[$iElement] & ' color change', 1000) _GUICtrlMenu_AddMenuItem($hMenu, "", 0) _GUICtrlMenu_AddMenuItem($hMenu, Chr(160) & "Use system color", 1001) _GUICtrlMenu_SetItemBmp($hMenu, 2, _WinAPI_CreateSolidBitmap($hParent, _WinAPI_GetSysColor($_Rgb[$iElement + 6]), 14, 14)) _GUICtrlMenu_AddMenuItem($hMenu, "", 0) _GUICtrlMenu_AddMenuItem($hMenu, Chr(160) & "Choose a color", 1002) $i = _GUICtrlMenu_TrackPopupMenu($hMenu, $hParent, MouseGetPos(0) + 30, MouseGetPos(1) - 20, 1, 1, 2) _GUICtrlMenu_DestroyMenu($hMenu) Switch $i Case 1001 $_Rgb[$iElement + 3] = 1 Return _WinAPI_GetSysColor($_Rgb[$iElement + 6]) Case 1002 $_Rgb[$iElement + 3] = 0 ; ..use _ChooseColor() Case Else Return -1 EndSwitch EndIf If @AutoItX64 Then Return _ChooseColor(2, $iColor, 2, $hParent) Else Return _ColorChooserDialog($iColor, $hParent, $iRefType, $iReturnType, $iFlags, $sTitle) EndIf EndFunc ;==>_ColorChooser_Dialog Func _NotInt($v) If $v Then Return 0 Return 1 EndFunc ;==>_NotInt Func _FMIPC_ReadSlower() Local Static $t = TimerInit() If TimerDiff($t) < 150 Then Return $t = TimerInit() If "DoSelfShow" = _FMIPC_Read() Then Emergency_Tray_ShowGui() EndFunc Func _About() ;~ If Not RegRead($REG_KEY_NAME, 'About') Then ; has no practical use, commented out ;~ RegWrite($REG_KEY_NAME, 'About', 'REG_DWORD', 1) ;~ If True Then _ShellAboutDlg() ;~ EndIf ;~ EndIf EndFunc ;==>_About Func _ApplicationCheck() ConsoleWrite('+ Func _ApplicationCheck()' & @CRLF) Local $hWnd = WinGetHandle($GUI_UNIQUE) ConsoleWrite('$hWnd = ' & $hWnd & @CRLF) If Not $hWnd Then AutoItWinSetTitle($GUI_UNIQUE) Return EndIf Local $PID, $List $PID = WinGetProcess($hWnd) If $PID > -1 Then $List = _WinAPI_EnumProcessWindows($PID, 0) If Not IsArray($List) Then Exit EndIf EndIf For $i = 1 To $List[0][0] If WinGetTitle($List[$i][0]) = $GUI_NAME & ChrW(160) Then If BitAND(WinGetState($List[$i][0]), 4) Then _SendMessage($List[$i][0], $WM_MYMSG, 12321, 0) WinActivate($List[$i][0]) Else For $j = 1 To $List[0][0] If (WinGetTitle($List[$j][0])) And (_WinAPI_GetAncestor($List[$j][0], $GA_ROOTOWNER) = $List[$i][0]) Then WinActivate($List[$j][0]) ExitLoop EndIf Next EndIf ExitLoop EndIf Next Exit EndFunc ;==>_ApplicationCheck Func _Capture_X1($iX, $iY, $iWidth, $iHeight, $iColCrop, $iColFill = 0, $fCapture = 0, $fDib = 1, $hDesktop = 0) Local $hDC, $hSrcDC, $hDstDC, $hGraphics, $hCrop, $hScreen = 0, $hPen, $hBrush, $hBitmap, $tRect, $tData Local $W = $iWidth + 10, $H = $iHeight + 10, $Xc = Floor($W / 2), $Yc = Floor($H / 2) If $fCapture Then If $hDesktop Then $hDC = _WinAPI_GetDC(0) $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) _WinAPI_SelectObject($hSrcDC, $hDesktop) $hDstDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) _WinAPI_SelectObject($hDstDC, $hBitmap) _WinAPI_BitBlt($hDstDC, 0, 0, $iWidth, $iHeight, $hSrcDC, $iX, $iY, $SRCCOPY) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteDC($hDstDC) Else $hDesktop = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hDesktop) $hDstDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) _WinAPI_SelectObject($hDstDC, $hBitmap) _WinAPI_BitBlt($hDstDC, 0, 0, $iWidth, $iHeight, $hDC, $iX, $iY, $SRCCOPY) $hBrush = _WinAPI_CreateSolidBrush(0) $tRect = _WinAPI_GetWindowRect($hPic[0]) _WinAPI_OffsetRect($tRect, -$iX, -$iY) _WinAPI_FillRect($hDstDC, DllStructGetPtr($tRect), $hBrush) If $_Tab = 2 Then $tRect = _WinAPI_GetWindowRect($hPic[1]) _WinAPI_OffsetRect($tRect, -$iX, -$iY) _WinAPI_FillRect($hDstDC, DllStructGetPtr($tRect), $hBrush) EndIf _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hDesktop, $hDC) _WinAPI_DeleteDC($hDstDC) EndIf $hScreen = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) _WinAPI_DeleteObject($hBitmap) EndIf $hBitmap = _GDIPlus_BitmapCreateFromScan0($W, $H) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;~ _GDIPlus_GraphicsClear($hGraphics, 0) $hPen = _GDIPlus_PenCreate($iColCrop) _GDIPlus_GraphicsDrawRect($hGraphics, 0, 0, 4, 4, $hPen) _GDIPlus_GraphicsDrawRect($hGraphics, $Xc - 2, 0, 4, 4, $hPen) _GDIPlus_GraphicsDrawRect($hGraphics, $W - 5, 0, 4, 4, $hPen) _GDIPlus_GraphicsDrawRect($hGraphics, $W - 5, $Yc - 2, 4, 4, $hPen) _GDIPlus_GraphicsDrawRect($hGraphics, $W - 5, $H - 5, 4, 4, $hPen) _GDIPlus_GraphicsDrawRect($hGraphics, $Xc - 2, $H - 5, 4, 4, $hPen) _GDIPlus_GraphicsDrawRect($hGraphics, 0, $H - 5, 4, 4, $hPen) _GDIPlus_GraphicsDrawRect($hGraphics, 0, $Yc - 2, 4, 4, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, 5, 2, $Xc - 3, 2, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, $Xc + 3, 2, $W - 6, 2, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, $W - 3, 5, $W - 3, $Yc - 3, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, $W - 3, $Yc + 3, $W - 3, $H - 6, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, $W - 6, $H - 3, $Xc + 3, $H - 3, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, $Xc - 3, $H - 3, 5, $H - 3, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, 2, $H - 6, 2, $Yc + 3, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, 2, $Yc - 3, 2, 5, $hPen) _GDIPlus_PenDispose($hPen) If $fCapture Then _GDIPlus_GraphicsDrawImageRect($hGraphics, $hScreen, 5, 5, $iWidth, $iHeight) _GDIPlus_ImageDispose($hScreen) Else If $iColFill Then $hBrush = _GDIPlus_BrushCreateSolid($iColFill) _GDIPlus_GraphicsFillRect($hGraphics, 5, 5, $iWidth, $iHeight, $hBrush) _GDIPlus_BrushDispose($hBrush) EndIf EndIf _GDIPlus_GraphicsDispose($hGraphics) If $fDib Then $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $W, $H, $GDIP_ILMREAD, $GDIP_PXF32ARGB) $hCrop = _WinAPI_CreateDIB($W, $H) _WinAPI_SetBitmapBits($hCrop, $W * $H * 4, DllStructGetData($tData, 'Scan0')) _GDIPlus_BitmapUnlockBits($hBitmap, $tData) Else $hCrop = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) EndIf _GDIPlus_ImageDispose($hBitmap) If $hCrop Then Return SetError(0, 0, $hCrop) Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_Capture_X1 Func _Capture_X3($iX, $iY, $iSrcWidth, $iSrcHeight, $iDstWidth, $iDstHeight) Local $hDC, $hSrcDC, $hDstDC, $hDesktop, $hGraphics, $hBrush, $hImage, $hBitmap, $hScreen, $Rgb, $hPen = 0 Local $Xc = Floor($iDstWidth / 2), $Yc = Floor($iDstHeight / 2) $hDesktop = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hDesktop) $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) $hScreen = _WinAPI_CreateCompatibleBitmap($hDC, $iSrcWidth, $iSrcHeight) _WinAPI_SelectObject($hSrcDC, $hScreen) _WinAPI_BitBlt($hSrcDC, 0, 0, $iSrcWidth, $iSrcHeight, $hDC, $iX, $iY, $SRCCOPY) $hBrush = _WinAPI_CreateSolidBrush(0) $tRect = _WinAPI_GetWindowRect($hPic[0]) _WinAPI_OffsetRect($tRect, -$iX, -$iY) _WinAPI_FillRect($hSrcDC, DllStructGetPtr($tRect), $hBrush) If $_Tab = 2 Then $tRect = _WinAPI_GetWindowRect($hPic[1]) _WinAPI_OffsetRect($tRect, -$iX, -$iY) _WinAPI_FillRect($hSrcDC, DllStructGetPtr($tRect), $hBrush) EndIf _WinAPI_DeleteObject($hBrush) $hDstDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iDstWidth, $iDstHeight) _WinAPI_SelectObject($hDstDC, $hBitmap) _WinAPI_SetStretchBltMode($hDstDC, $STRETCH_DELETESCANS) _WinAPI_StretchBlt($hDstDC, 0, 0, $iDstWidth, $iDstHeight, $hSrcDC, 0, 0, $iSrcWidth, $iSrcHeight, $SRCCOPY) _WinAPI_ReleaseDC($hDesktop, $hDC) _WinAPI_DeleteDC($hDstDC) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hScreen) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) _WinAPI_DeleteObject($hBitmap) $Rgb = BitAND(_GDIPlus_BitmapGetPixel($hImage, $Xc, $Yc), 0x00FFFFFF) If $_Crosshair Then For $y = $Yc - 3 To $Yc + 3 Step 3 For $x = $Xc - 3 To $Xc + 3 Step 3 If (($Xc <> $x) Or ($Yc <> $y)) And (Not _IsDark(_GDIPlus_BitmapGetPixel($hImage, $x, $y))) Then $hPen = _GDIPlus_PenCreate() ExitLoop 2 EndIf Next Next If Not $hPen Then $hPen = _GDIPlus_PenCreate(0xFFFFFFFF) EndIf $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage) _GDIPlus_GraphicsDrawLine($hGraphics, 0, $Yc, $Xc - 3, $Yc, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, $Xc + 3, $Yc, $iDstWidth, $Yc, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, $Xc, 0, $Xc, $Yc - 3, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, $Xc, $Yc + 3, $Xc, $iDstHeight, $hPen) _GDIPlus_GraphicsDrawRect($hGraphics, $Xc - 2, $Yc - 2, 4, 4, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphics) EndIf $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) If $hBitmap Then Return SetError(0, $Rgb, $hBitmap) Else Return SetError(1, -1, 0) EndIf EndFunc ;==>_Capture_X3 Func _Capture_Desktop() Local $hDC, $hMemDC, $hDesktop, $hBrush, $hBitmap, $tRect $hDesktop = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hDesktop) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, @DesktopWidth, @DesktopHeight) _WinAPI_SelectObject($hMemDC, $hBitmap) _WinAPI_BitBlt($hMemDC, 0, 0, @DesktopWidth, @DesktopHeight, $hDC, 0, 0, $SRCCOPY) $hBrush = _WinAPI_CreateSolidBrush(0) $tRect = _WinAPI_GetWindowRect($hPic[0]) _WinAPI_FillRect($hMemDC, DllStructGetPtr($tRect), $hBrush) If $_Tab = 2 Then $tRect = _WinAPI_GetWindowRect($hPic[1]) _WinAPI_FillRect($hMemDC, DllStructGetPtr($tRect), $hBrush) EndIf _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hDesktop, $hDC) _WinAPI_DeleteDC($hMemDC) If $hBitmap Then Return SetError(0, 0, $hBitmap) Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_Capture_Desktop Func _CreateReport() Local $Data[2], $Text = '' $Text &= '###AutoIt Control Viewer Report File###' & @CRLF $Text &= @CRLF $Text &= 'Environment' & @CRLF $Text &= '===========' & @CRLF $Text &= StringStripWS('System: ' & _OSVersion(), 2) & @CRLF $Text &= 'Aero: ' If _WinAPI_GetVersion() >= 6.0 Then If _WinAPI_DwmIsCompositionEnabled() Then $Text &= 'Enabled' Else $Text &= 'Disabled' EndIf EndIf $Text &= @CRLF $Text &= @CRLF $Text &= 'Window' & @CRLF $Text &= '======' & @CRLF $Text &= StringStripWS('Title: ' & GUICtrlRead($Input[3]), 2) & @CRLF $Text &= StringStripWS('Class: ' & GUICtrlRead($Input[4]), 2) & @CRLF $Text &= StringStripWS('Style: ' & GUICtrlRead($Input[5]), 2) & @CRLF $Text &= StringStripWS('ExStyle: ' & GUICtrlRead($Input[7]), 2) & @CRLF $Text &= 'Position: ' For $i = 0 To 1 $Data[$i] = GUICtrlRead($Input[9 + $i]) Next If ($Data[0]) And ($Data[1]) Then $Text &= $Data[0] & ', ' & $Data[1] EndIf $Text = StringStripWS($Text, 2) $Text &= @CRLF $Text &= 'Size: ' For $i = 0 To 1 $Data[$i] = GUICtrlRead($Input[11 + $i]) Next If ($Data[0]) And ($Data[1]) Then $Text &= $Data[0] & ', ' & $Data[1] EndIf $Text = StringStripWS($Text, 2) $Text &= @CRLF $Text &= StringStripWS('Handle: ' & GUICtrlRead($Input[13]), 2) & @CRLF $Text &= StringStripWS('PID: ' & GUICtrlRead($Input[14]), 2) & @CRLF $Text &= StringStripWS('Path: ' & GUICtrlRead($Input[15]), 2) & @CRLF $Text &= @CRLF $Text &= 'Control' & @CRLF $Text &= '=======' & @CRLF $Text &= StringStripWS('Class: ' & GUICtrlRead($Input[16]), 2) & @CRLF $Text &= StringStripWS('Instance: ' & GUICtrlRead($Input[17]), 2) & @CRLF $Text &= StringStripWS('ID: ' & GUICtrlRead($Input[19]), 2) & @CRLF $Text &= StringStripWS('Style: ' & GUICtrlRead($Input[21]), 2) & @CRLF $Text &= StringStripWS('ExStyle: ' & GUICtrlRead($Input[23]), 2) & @CRLF $Text &= 'Position: ' For $i = 0 To 1 $Data[$i] = GUICtrlRead($Input[25 + $i]) Next If ($Data[0]) And ($Data[1]) Then $Text &= $Data[0] & ', ' & $Data[1] EndIf $Text = StringStripWS($Text, 2) $Text &= @CRLF $Text &= 'Size: ' For $i = 0 To 1 $Data[$i] = GUICtrlRead($Input[27 + $i]) Next If ($Data[0]) And ($Data[1]) Then $Text &= $Data[0] & ', ' & $Data[1] EndIf $Text = StringStripWS($Text, 2) $Text &= @CRLF $Text &= StringStripWS('Handle: ' & GUICtrlRead($Input[29]), 2) & @CRLF $Text &= StringStripWS('Text: ' & GUICtrlRead($Input[30]), 2) & @CRLF Return $Text EndFunc ;==>_CreateReport Func _GetCursor(ByRef $iX, ByRef $iY, $hWnd = 0) ;~ $hWnd = _HWnd($hWnd) ;~ If Not $hWnd Then ;~ Return ;~ EndIf Local $tPoint = _WinAPI_GetMousePos($hWnd, $hWnd) If @error Then Return SetError(1, 0, 0) EndIf $iX = DllStructGetData($tPoint, 1) $iY = DllStructGetData($tPoint, 2) Return 1 EndFunc ;==>_GetCursor Func _GetNN($hWnd) Local $List, $Text, $ID = 0 $Text = _WinAPI_GetClassName($hWnd) If Not $Text Then Return -1 EndIf $List = _WinAPI_EnumChildWindows(_WinAPI_GetAncestor($hWnd, $GA_ROOT), 0) If @error Then Return -1 EndIf For $i = 1 To $List[0][0] If $List[$i][1] = $Text Then $ID += 1 EndIf If $List[$i][0] = $hWnd Then ExitLoop EndIf Next If Not $ID Then Return -1 EndIf Return $ID EndFunc ;==>_GetNN Func hListView_AUTOSIZE_USEHEADER() For $i = 0 To 3 _GUICtrlListView_SetColumnWidth($hListView, $i, $LVSCW_AUTOSIZE_USEHEADER) Next EndFunc ;==>hListView_AUTOSIZE_USEHEADER Func _GetStyleString($iStyle, $fDialog = 1, $fExStyle = 0) Local $Data, $Text = '' If $fExStyle Then $Data = $ExStyle Else $Data = $Style EndIf For $i = 0 To UBound($Data) - 1 If BitAND($iStyle, $Data[$i][0]) Then If (Not BitAND($Data[$i][0], 0xFFFF)) Or ($fDialog) Or ($fExStyle) Then $iStyle = BitAND($iStyle, BitNOT($Data[$i][0])) $Text &= $Data[$i][1] & ', ' EndIf EndIf Next If $iStyle Then $Text = '0x' & Hex($iStyle, 8) & ', ' & $Text EndIf Return StringRegExpReplace($Text, ',\s\z', '') EndFunc ;==>_GetStyleString Func _GUICreate() Local $Style = BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY, $WS_TABSTOP) Local $ID, $tData, $hIcon, $hImageList Local $Height = $_Height - 653 $_SM_CYMENU = _WinAPI_GetSystemMetrics($SM_CYMENU) $_SM_CXSIZEFRAME = _WinAPI_GetSystemMetrics($SM_CXSIZEFRAME) ; Main Window $hForm = GUICreate($GUI_NAME & (@AutoItX64 ? " (x64)" : "" ) & ChrW(160), 421, $_Height + $_SM_CYMENU, $a_ProgmanPos[2], $a_ProgmanPos[3], BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX), $WS_EX_TOPMOST * $_Top) $hSizebox = _WinAPI_CreateWindowEx(0, "Scrollbar", "", $WS_CHILD + $WS_VISIBLE + $SBS_SIZEBOX, 300 - 15, 200 - 15, 15, 15, $hForm) ; $SBS_SIZEBOX or $SBS_SIZEGRIP ; Menu $ID = GUICtrlCreateMenu('&File') $Menu[0] = GUICtrlCreateMenu('&Report', $ID) GUICtrlSetState(-1, $GUI_DISABLE) $Menu[1] = GUICtrlCreateMenuItem('&Copy To Clipboard', $Menu[0]) $Menu[2] = GUICtrlCreateMenuItem('Save &As...', $Menu[0]) GUICtrlCreateMenuItem('', $ID) $Menu[22] = GUICtrlCreateMenuItem('&Browse self folder', $ID) GUICtrlCreateMenuItem('', $ID) $Menu[23] = GUICtrlCreateMenu('&TaskSched:', $ID) $Menu[24] = GUICtrlCreateMenuItem('Add on Logon', $Menu[23]) $Menu[25] = GUICtrlCreateMenuItem('Add on demand', $Menu[23]) GUICtrlCreateMenuItem('', $ID) $Menu[26] = GUICtrlCreateMenuItem('Elevate', $ID) If IsAdmin() Then GUICtrlSetData($Menu[26], 'DeElevate') GUICtrlCreateMenuItem('', $ID) _TaskSched_ForGui() $Menu[3] = GUICtrlCreateMenuItem('E&xit', $ID) $ID = GUICtrlCreateMenu('&Options') $Menu[4] = GUICtrlCreateMenuItem('&Always On Top' & @TAB & 'Ctrl+Alt+T', $ID) If $_Top Then GUICtrlSetState(-1, $GUI_CHECKED) EndIf $Menu[27] = GUICtrlCreateMenuItem('&Use Ctrl coloring' & @TAB & 'Ctrl+Alt+C', $ID) If $_ColoringCtrls Then GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateMenuItem('', $ID) $Menu[5] = GUICtrlCreateMenuItem('C&rosshair', $ID) If $_Crosshair Then GUICtrlSetState(-1, $GUI_CHECKED) EndIf $Menu[6] = GUICtrlCreateMenuItem('Capture While &Tracking', $ID) If $_Capture Then GUICtrlSetState(-1, $GUI_CHECKED) EndIf GUICtrlCreateMenuItem('', $ID) $Menu[20] = GUICtrlCreateMenuItem('Show All', $ID) If $_All Then GUICtrlSetState(-1, $GUI_CHECKED) EndIf $Menu[21] = GUICtrlCreateMenuItem('Just "AutoIt v3"', $ID) If $_AllJustAutoItv3 Then GUICtrlSetState($Menu[21], $GUI_CHECKED) If Not $_All Then GUICtrlSetState($Menu[21], $GUI_DISABLE) GUICtrlCreateMenuItem('', $ID) $Menu[10] = GUICtrlCreateMenu('Text &Encoding', $ID) $Menu[7] = GUICtrlCreateMenuItem('ANSI', $Menu[10], Default, 1) $Menu[8] = GUICtrlCreateMenuItem('Unicode', $Menu[10], Default, 1) $Menu[9] = GUICtrlCreateMenuItem('Unicode (Big Endian)', $Menu[10], Default, 1) $Menu[10] = GUICtrlCreateMenuItem('UTF8', $Menu[10], Default, 1) Switch $_Code Case 0 GUICtrlSetState($Menu[7], $GUI_CHECKED) Case 1 GUICtrlSetState($Menu[8], $GUI_CHECKED) Case 2 GUICtrlSetState($Menu[9], $GUI_CHECKED) Case 3 GUICtrlSetState($Menu[10], $GUI_CHECKED) EndSwitch $Menu[18] = GUICtrlCreateMenu('&Highlight', $ID) $Menu[11] = GUICtrlCreateMenuItem('&Highlight Controls' & @TAB & 'Ctrl+Alt+H', $Menu[18]) If $_Highlight Then GUICtrlSetState(-1, $GUI_CHECKED) EndIf GUICtrlCreateMenuItem('', $Menu[18]) $Menu[12] = GUICtrlCreateMenu('&Transparency', $Menu[18]) If $_Highlight Then GUICtrlSetState(-1, $GUI_ENABLE) Else GUICtrlSetState(-1, $GUI_DISABLE) EndIf $Menu[13] = GUICtrlCreateMenuItem('25%', $Menu[12], Default, 1) $Menu[14] = GUICtrlCreateMenuItem('50%', $Menu[12], Default, 1) $Menu[15] = GUICtrlCreateMenuItem('75%', $Menu[12], Default, 1) $Menu[16] = GUICtrlCreateMenuItem('Opaque', $Menu[12], Default, 1) Switch $_Alpha Case 64 GUICtrlSetState($Menu[13], $GUI_CHECKED) Case 128 GUICtrlSetState($Menu[14], $GUI_CHECKED) Case 192 GUICtrlSetState($Menu[15], $GUI_CHECKED) Case 255 GUICtrlSetState($Menu[16], $GUI_CHECKED) EndSwitch $Menu[17] = GUICtrlCreateMenuItem('&Fade In', $Menu[18]) If $_Highlight Then GUICtrlSetState(-1, BitOR($GUI_CHECKED * $_Fade, $GUI_UNCHECKED * (Not $_Fade), $GUI_ENABLE)) Else GUICtrlSetState(-1, BitOR($GUI_CHECKED * $_Fade, $GUI_UNCHECKED * (Not $_Fade), $GUI_DISABLE)) EndIf $Menu[18] = GUICtrlCreateMenuItem('&Color...', $Menu[18]) If $_Highlight Then GUICtrlSetState(-1, $GUI_ENABLE) Else GUICtrlSetState(-1, $GUI_DISABLE) EndIf GUICtrlCreateMenuItem('', $ID) $g_ctrl_CloneGui[5] = GUICtrlCreateMenu('Clone&GUI', $ID) $g_ctrl_CloneGui[6] = GUICtrlCreateMenuItem('Copy to clipboard', $g_ctrl_CloneGui[5], Default, 1) $g_ctrl_CloneGui[7] = GUICtrlCreateMenuItem('Save to MyDocuments', $g_ctrl_CloneGui[5], Default, 1) $g_ctrl_CloneGui[8] = GUICtrlCreateMenuItem('Ask to "save as" filename', $g_ctrl_CloneGui[5], Default, 1) Switch $_CloneGui Case 0 GUICtrlSetState($g_ctrl_CloneGui[6], $GUI_CHECKED) Case 2 GUICtrlSetState($g_ctrl_CloneGui[8], $GUI_CHECKED) Case Else GUICtrlSetState($g_ctrl_CloneGui[7], $GUI_CHECKED) EndSwitch ConsoleWrite('- $_CloneGui = ' & $_CloneGui & @CRLF) GUICtrlCreateMenuItem('', $g_ctrl_CloneGui[5]) $g_ctrl_CloneGui[9] = GUICtrlCreateMenuItem('Edit file after save', $g_ctrl_CloneGui[5]) If $_CloneEditGuiFile Then GUICtrlSetState($g_ctrl_CloneGui[9], $GUI_CHECKED) $ID = GUICtrlCreateMenu('&Help') $Menu[19] = GUICtrlCreateMenuItem('&About...', $ID) For $i = 0 To UBound($Dummy) - 1 $Dummy[$i] = GUICtrlCreateDummy() Next ; Color Picker Group GUICtrlCreateGroup('Color Picker', 10, 7, 293, 104) GUICtrlCreatePic('', 22, 28, 71, 71, BitOR($GUI_SS_DEFAULT_PIC, $SS_SUNKEN)) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreatePic('', 23, 29, 69, 69) GUICtrlSetState(-1, $GUI_DISABLE) $hPic[0] = GUICtrlGetHandle(-1) GUICtrlCreate_Label('X, Y:', 103, 32, 29, 14) $Input[0] = GUICtrlCreateInput('', 133, 29, 36, 19, $Style) $Input[1] = GUICtrlCreateInput('', 177, 29, 36, 19, $Style) $Combo[0] = GUICtrlCreateCombo('', 223, 28, 68, 21, $CBS_DROPDOWNLIST) _GUICtrlComboBox_AddString(-1, 'Absolute') _GUICtrlComboBox_AddString(-1, 'Window') _GUICtrlComboBox_AddString(-1, 'Client') _GUICtrlComboBox_AddString(-1, 'Control') _GUICtrlComboBox_SetCurSel(-1, $_Position) GUICtrlCreate_Label('Color:', 103, 57, 29, 14) $Input[2] = GUICtrlCreateInput('', 133, 54, 80, 19, $Style) $Combo[1] = GUICtrlCreateCombo('', 223, 53, 50, 21, $CBS_DROPDOWNLIST) _GUICtrlComboBox_AddString(-1, 'RGB') _GUICtrlComboBox_AddString(-1, 'BGR') _GUICtrlComboBox_SetCurSel(-1, $_Color) GUICtrlCreate_Label('Solid:', 103, 82, 29, 14) $Label[0] = GUICtrlCreateLabel('', 133, 79, 19, 19, $SS_SUNKEN) ; Browse Tool Group GUICtrlCreateGroup('Browse Tool', 313, 7, 98, 104) $Icon[0] = GUICtrlCreateIcon('', 0, 330, 30, 64, 64) _SetStyle(-1, $WS_TABSTOP, 0) If Not @Compiled Then GUICtrlSetImage(-1, @ScriptDir & '\Resources\202.ico') Else GUICtrlSetImage(-1, @ScriptFullPath, 202) EndIf Local $Theme = _WinAPI_GetThemeAppProperties() _WinAPI_SetThemeAppProperties($STAP_ALLOW_NONCLIENT) ; Info Group If $_Icon Then $Tab = GUICtrlCreateTab(22, 136, 379, 273) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKHEIGHT, $GUI_DOCKRIGHT)) _GUICtrlTab_SetMinTabWidth(-1, 75) Else $Tab = GUICtrlCreateTab(22, 136, 379, 273, BitOR($GUI_SS_DEFAULT_TAB, $TCS_FIXEDWIDTH)) _GUICtrlTab_SetItemSize(-1, 64, 19) EndIf GUICtrlSetState(-1, $GUI_FOCUS) $hTab = GUICtrlGetHandle(-1) GUICtrlCreateTabItem('Window') GUICtrlCreate_Label('Title:', 33, 176, 46, 14) $Input[3] = GUICtrlCreateInput('', 80, 173, 308, 19, $Style) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKHEIGHT, $GUI_DOCKRIGHT)) GUICtrlCreate_Label('Class:', 33, 201, 46, 14) $Input[4] = GUICtrlCreateInput('', 80, 198, 308, 19, $Style) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKHEIGHT, $GUI_DOCKRIGHT)) GUICtrlCreate_Label('Style:', 33, 226, 46, 14) $Input[5] = GUICtrlCreateInput('', 80, 223, 80, 19, $Style) $Input[6] = GUICtrlCreateInput('', 168, 223, 220, 19, $Style) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKHEIGHT, $GUI_DOCKRIGHT)) ;~ GUICtrlSetColor(-1, 0xAA0000) GUICtrlCreate_Label('ExStyle:', 33, 251, 46, 14) $Input[7] = GUICtrlCreateInput('', 80, 248, 80, 19, $Style) $Input[8] = GUICtrlCreateInput('', 168, 248, 220, 19, $Style) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKHEIGHT, $GUI_DOCKRIGHT)) ;~ GUICtrlSetColor(-1, 0xAA0000) GUICtrlCreate_Label('Position:', 33, 276, 46, 14) $Input[9] = GUICtrlCreateInput('', 80, 273, 80, 19, $Style) $Input[10] = GUICtrlCreateInput('', 168, 273, 80, 19, $Style) GUICtrlCreate_Label('Size:', 33, 301, 46, 14) $Input[11] = GUICtrlCreateInput('', 80, 298, 80, 19, $Style) $Input[12] = GUICtrlCreateInput('', 168, 298, 80, 19, $Style) GUICtrlCreate_Label('Handle:', 33, 326, 46, 14) $Input[13] = GUICtrlCreateInput('', 80, 323, 168, 19, $Style) GUICtrlCreate_Label('PID:', 33, 351, 46, 14) $Input[14] = GUICtrlCreateInput('', 80, 348, 80, 19, $Style) GUICtrlCreate_Label('Visible Text:', 190, 351, 63, 14) $Input[31] = GUICtrlCreateEdit('', 255, 273, 133, 95) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKHEIGHT, $GUI_DOCKRIGHT)) GUICtrlCreate_Label('Path:', 33, 376, 46, 14) $Input[15] = GUICtrlCreateInput('', 80, 373, 289, 19, $Style) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKHEIGHT, $GUI_DOCKRIGHT)) $Icon[1] = GUICtrlCreateIcon('', 0, 373, 375, 15, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetTip(-1, 'Open file location') GUICtrlSetCursor(-1, 0) _SetStyle(-1, $WS_TABSTOP, 0) If Not @Compiled Then GUICtrlSetImage(-1, @ScriptDir & '\Resources\210.ico') Else GUICtrlSetImage(-1, @ScriptFullPath, 210) EndIf GUICtrlCreateTabItem('Control') GUICtrlCreate_Label('Class:', 33, 176, 46, 14) $Input[16] = GUICtrlCreateInput('', 80, 173, 308, 19, $Style) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKHEIGHT)) GUICtrlCreate_Label('Instance:', 33, 201, 46, 14) $Input[17] = GUICtrlCreateInput('', 80, 198, 80, 19, $Style) $Input[18] = GUICtrlCreateInput('', 168, 198, 220, 19, $Style) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKHEIGHT)) ;~ GUICtrlSetColor(-1, 0x9999CC) GUICtrlCreate_Label('ID:', 33, 226, 42, 14) $Input[19] = GUICtrlCreateInput('', 80, 223, 80, 19, $Style) $Input[20] = GUICtrlCreateInput('', 168, 223, 220, 19, $Style) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKHEIGHT)) ;~ GUICtrlSetColor(-1, 0x9999CC) GUICtrlCreate_Label('Style:', 33, 251, 42, 14) $Input[21] = GUICtrlCreateInput('', 80, 248, 80, 19, $Style) $Input[22] = GUICtrlCreateInput('', 168, 248, 220, 19, $Style) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKHEIGHT)) ;~ GUICtrlSetColor(-1, 0xAA0000) GUICtrlCreate_Label('ExStyle:', 33, 276, 42, 14) $Input[23] = GUICtrlCreateInput('', 80, 273, 80, 19, $Style) $Input[24] = GUICtrlCreateInput('', 168, 273, 220, 19, $Style) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKHEIGHT)) ;~ GUICtrlSetColor(-1, 0xAA0000) GUICtrlCreate_Label('Position:', 33, 301, 42, 14) $Input[25] = GUICtrlCreateInput('', 80, 298, 80, 19, $Style) $Input[26] = GUICtrlCreateInput('', 168, 298, 80, 19, $Style) GUICtrlCreate_Label('Size:', 33, 326, 42, 14) $Input[27] = GUICtrlCreateInput('', 80, 323, 80, 19, $Style) $Input[28] = GUICtrlCreateInput('', 168, 323, 80, 19, $Style) GUICtrlCreate_Label('Handle:', 263, 305, 42, 14) $Input[29] = GUICtrlCreateInput('', 263, 323, 125, 19, $Style) GUICtrlCreate_Label('Text:', 33, 376, 42, 14) $Input[30] = GUICtrlCreateEdit('', 80, 348, 308, 50) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKHEIGHT)) GUICtrlCreateTabItem('Capture') $Pic = GUICtrlCreatePic('', 36 + Floor((349 - $_Crop[0]) / 2), 171 + Floor((223 - $_Crop[1]) / 2), $_Crop[0], $_Crop[1], 0) $hPic[1] = GUICtrlGetHandle(-1) _SetBitmap($hPic[1], _Capture_X1(0, 0, $_Crop[0] - 10, $_Crop[1] - 10, $Col[0], $Col[1]), 1) ;~ GUICtrlSetTip(-1, 'Click on the picture to save it') ;~ GUICtrlSetCursor(-1, 0) $Label[4] = GUICtrlCreate_Label('Double click on the screenshot to save it' & @CR & @CR & '( Hold CTRL to pan screenshot )' & @CR & '( Hold SHIFT to resize it equilaterally )', 110, 250, 200, 60, $SS_CENTER) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ;~ GUICtrlSetColor(-1, BitAND($Col[0], 0xFFFFFF)) If $_Crop[0] - 10 < 187 Then GUICtrlSetState(-1, $GUI_HIDE) EndIf GUICtrlCreateTabItem('AutoIt') $hAutoItCreated = GUICtrlCreateListView('Process|PID|Handle|Class|Title|Version|Path|CmdLine', 36, 171, 349, 223, BitOR($LVS_DEFAULT, $LVS_NOSORTHEADER), $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 8.5, 400, 0, 'Tahoma') GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKHEIGHT)) $hAutoIt = GUICtrlGetHandle(-1) _GUICtrlListView_SetExtendedListViewStyle(-1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) For $i = 4 To UBound($_Column) - 1 _GUICtrlListView_SetColumnWidth(-1, $i - 4, $_Column[$i]) Next $hIL = _GUIImageList_Create(16, 16, 5, 1) If _WinAPI_GetVersion() >= '6.0' Then _WinAPI_SetWindowTheme($hAutoIt, 'Explorer') $tData = _WinAPI_ShellGetStockIconInfo($SIID_APPLICATION, BitOR($SHGSI_ICON, $SHGSI_SMALLICON)) $hIcon = DllStructGetData($tData, 'hIcon') Else $hIcon = _WinAPI_ExtractIcon(@SystemDir & '\shell32.dll', 2, 1) EndIf _GUIImageList_ReplaceIcon($hIL, -1, $hIcon) $hIcon = _WinAPI_AddIconTransparency($hIcon, 50, 1) _GUIImageList_ReplaceIcon($hIL, -1, $hIcon) _WinAPI_DestroyIcon($hIcon) If Not @Compiled Then $hIcon = _WinAPI_ExtractIcon(@ScriptDir & '\Resources\214.ico', 0, 1) Else $hIcon = _WinAPI_ExtractIcon(@ScriptFullPath, -214, 1) EndIf _GUIImageList_ReplaceIcon($hIL, -1, $hIcon) $hIcon = _WinAPI_AddIconTransparency($hIcon, 50, 1) _GUIImageList_ReplaceIcon($hIL, -1, $hIcon) _WinAPI_DestroyIcon($hIcon) _GUICtrlListView_SetImageList($hAutoIt, $hIL, 1) $hHeader[1] = _GUICtrlListView_GetHeader(-1) ;~ _SetAutoItInfo() GUICtrlCreateTabItem('Extras') ; mod. by argumentum GUICtrlCreateGroup(" Emergency close scripts ", 36, 171, 265, 104) $BttnEC[0] = GUICtrlCreateButton(' ProcessClose("AutoIt3*.exe")', 46, 192, 190, 23) GUICtrlSetFont(-1, 8.5, 400, 0, "Tahoma") GUICtrlSetTip($BttnEC[0], "Ctrl+Alt+Shift+ """ & Chr($_EmergencyTryPAu3ExeKey) & """ +Break") If Not @Compiled Then GUICtrlSetState($BttnEC[0], $GUI_DISABLE) $BttnEC[1] = GUICtrlCreateButton('WinClose("[CLASS:AutoIt v3;]")', 46, 217, 220, 23) GUICtrlSetFont(-1, 8.5, 400, 0, "Tahoma") GUICtrlSetTip($BttnEC[1], "Ctrl+Alt+Shift+Break") $BttnEC[5] = GUICtrlCreateCheckbox("", 245, 242, 23, 23) GUICtrlSetTip($BttnEC[5], 'If WinClose("[CLASS:AutoIt v3;]") fails,' & @CR & 'do ProcessClose("[CLASS:AutoIt v3;]")', "", 0, 1) If $_EmergencyTryPClose Then GUICtrlSetState($BttnEC[5], $GUI_CHECKED) ; $_EmergencyTryPAu3Exe $BttnEC[6] = GUICtrlCreateCheckbox("", 245, 192, 23, 23) GUICtrlSetTip($BttnEC[6], "If all prior failed," & @CR & 'do ProcessClose("AutoIt3*.exe")', "", 0, 1) If $_EmergencyTryPAu3Exe Then GUICtrlSetState($BttnEC[6], $GUI_CHECKED) ; If Not @Compiled Then GUICtrlSetState($BttnEC[6], $GUI_UNCHECKED) GUICtrlSetState($BttnEC[6], $GUI_DISABLE) EndIf $BttnEC[2] = GUICtrlCreateButton('ProcessClose("[CLASS:AutoIt v3;]")', 46, 242, 190, 23) GUICtrlSetFont(-1, 8.5, 400, 0, "Tahoma") GUICtrlSetTip($BttnEC[2], "Ctrl+Alt+Shift+ """ & Chr($_EmergencyTryPCloseKey) & """ +Break") $BttnEC[3] = GUICtrlCreateButton("EXEMPT", 270, 192, 24, 73, 12032) ; BitOR($BS_CENTER,$BS_VCENTER,$BS_MULTILINE) GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") GUICtrlSetTip(-1, "Add those exempted from" & @CR & ' closing when closing is' & @CR & ' based on "CLASS:AutoIt v3;"') $BttnEC[4] = GUICtrlCreateCheckbox('Enable HotKey', 200, 169, 90, 17, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_RIGHTBUTTON, $BS_RIGHT)) GUICtrlSetFont(-1, 8.5, 400, 0, "Tahoma") GUICtrlSetTip($BttnEC[4], "Enable/Disable" & @CR & "Emergency HotKey" & @CR & @CR & "This will also close to tray") If $_EmergencyCloseOn Then GUICtrlSetState($BttnEC[4], $GUI_CHECKED) Emergency_HotKey_GuiMsg($BttnEC[4]) $UIA_Ctrls[0] = GUICtrlCreateGroup(" UIA Highlight ", 36, 280, 265, 115) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKHEIGHT, $GUI_DOCKRIGHT)) $UIA_Ctrls[2] = GUICtrlCreateEdit(@CRLF & "Using this may crash the" & @CRLF & " inspected executable." & @CRLF & @CRLF & "Adapted code (from 10/8/2015) found at: " & $_UiaSpyLink & @CRLF, 46, 300, 245, 85) ; , BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) GUICtrlSetFont(-1, 8.5, 400, 0, "Tahoma") GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKHEIGHT, $GUI_DOCKRIGHT)) $UIA_Ctrls[1] = GUICtrlCreateCheckbox('Enable', 235, 277, 55, 17, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_RIGHTBUTTON, $BS_RIGHT)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKWIDTH, $GUI_DOCKTOP, $GUI_DOCKHEIGHT, $GUI_DOCKRIGHT)) GUICtrlSetFont(-1, 8.5, 400, 0, "Tahoma") GUICtrlSetTip($UIA_Ctrls[1], @CR & "Enable/Disable" & @CR & @CR & "Using this may crash the " & @CR & " inspected executable !!!" & @CR & " ", "Warning !", 2, 3) If $_UiaSpy Then GUICtrlSetState($UIA_Ctrls[1], $GUI_CHECKED) Else GUICtrlSetState($UIA_Ctrls[2], $GUI_DISABLE) EndIf If Not IsObj($UIA_oUIAutomation) Then $_UiaSpy = 0 GUICtrlSetState($UIA_Ctrls[1], $GUI_DISABLE) GUICtrlSetState($UIA_Ctrls[1], $GUI_UNCHECKED) GUICtrlSetState($UIA_Ctrls[2], $GUI_DISABLE) GUICtrlSetData($UIA_Ctrls[2], "No UI Automation" & @CRLF & "available.") EndIf GUICtrlCreateTabItem('') _WinAPI_SetThemeAppProperties($Theme) _GUICreate_Aux0() If $_Icon Then $hImageList = _GUIImageList_Create(16, 16, 5, 1) If Not @Compiled Then For $i = 203 To 207 _GUIImageList_AddIcon($hImageList, @ScriptDir & '\Resources\' & $i & '.ico') Next $i = 217 _GUIImageList_AddIcon($hImageList, @ScriptDir & '\Resources\' & $i & '.ico') Else For $i = 203 To 207 _GUIImageList_AddIcon($hImageList, @ScriptFullPath, -$i) Next $i = 217 _GUIImageList_AddIcon($hImageList, @ScriptFullPath, -$i) EndIf _GUICtrlTab_SetImageList($hTab, $hImageList) For $i = 0 To 4 _GUICtrlTab_SetItemImage($hTab, $i, $i) Next EndIf GUICtrlCreateGroup('Info', 10, 115, 401, 305) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKHEIGHT, $GUI_DOCKRIGHT)) ; Controls Group $Group = GUICtrlCreateGroup('Controls', 10, 424, 401, 219 + $Height) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKRIGHT)) GUICtrlCreateListView('Handle|Class|NN|ID', 22, 445, 377, 164 + $Height, BitOR($LVS_DEFAULT, $LVS_NOSORTHEADER), $WS_EX_CLIENTEDGE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKRIGHT)) GUICtrlSetFont(-1, 8.5, 400, 0, 'Tahoma') $hListView = GUICtrlGetHandle(-1) _GUICtrlListView_SetExtendedListViewStyle(-1, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) ;~ For $i = 0 To 3 ;~ _GUICtrlListView_SetColumnWidth($hListView, $i, $_Column[$i]) ;~ Next If _WinAPI_GetVersion() >= '6.0' Then _WinAPI_SetWindowTheme($hListView, 'Explorer') EndIf $hHeader[0] = _GUICtrlListView_GetHeader(-1) $Label[1] = GUICtrlCreateLabel('', 22, 619 + $Height, 12, 12, BitOR($SS_NOTIFY, $SS_SUNKEN)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) GUICtrlSetBkColor(-1, $_Rgb[0]) GUICtrlSetTip(-1, 'Change Visible color') GUICtrlSetCursor(-1, 0) $Label[5] = GUICtrlCreate_Label('Visible', 38, 618 + $Height, 42, 14) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) $Label[2] = GUICtrlCreateLabel('', 92, 619 + $Height, 12, 12, BitOR($SS_NOTIFY, $SS_SUNKEN)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) GUICtrlSetBkColor(-1, $_Rgb[1]) GUICtrlSetTip(-1, 'Change Hidden color') GUICtrlSetCursor(-1, 0) $Label[6] = GUICtrlCreate_Label('Hidden', 108, 618 + $Height, 42, 14) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) $Label[3] = GUICtrlCreateLabel('', 162, 619 + $Height, 12, 12, BitOR($SS_NOTIFY, $SS_SUNKEN)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) GUICtrlSetBkColor(-1, $_Rgb[2]) GUICtrlSetTip(-1, 'Change Missing color') GUICtrlSetCursor(-1, 0) $Label[7] = GUICtrlCreate_Label('Missing', 178, 618 + $Height, 42, 14) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) If Not $_ColoringCtrls Then For $n = 1 To 3 GUICtrlSetState($Label[$n], $GUI_HIDE) GUICtrlSetState($Label[$n + 4], $GUI_HIDE) Next EndIf $g_ctrl_CloneGui[0] = GUICtrlCreateButton('Clone GUI', 238, 618 + $Height - 3, 80, 21) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) GUICtrlSetState($g_ctrl_CloneGui[0], $GUI_DISABLE) $g_ctrl_CloneGui[1] = GUICtrlCreateDummy() $g_ctrl_CloneGui[2] = GUICtrlCreateContextMenu($g_ctrl_CloneGui[1]) $g_ctrl_CloneGui[3] = GUICtrlCreateMenuItem("All controls", $g_ctrl_CloneGui[2]) GUICtrlCreateMenuItem("", $g_ctrl_CloneGui[2]) $g_ctrl_CloneGui[4] = GUICtrlCreateMenuItem("Checked controls", $g_ctrl_CloneGui[2]) For $i = 0 To UBound($Accel) - 1 $Accel[$i][1] = GUICtrlCreateDummy() Next ReDim $Accel[8][2] $Accel[5][0] = '{F5}' ; this is so the refresh, need not be while the listview is in focus $Accel[5][1] = $Dummy[6] $Accel[6][0] = '{F1}' ; "F1" is help ... no help but a link to the site maybe ? $Accel[6][1] = $Menu[19] $Accel[7][0] = '^!c' ; "F1" is help ... no help but a link to the site maybe ? $Accel[7][1] = $Menu[27] GUISetAccelerators($Accel) ; Frame Window ;~ $hFrame = GUICreate('', 100, 100, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST), WinGetHandle($GUI_UNIQUE)) $hFrame = GUICreate('', 100, 100, -1, -1, $WS_POPUP, $WS_EX_LAYERED, WinGetHandle($GUI_UNIQUE)) GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO') GUIRegisterMsg($WM_LBUTTONDBLCLK, 'WM_LBUTTONDBLCLK') GUIRegisterMsg($WM_LBUTTONDOWN, 'WM_LBUTTONDOWN') GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') GUIRegisterMsg($WM_MOVE, 'WM_MOVE') GUIRegisterMsg($WM_SIZE, 'WM_SIZE') $Area = WinGetPos($hForm) If IsArray($Area) Then $Area[3] = $Area[3] - $_Height + 568 EndIf GUISetState(@SW_SHOW, $hForm) If $g_iStartOnTray Then WinSetState($hForm, "", @SW_HIDE) Sleep(300) EndIf FormResize() SizeboxResize() If StringInStr($CmdLineRaw, "/R") Then $_XPos = 50 ; "/Reset" command line to reset GUI position $_YPos = 50 EndIf WinMove($hForm, "", $_XPos, $_YPos) GUISwitch($hForm) $Enum = 1 _GUICtrlTab_SetCurFocus($hTab, $_Tab) ;~ _WinAPI_SetFocus(0) $Enum = 0 If $_Tab = 3 Then _SetAutoItInfo() EndIf EndFunc ;==>_GUICreate Func GUICtrlCreate_Label($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle = -1, $iExStyle = -1) Local Static $iCount = 0 $iCount += 1 $LabelOther[0] = $iCount $LabelOther[$iCount] = GUICtrlCreateLabel($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) Return $LabelOther[$iCount] EndFunc Func GUICtrlCreate_Label_ColorUp() Local $n, $color = _WinAPI_GetSysColor($COLOR_WINDOWTEXT) For $n = 1 To $LabelOther[0] GUICtrlSetColor($LabelOther[$n], $color) Next EndFunc Func _GUICreate_Aux0() If $_ColoringCtrls Then If _WinAPI_IsThemeActive() Then For $i = 3 To 30 ;~ GUICtrlSetBkColor($Input[$i], 0xFFFFFF) GUICtrlSetBkColor($Input[$i], _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_WINDOW))) ; <= set system colors here!!! (0.2019.11.8) Next _GUICreate_Aux1() EndIf EndIf EndFunc Func _GUICreate_Aux1() If $_ColoringCtrls Then If _WinAPI_IsThemeActive() Then GUICtrlSetColor($Input[6], $_Rgb[2]) GUICtrlSetColor($Input[8], $_Rgb[2]) GUICtrlSetColor($Input[18], $_Rgb[1]) GUICtrlSetColor($Input[20], $_Rgb[1]) GUICtrlSetColor($Input[22], $_Rgb[2]) GUICtrlSetColor($Input[24], $_Rgb[2]) EndIf EndIf EndFunc ;==>_GUICreate_Aux1 Func _HWnd($CtrlID) If Not IsHWnd($CtrlID) Then $CtrlID = GUICtrlGetHandle($CtrlID) If Not $CtrlID Then Return 0 EndIf EndIf Return $CtrlID EndFunc ;==>_HWnd Func _IsCrop($iX, $iY, ByRef $iDX, ByRef $iDY) Local $Xn = 36 + Floor((349 - $_Crop[0]) / 2) Local $Yn = 171 + Floor((223 - $_Crop[1]) / 2) Local $Xc = Floor($_Crop[0] / 2) Local $Yc = Floor($_Crop[1] / 2) ;~ Local $dX, $dY Select Case ($iX > $Xn + 4) And ($iX < $Xn + $_Crop[0] - 5) And ($iY > $Yn + 4) And ($iY < $Yn + $_Crop[1] - 5) Return 0 Case ($iX > $Xn - 1) And ($iX < $Xn + 5) And ($iY > $Yn - 1) And ($iY < $Yn + 5) $iDX = $Xi - $Xn - 2 $iDY = $Yi - $Yn - 2 Return 1 Case ($iX > $Xn + $Xc - 3) And ($iX < $Xn + $Xc + 3) And ($iY > $Yn - 1) And ($iY < $Yn + 5) $iDX = $Xi - $Xn - $Xc $iDY = $Yi - $Yn - 2 Return 2 Case ($iX > $Xn + $_Crop[0] - 6) And ($iX < $Xn + $_Crop[0]) And ($iY > $Yn - 1) And ($iY < $Yn + 5) $iDX = $Xi - $Xn - $_Crop[0] + 3 $iDY = $Yi - $Yn - 2 Return 3 Case ($iX > $Xn + $_Crop[0] - 6) And ($iX < $Xn + $_Crop[0]) And ($iY > $Yn + $Yc - 3) And ($iY < $Yn + $Yc + 3) $iDX = $Xi - $Xn - $_Crop[0] + 3 $iDY = $Yi - $Yn - $Yc Return 4 Case ($iX > $Xn + $_Crop[0] - 6) And ($iX < $Xn + $_Crop[0]) And ($iY > $Yn + $_Crop[1] - 6) And ($iY < $Yn + $_Crop[1]) $iDX = $Xi - $Xn - $_Crop[0] + 3 $iDY = $Yi - $Yn - $_Crop[1] + 3 Return 5 Case ($iX > $Xn + $Xc - 3) And ($iX < $Xn + $Xc + 3) And ($iY > $Yn + $_Crop[1] - 6) And ($iY < $Yn + $_Crop[1]) $iDX = $Xi - $Xn - $Xc $iDY = $Yi - $Yn - $_Crop[1] + 3 Return 6 Case ($iX > $Xn - 1) And ($iX < $Xn + 5) And ($iY > $Yn + $_Crop[1] - 6) And ($iY < $Yn + $_Crop[1]) $iDX = $Xi - $Xn - 2 $iDY = $Yi - $Yn - $_Crop[1] + 3 Return 7 Case ($iX > $Xn - 1) And ($iX < $Xn + 5) And ($iY > $Yn + $Yc - 3) And ($iY < $Yn + $Yc + 3) $iDX = $Xi - $Xn - 2 $iDY = $Yi - $Yn - $Yc Return 8 Case Else Return -1 EndSelect EndFunc ;==>_IsCrop Func _IsDark($iRgb) If CC_GetRValue($iRgb) + CC_GetGValue($iRgb) + CC_GetBValue($iRgb) < 3 * 255 / 2 Then Return 1 Else Return 0 EndIf EndFunc ;==>_IsDark Func _IsDown($iKey) ;Local $Ret = DllCall($hDLLuser32, 'short', 'GetAsyncKeyState', 'int', $iKey) Local $Ret = _WinAPI_GetAsyncKeyState($iKey) If (@error) Or ((Not $Ret) And (_WinAPI_GetLastError())) Then Return SetError(1, 0, 0) EndIf Return BitAND($Ret, 0x8000) EndFunc ;==>_IsDown Func _LoadResourceImage($hInstance, $sResType, $sResName, $iResLanguage = 0) Local $hInfo, $hData, $pData, $iSize, $hMem, $pMem, $hStream, $hImage If $iResLanguage Then $hInfo = _WinAPI_FindResourceEx($hInstance, $sResType, $sResName, $iResLanguage) Else $hInfo = _WinAPI_FindResource($hInstance, $sResType, $sResName) EndIf $hData = _WinAPI_LoadResource($hInstance, $hInfo) $iSize = _WinAPI_SizeOfResource($hInstance, $hInfo) $pData = _WinAPI_LockResource($hData) If @error Then Return SetError(1, 0, 0) EndIf ;$hMem = DllCall("kernel32.dll", "ptr", "GlobalAlloc", "uint", 2, "ulong_ptr", $iSize) $hMem = _MemGlobalAlloc($iSize, 2) If @error Then Return SetError(1, 0, 0) EndIf ;$pMem = DllCall("kernel32.dll", "ptr", "GlobalLock", "ptr", $hMem[0]) $pMem = _MemGlobalLock($hMem) If @error Then Return SetError(1, 0, 0) EndIf ;DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", $pMem[0], "ptr", $pData, "ulong_ptr", $iSize) _MemMoveMemory ($pMem, $pData, $iSize) ;DllCall("kernel32.dll", "int", "GlobalUnlock", "ptr", $hMem[0]) _MemGlobalUnlock($hMem) $hStream = _WinAPI_CreateStreamOnHGlobal($hMem[0]) If @error Then Return SetError(1, 0, 0) EndIf ;~ _GDIPlus_Startup() ;$hImage = DllCall($__g_hGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "ptr*", 0) $hImage = _GDIPlus_BitmapCreateFromStream($hStream) If (@error) Or (Not $hImage) Then $hImage = 0 EndIf ;~ _GDIPlus_Shutdown() ;DllCall("kernel32.dll", "ptr", "GlobalFree", "ptr", $hMem[0]) _MemGlobalFree($hMem) If Not $hImage Then Return SetError(1, 0, 0) EndIf Return $hImage EndFunc ;==>_LoadResourceImage Func _OSVersion() Local $oService, $oItems, $Version = '' $oService = ObjGet('winmgmts:\\.\root\cimv2') If Not IsObj($oService) Then Return '' EndIf $oItems = $oService.ExecQuery('SELECT Caption, OSArchitecture FROM Win32_OperatingSystem') If Not IsObj($oItems) Then Return '' EndIf For $Property In $oItems $Version = StringStripWS($Property.Caption & ' ' & $Property.OSArchitecture, 7) Next Return $Version EndFunc ;==>_OSVersion Func _PtInRect($tRect, $tPoint) Local $Ret = DllCall($hDLLuser32, 'int', 'PtInRect', 'ptr', DllStructGetPtr($tRect), 'uint64', DllStructGetData(DllStructCreate('uint64', DllStructGetPtr($tPoint)), 1)) If @error Then Return SetError(1, 0, 0) EndIf Return $Ret[0] EndFunc ;==>_PtInRect Func _ReadRegistry() $_XPos = _WinAPI_DWordToInt(_RegRead($REG_KEY_NAME, 'XPos', 'REG_DWORD', $_XPos)) $_YPos = _WinAPI_DWordToInt(_RegRead($REG_KEY_NAME, 'YPos', 'REG_DWORD', $_YPos)) $_ProgmanPos = _RegRead($REG_KEY_NAME, 'ProgmanPos', 'REG_SZ', "0,0,640,480") ;~ $_About = _ValueCheck(_RegRead($REG_KEY_NAME, 'About', 'REG_DWORD', $_About), 0, 1) $_Width = _ValueCheck(_RegRead($REG_KEY_NAME, 'ClientWidth', 'REG_DWORD', $_Width), 421) $_Height = _ValueCheck(_RegRead($REG_KEY_NAME, 'ClientHeight', 'REG_DWORD', $_Height), 552) $_Top = _ValueCheck(_RegRead($REG_KEY_NAME, 'AlwaysOnTop', 'REG_DWORD', $_Top), 0, 1) $_ColoringCtrls = _ValueCheck(_RegRead($REG_KEY_NAME, 'ColoringCtrls', 'REG_DWORD', $_ColoringCtrls), 0, 1) $_Position = _ValueCheck(_RegRead($REG_KEY_NAME, 'CoordinateMode', 'REG_DWORD', $_Position), 0, 3) $_Color = _ValueCheck(_RegRead($REG_KEY_NAME, 'ColorMode', 'REG_DWORD', $_Color), 0, 1) $_Crosshair = _ValueCheck(_RegRead($REG_KEY_NAME, 'Crosshair', 'REG_DWORD', $_Crosshair), 0, 1) $_Highlight = _ValueCheck(_RegRead($REG_KEY_NAME, 'Highlight', 'REG_DWORD', $_Highlight), 0, 1) $_Frame = BitAND(_RegRead($REG_KEY_NAME, 'HighlightColor', 'REG_DWORD', $_Frame), 0x00FFFFFF) $_Alpha = _ValueCheck(_RegRead($REG_KEY_NAME, 'HighlightTransparency', 'REG_DWORD', $_Alpha), 0, 255) $_Fade = _ValueCheck(_RegRead($REG_KEY_NAME, 'HighlightFadeIn', 'REG_DWORD', $_Fade), 0, 1) $_Code = _ValueCheck(_RegRead($REG_KEY_NAME, 'Encoding', 'REG_DWORD', $_Code), 0, 3) $_CloneGui = _ValueCheck(_RegRead($REG_KEY_NAME, 'CloneGui', 'REG_DWORD', $_CloneGui), 0, 2) $_CloneEditGuiFile = _ValueCheck(_RegRead($REG_KEY_NAME, 'CloneEditGuiFile', 'REG_DWORD', $_CloneEditGuiFile), 0, 1) $_Icon = _ValueCheck(_RegRead($REG_KEY_NAME, 'TabIcon', 'REG_DWORD', $_Icon), 0, 1) $_Tab = _ValueCheck(_RegRead($REG_KEY_NAME, 'Tab', 'REG_DWORD', $_Tab), 0, 3) $_Rgb[0] = BitAND(_RegRead($REG_KEY_NAME, 'ControlVisibleColor', 'REG_DWORD', $_Rgb[0]), 0x00FFFFFF) $_Rgb[1] = BitAND(_RegRead($REG_KEY_NAME, 'ControlHiddenColor', 'REG_DWORD', $_Rgb[1]), 0x00FFFFFF) $_Rgb[2] = BitAND(_RegRead($REG_KEY_NAME, 'ControlMissingColor', 'REG_DWORD', $_Rgb[2]), 0x00FFFFFF) $_Rgb[3] = _ValueCheck(_RegRead($REG_KEY_NAME, 'ControlVisibleColorDef', 'REG_DWORD', $_Rgb[3]), 0, 1) $_Rgb[4] = _ValueCheck(_RegRead($REG_KEY_NAME, 'ControlHiddenColorDef', 'REG_DWORD', $_Rgb[4]), 0, 1) $_Rgb[5] = _ValueCheck(_RegRead($REG_KEY_NAME, 'ControlMissingColorDef', 'REG_DWORD', $_Rgb[5]), 0, 1) If $_Rgb[3] Then $_Rgb[0] = _WinAPI_GetSysColor($_Rgb[6]) If $_Rgb[4] Then $_Rgb[1] = _WinAPI_GetSysColor($_Rgb[7]) If $_Rgb[5] Then $_Rgb[2] = _WinAPI_GetSysColor($_Rgb[8]) ;~ $_Column[0] = _RegRead($REG_KEY_NAME, 'ColumnControlHandle', 'REG_DWORD', $_Column[0]) ; these columns ;~ $_Column[1] = _RegRead($REG_KEY_NAME, 'ColumnControlClass', 'REG_DWORD', $_Column[1]) ; are now resized ;~ $_Column[2] = _RegRead($REG_KEY_NAME, 'ColumnControlNN', 'REG_DWORD', $_Column[2]) ; on the fly ;~ $_Column[3] = _RegRead($REG_KEY_NAME, 'ColumnControlID', 'REG_DWORD', $_Column[3]) ;~ $_Column[4] = _RegRead($REG_KEY_NAME, 'ColumnAutoItProcess', 'REG_DWORD', $_Column[4]) ;~ $_Column[5] = _RegRead($REG_KEY_NAME, 'ColumnAutoItPID', 'REG_DWORD', $_Column[5]) ;~ $_Column[6] = _RegRead($REG_KEY_NAME, 'ColumnAutoItHandle', 'REG_DWORD', $_Column[6]) ;~ $_Column[7] = _RegRead($REG_KEY_NAME, 'ColumnAutoItClass', 'REG_DWORD', $_Column[7]) ;~ $_Column[8] = _RegRead($REG_KEY_NAME, 'ColumnAutoItTitle', 'REG_DWORD', $_Column[8]) ;~ $_Column[9] = _RegRead($REG_KEY_NAME, 'ColumnAutoItVersion', 'REG_DWORD', $_Column[9]) ;~ $_Column[10] = _RegRead($REG_KEY_NAME, 'ColumnAutoItPath', 'REG_DWORD', $_Column[10]) ;~ $_Column[10] = _RegRead($REG_KEY_NAME, 'ColumnAutoItCmdLine', 'REG_DWORD', $_Column[11]) $_Crop[0] = _ValueCheck(_RegRead($REG_KEY_NAME, 'CaptureWidth', 'REG_DWORD', $_Crop[0]), 43, 349) $_Crop[1] = _ValueCheck(_RegRead($REG_KEY_NAME, 'CaptureHeight', 'REG_DWORD', $_Crop[0]), 43, 223) $_Capture = _ValueCheck(_RegRead($REG_KEY_NAME, 'LiveCapture', 'REG_DWORD', $_Capture), 0, 1) $_All = _ValueCheck(_RegRead($REG_KEY_NAME, 'AutoItVisible', 'REG_DWORD', $_All), 0, 1) $_AllJustAutoItv3 = _ValueCheck(_RegRead($REG_KEY_NAME, 'AutoItJustAutoItV3', 'REG_DWORD', $_AllJustAutoItv3), 0, 1) $_EmergencyCloseOn = _ValueCheck(_RegRead($REG_KEY_NAME, 'EmergencyClose', 'REG_DWORD', $_EmergencyCloseOn), 0, 1) $_UiaSpy = _ValueCheck(_RegRead($REG_KEY_NAME, 'UiaSpy', 'REG_DWORD', $_UiaSpy), 0, 1) $_EmergencyTryPClose = _ValueCheck(_RegRead($REG_KEY_NAME, 'EmergencyTryPClose', 'REG_DWORD', $_EmergencyTryPClose), 0, 1) $_EmergencyTryPAu3Exe = _ValueCheck(_RegRead($REG_KEY_NAME, 'EmergencyTryPAu3Exe', 'REG_DWORD', $_EmergencyTryPAu3Exe), 0, 1) $_EmergencyTryPCloseKey = _RegRead($REG_KEY_NAME, 'EmergencyTryPCloseKey', 'REG_DWORD', $_EmergencyTryPCloseKey) $_EmergencyTryPAu3ExeKey = _RegRead($REG_KEY_NAME, 'EmergencyTryPAu3ExeKey', 'REG_DWORD', $_EmergencyTryPAu3ExeKey) For $i = 0 To 1 If Not Mod($_Crop[$i], 2) Then $_Crop[$i] -= 1 EndIf Next EndFunc ;==>_ReadRegistry Func _RegRead($sKey, $sValue, $sType, $sDefault) Local Static $iUseIni = FileExists($GUI_INI) Local $a, $Val, $Error = 0 If $iUseIni Then $Val = IniRead($GUI_INI, "Settings", $sValue, $sDefault) Else $Val = RegRead($sKey, $sValue) EndIf If @error Then Switch @error Case -1, 1 If Not $iUseIni Then RegWrite($sKey, $sValue, $sType, $sDefault) Case Else EndSwitch Return SetError(@error, 0, $sDefault) EndIf Switch $sType Case 'REG_SZ', 'REG_MULTI_SZ', 'REG_EXPAND_SZ' If $iUseIni Then $Val = String($Val) Else If Not IsString($Val) Then $Error = -3 EndIf Case 'REG_BINARY' If $iUseIni Then $Val = Binary($Val) Else If Not IsBinary($Val) Then $Error = -3 EndIf Case 'REG_DWORD' If $iUseIni Then $a = StringSplit($Val, ";") $a[1] = StringStripWS($a[1], 3) If StringLeft($a[1], 1) = "-" Then $Val = "-" & Int(StringTrimLeft($a[1], 1)) Else $Val = Int($a[1]) EndIf Else If Not IsInt($Val) Then $Error = -3 EndIf Case Else $Error = -2 EndSwitch If $Error Then Return SetError($Error, 0, $sDefault) Else Return $Val EndIf EndFunc ;==>_RegRead Func _SCAW() Local $tState = _WinAPI_GetKeyboardState() For $i = 0x5B To 0x5C If BitAND(DllStructGetData($tState, 1, $i + 1), 0xF0) Then Return 1 EndIf Next For $i = 0xA0 To 0xA5 If BitAND(DllStructGetData($tState, 1, $i + 1), 0xF0) Then Return 1 EndIf Next Return 0 EndFunc ;==>_SCAW Func _SetAutoItInfo() Local $ID, $List, $Argv, $File, $FlagIsAu3, $Flag, $Name, $Path, $Version, $hIcon, $Index = 0, $CmdLiner Local $Data[101][7] = [[0]] _GUICtrlListView_BeginUpdate($hAutoIt) _GUICtrlListView_DeleteAllItems($hAutoIt) _GUIImageList_SetImageCount($hIL, 4) $List = WinList() If IsArray($List) Then For $i = 0 To $List[0][0] $ID = WinGetProcess($List[$i][1]) If ($ID <> -1) And ($ID <> @AutoItPID) And (StringInStr(_WinAPI_GetClassName($List[$i][1]), 'AutoIt v3')) And (_ArraySearch($Data, $ID, 1) = -1) Then $CmdLiner = _WinAPI_GetProcessCommandLine($ID) $Path = _WinAPI_GetProcessFileName($ID) If Not $Path Then ContinueLoop EndIf $Name = _WinAPI_GetProcessName($ID) If Not $Name Then ContinueLoop EndIf $File = '' $Version = '' If ($Name = 'AutoIt3.exe') And (FileGetVersion($Path, 'ProductName') = 'AutoIt v3 Script') Then $Argv = _WinAPI_CommandLineToArgv($CmdLiner) For $i = 1 To UBound($Argv) - 1 If StringLeft($Argv[$i], 1) <> '/' Then If _WinAPI_PathIsRelative($Argv[$i]) Then $File = _WinAPI_PathSearchAndQualify(_WinAPI_GetProcessWorkingDirectory($ID) & '\' & $Argv[$i], 1) Else $File = _WinAPI_PathSearchAndQualify($Argv[$i], 1) EndIf ExitLoop EndIf Next If $File Then $Version = FileGetVersion($Path) If @error Then $Version = '' EndIf $Flag = 0 Else $Version = FileGetVersion($Path) ; correction added by argumentum $File = $Path $Flag = 1 EndIf $Data[0][0] += 1 If $Data[0][0] > UBound($Data) - 1 Then ReDim $Data[$Data[0][0] + 100][7] EndIf $Data[$Data[0][0]][0] = $ID $Data[$Data[0][0]][1] = $Name $Data[$Data[0][0]][2] = $Path $Data[$Data[0][0]][3] = $Version $Data[$Data[0][0]][4] = $File $Data[$Data[0][0]][5] = $Flag $Data[$Data[0][0]][6] = $CmdLiner ; added by argumentum EndIf Next _ArraySort($Data, 0, 1, $Data[0][0], 1) $Enum += 1 For $i = 1 To $Data[0][0] $List = _WinAPI_EnumProcessWindows($Data[$i][0], Not $_All) If Not IsArray($List) Then ContinueLoop EndIf For $j = $List[0][0] To 1 Step -1 $FlagIsAu3 = StringInStr($List[$j][1], "AutoIt v3") = 1 If $_AllJustAutoItv3 Then ; added by argumentum If Not $FlagIsAu3 Then ContinueLoop EndIf If $_All Then $Flag = _WinAPI_IsWindowVisible($List[$j][0]) Else $Flag = 1 EndIf If $Data[$i][5] Then $hIcon = _WinAPI_ExtractIcon($Data[$i][2], 0, 1) If $hIcon Then If Not $Flag Then $hIcon = _WinAPI_AddIconTransparency($hIcon, 50, 1) EndIf $ID = _GUIImageList_ReplaceIcon($hIL, -1, $hIcon) If $hIcon Then _WinAPI_DestroyIcon($hIcon) EndIf EndIf Else $hIcon = 0 EndIf If Not $hIcon Then If $Data[$i][5] Then If $Flag Then $ID = 0 Else $ID = 1 EndIf Else If $Flag Then $ID = 2 Else $ID = 3 EndIf EndIf EndIf _GUICtrlListView_AddItem($hAutoIt, $Data[$i][1], $ID) _GUICtrlListView_AddSubItem($hAutoIt, $Index, $Data[$i][0], 1) _GUICtrlListView_AddSubItem($hAutoIt, $Index, $List[$j][0], 2) _GUICtrlListView_AddSubItem($hAutoIt, $Index, $List[$j][1], 3) ; corrected by argumentum _GUICtrlListView_AddSubItem($hAutoIt, $Index, _WinAPI_GetWindowText($List[$j][0]), 4) _GUICtrlListView_AddSubItem($hAutoIt, $Index, $Data[$i][3], 5) _GUICtrlListView_AddSubItem($hAutoIt, $Index, $Data[$i][4], 6) _GUICtrlListView_AddSubItem($hAutoIt, $Index, $Data[$i][6], 7) ; added by argumentum If Not $Flag Then _GUICtrlListView_SetItemParam($hAutoIt, $Index, 0x7FFFFFFF) EndIf If Not $FlagIsAu3 Then _GUICtrlListView_SetItemParam($hAutoIt, $Index, 0x7FFFFFF9) $Index += 1 Next Next $Enum -= 1 EndIf For $j = 0 To 7 _GUICtrlListView_SetColumnWidth($hAutoIt, $j, $LVSCW_AUTOSIZE_USEHEADER) ; added by argumentum Next _GUICtrlListView_EndUpdate($hAutoIt) EndFunc ;==>_SetAutoItInfo Func _SetBitmap($hWnd, $hBitmap, $fUpdate = 0) ;~ $hWnd = _HWnd($hWnd) ;~ If Not $hWnd Then ;~ Return ;~ EndIf Local $hPrev, $Pos If Not $hBitmap Then $Pos = ControlGetPos($hWnd, '', 0) EndIf $hPrev = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap) If $hPrev Then _WinAPI_DeleteObject($hPrev) EndIf If Not $hBitmap Then _WinAPI_MoveWindow($hWnd, $Pos[0], $Pos[1], $Pos[2], $Pos[3], 0) Else $hPrev = _SendMessage($hWnd, $STM_GETIMAGE) If $hPrev <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf EndIf If $fUpdate Then _WinAPI_UpdateWindow($hWnd) EndIf Return 1 EndFunc ;==>_SetBitmap Func _SetData($CtrlID, $sData) If StringCompare(GUICtrlRead($CtrlID), $sData, 1) Then _GUICtrlEdit_SetText($CtrlID, $sData) EndIf EndFunc ;==>_SetData Func _SetStyle($hWnd, $iStyle, $fSet, $fExStyle = 0, $fUpdate = 0) $hWnd = _HWnd($hWnd) If Not $hWnd Then Return EndIf Local $Flag = $GWL_STYLE If $fExStyle Then $Flag = $GWL_EXSTYLE EndIf Local $Style = _WinAPI_GetWindowLong($hWnd, $Flag) If $fSet Then If BitAND($Style, $iStyle) <> $iStyle Then _WinAPI_SetWindowLong($hWnd, $Flag, BitOR($Style, $iStyle)) EndIf Else If BitAND($Style, $iStyle) Then _WinAPI_SetWindowLong($hWnd, $Flag, BitAND($Style, BitNOT($iStyle))) EndIf EndIf If $fUpdate Then _WinAPI_InvalidateRect($hWnd) EndIf EndFunc ;==>_SetStyle Func _SetControlInfo($hWnd) If Not $hWnd Then For $i = 16 To 30 _SetData($Input[$i], '') Next Return EndIf Local $Data, $Prev, $Index $Index = _GUICtrlListView_GetSelectedIndices($hListView) $Data = _WinAPI_GetClassName($hWnd) If ($Index) And (StringCompare(_GUICtrlListView_GetItemText($hListView, $Index, 1), $Data, 1)) Then _GUICtrlListView_SetItemText($hListView, $Index, $Data, 1) EndIf If $Data Then _SetData($Input[16], $Data) Else _SetData($Input[16], '') EndIf $Prev = $Data $Data = _GetNN($hWnd) If $Data <= 0 Then $Data = '' EndIf If ($Index) And (StringCompare(_GUICtrlListView_GetItemText($hListView, $Index, 2), $Data, 1)) Then _GUICtrlListView_SetItemText($hListView, $Index, $Data, 2) EndIf If $Data Then _SetData($Input[17], $Data) If $Prev Then _SetData($Input[18], '[CLASS:' & $Prev & '; INSTANCE:' & $Data & ']') Else _SetData($Input[18], '') EndIf Else For $i = 17 To 18 _SetData($Input[$i], '') Next EndIf $Data = _WinAPI_GetDlgCtrlID($hWnd) If $Data <= 0 Then $Data = '' EndIf If ($Index) And (StringCompare(_GUICtrlListView_GetItemText($hListView, $Index, 3), $Data, 1)) Then _GUICtrlListView_SetItemText($hListView, $Index, $Data, 3) EndIf If $Data Then _SetData($Input[19], $Data) If $Prev Then _SetData($Input[20], '[CLASS:' & $Prev & '; ID:' & $Data & ']') Else _SetData($Input[20], '') EndIf Else For $i = 19 To 20 _SetData($Input[$i], '') Next EndIf $Data = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) ;~ If $Data Then _SetData($Input[21], '0x' & Hex($Data, 8)) _SetData($Input[22], _GetStyleString($Data, 0, 0)) ;~ Else ;~ For $i = 21 To 22 ;~ _SetData($Input[$i], '') ;~ Next ;~ EndIf $Data = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE) ;~ If $Data Then _SetData($Input[23], '0x' & Hex($Data, 8)) _SetData($Input[24], _GetStyleString($Data, 0, 1)) ;~ Else ;~ For $i = 23 To 24 ;~ _SetData($Input[$i], '') ;~ Next ;~ EndIf $Data = _WinAPI_GetWindowRect($hWnd) For $i = 27 To 28 _SetData($Input[$i], DllStructGetData($Data, $i - 24) - DllStructGetData($Data, $i - 26)) Next If _WinAPI_ScreenToClient(_WinAPI_GetAncestor($hWnd, $GA_ROOT), $Data) Then For $i = 25 To 26 _SetData($Input[$i], DllStructGetData($Data, $i - 24)) Next Else For $i = 25 To 26 _SetData($Input[$i], '') Next EndIf ;~ If $hWnd Then _SetData($Input[29], $hWnd) ;~ Else ;~ _SetData($Input[29], '') ;~ EndIf $Data = ControlGetText($hWnd, '', 0) Switch $_Code Case 0 ; ANSI $Data = BinaryToString(StringToBinary($Data, 2), 1) Case 1 ; Unicode Case 2 ; Unicode (Big Endian) $Data = BinaryToString(StringToBinary($Data, 2), 3) Case 3 ; UTF8 $Data = BinaryToString(StringToBinary($Data, 2), 4) EndSwitch If $Data Then _SetData($Input[30], $Data) ; StringStripWS(StringRegExpReplace($Data, '\n.*', ''), 2)) Else _SetData($Input[30], '') EndIf EndFunc ;==>_SetControlInfo Func _SetWindowInfo($hWnd) If Not $hWnd Then For $i = 3 To 15 _SetData($Input[$i], '') Next Return EndIf Local $Data $Data = WinGetText($hWnd) If $Data Then _SetData($Input[31], $Data) Else _SetData($Input[31], '') EndIf $Data = _WinAPI_GetWindowText($hWnd) If $Data Then _SetData($Input[3], $Data) Else _SetData($Input[3], '') EndIf $Data = _WinAPI_GetClassName($hWnd) If $Data Then _SetData($Input[4], $Data) Else _SetData($Input[4], '') EndIf $Data = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) ;~ If $Data Then _SetData($Input[5], '0x' & Hex($Data, 8)) _SetData($Input[6], _GetStyleString($Data)) ;~ Else ;~ For $i = 5 To 6 ;~ _SetData($Input[$i], '') ;~ Next ;~ EndIf $Data = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE) ;~ If $Data Then _SetData($Input[7], '0x' & Hex($Data, 8)) _SetData($Input[8], _GetStyleString($Data, 1, 1)) ;~ Else ;~ For $i = 7 To 8 ;~ _SetData($Input[$i], '') ;~ Next ;~ EndIf $Data = _WinAPI_GetWindowRect($hWnd) For $i = 9 To 10 _SetData($Input[$i], DllStructGetData($Data, $i - 8)) Next For $i = 11 To 12 _SetData($Input[$i], DllStructGetData($Data, $i - 8) - DllStructGetData($Data, $i - 10)) Next ;~ If $hWnd Then _SetData($Input[13], $hWnd) ;~ Else ;~ _SetData($Input[13], '') ;~ EndIf $Data = WinGetProcess($hWnd) If $Data > -1 Then _SetData($Input[14], $Data) $Data = _WinAPI_GetProcessFileName($Data) If Not @error Then _SetData($Input[15], FileGetLongName($Data)) Else _SetData($Input[15], '') EndIf Else For $i = 14 To 15 _SetData($Input[$i], '') Next EndIf EndFunc ;==>_SetWindowInfo Func _SetFrameOrder($hOwner) If BitAND(_WinAPI_GetWindowLong($hOwner, $GWL_EXSTYLE), $WS_EX_TOPMOST) Then WinSetOnTop($hFrame, '', 1) Else WinSetOnTop($hFrame, '', 0) EndIf If _WinAPI_SetWindowPos($hFrame, _WinAPI_GetWindow($hOwner, $GW_HWNDPREV), 0, 0, 0, 0, BitOR($SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE)) Then Return 1 Else Return 0 EndIf EndFunc ;==>_SetFrameOrder Func _ShellAboutDlg($hParent = 0) Local $hDlg, $hLayer, $hPng, $tSize, $Button, $Msg, $Pos, $Top = 0, $www[3] If Not $hAbout Then ;~ _GDIPlus_Startup() If Not @Compiled Then $hPng = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Resources\About.png') Else $hPng = _LoadResourceImage($hInstance, 'PNG', 'ABOUT') EndIf $hAbout = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng) _GDIPlus_ImageDispose($hPng) ;~ _GDIPlus_Shutdown() EndIf $tSize = _WinAPI_GetBitmapDimension($hAbout) If @error Then Return 0 EndIf ;~ Opt('GUICloseOnESC', 1) GUISetState(@SW_DISABLE, $hParent) If Not $hParent Then $Top = $WS_EX_TOPMOST EndIf $hDlg = GUICreate($GUI_NAME, DllStructGetData($tSize, 1), DllStructGetData($tSize, 2), -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $Top), $hParent) $Pos = WinGetPos($hDlg) $www[0] = GUICreate('', 220, 115, $Pos[0] + ($Pos[2] + 20) / 2, $Pos[1] + $Pos[3] - 200, $WS_POPUP, $WS_EX_LAYERED, $hDlg) GUISetBkColor(0x2B5280, $www[0]) $www[1] = GUICtrlCreateLabel("www.autoitscript.com/forum/", 0, 0, 190, 15) GUICtrlSetFont($www[1], 9.5, 800, 4) ; underlined GUICtrlSetColor($www[1], 0x00FFFF) GUICtrlSetCursor($www[1], 0) $www[2] = GUICtrlCreateLabel("( mod. v" & FileGetVersion(@ScriptFullPath) & " )", 0, 30, 190, 15) GUICtrlSetFont($www[2], 8.5, -1, 0, 'Tahoma') GUICtrlSetColor($www[2], 0xFFFF00) $hLayer = GUICreate('', 70, 23, $Pos[0] + ($Pos[2] - 70) / 2, $Pos[1] + $Pos[3] - 50, $WS_POPUP, $WS_EX_LAYERED, $hDlg) ;~ GUISetFont(8.5, 400, 0, 'MS Shell Dlg', $hLayer) GUISetBkColor(0x2B5280, $hLayer) $Button = GUICtrlCreateButton('OK', 0, 0, 70, 23) GUICtrlSetState(-1, $GUI_FOCUS) _WinAPI_SetLayeredWindowAttributes($www[0], 0x2B5280, 0, $LWA_COLORKEY) _WinAPI_SetLayeredWindowAttributes($hLayer, 0x2B5280, 0, $LWA_COLORKEY) _WinAPI_UpdateLayeredWindowEx($hDlg, -1, -1, $hAbout) GUISetState(@SW_SHOW, $hDlg) GUISetState(@SW_SHOW, $www[0]) GUISetState(@SW_SHOW, $hLayer) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE, $Button ExitLoop Case $www[1] ShellExecute("https://www.autoitscript.com/forum/files/file/478-control-viewer-mod/") ExitLoop EndSwitch WEnd GUISetState(@SW_ENABLE, $hParent) GUIDelete($hLayer) GUIDelete($hDlg) ;~ Opt('GUICloseOnESC', 0) EndFunc ;==>_ShellAboutDlg Func _ShellKillProcess($PID, $hParent = 0) Local $Name = _WinAPI_GetProcessName($PID) If Not $Name Then Return 0 EndIf If MsgBox(256 + 48 + 4, $GUI_NAME, 'Are you sure you want to close this prosess?', 0, $hParent) = 6 Then If Not ProcessClose($PID) Then MsgBox(16, $GUI_NAME, 'Unable to close the process.', 0, $hParent) Return 0 Else Return 1 EndIf EndIf Return 0 EndFunc ;==>_ShellKillProcess Func _ShellReportDlg($hParent = 0, $Data = "", $tempFile = "", $iEditFile = 0) Local $hFile, $Path, $Result If $tempFile = "" Then $Path = FileSaveDialog('Save Report', $PathDlg, 'Text Document (*.txt)|All Files (*.*)', 2 + 16, 'Report-' & @YEAR & '.' & @MON & '.' & @MDAY & '-' & @HOUR & '.' & @MIN & '.' & @SEC & '.txt', $hParent) Else $Path = FileSaveDialog('Save Code', $PathDlg, 'AutoIt source (*.au3)|All Files (*.*)', 2 + 16, $tempFile, $hParent) EndIf If Not $Path Then Return 1 EndIf $PathDlg = StringRegExpReplace($Path, '^.*\.', '') If $tempFile = "" Then $Data = _CreateReport() If Not $Data Then Return 0 EndIf $hFile = FileOpen($Path, 2) $Result = FileWrite($hFile, $Data) FileClose($hFile) If $iEditFile And $Result Then ShellExecute($Path, "", "", "Edit") Return $Result EndFunc ;==>_ShellReportDlg Func _ShellSaveDlg($hParent = 0) Local $hSrcDC, $hDstDC, $hSrcSv, $hDstSv, $hArea, $hBitmap, $Path, $Result $Path = FileSaveDialog('Save Image', _ $PathDlg, _ ;StringRegExpReplace($PathDlg, '\\[^\\]*\Z', ''), _ 'Portable Network Graphic (*.png)|All Files (*.*)', _ 2 + 16, _ 'Capture-' & @YEAR & '.' & @MON & '.' & @MDAY & '-' & @HOUR & '.' & @MIN & '.' & @SEC & '.png', _ $hParent) If Not $Path Then Return 1 EndIf $PathDlg = StringRegExpReplace($Path, '^.*\.', '') $hBitmap = _SendMessage($hPic[1], $STM_GETIMAGE) If Not $hBitmap Then Return 0 EndIf $hArea = _WinAPI_CreateBitmap($_Crop[0] - 10, $_Crop[1] - 10, 1, 32) If Not $hArea Then Return 0 EndIf $hSrcDC = _WinAPI_CreateCompatibleDC(0) $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBitmap) $hDstDC = _WinAPI_CreateCompatibleDC(0) $hSrcSv = _WinAPI_SelectObject($hDstDC, $hArea) _WinAPI_BitBlt($hDstDC, 0, 0, $_Crop[0] - 10, $_Crop[1] - 10, $hSrcDC, 5, 5, $SRCCOPY) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_SelectObject($hDstDC, $hDstSv) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteDC($hDstSv) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hArea) $Result = _GDIPlus_ImageSaveToFile($hBitmap, $Path) _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject($hArea) Return $Result EndFunc ;==>_ShellSaveDlg Func _ShowFrame($fShow, $tRect = 0, $hOwner = 0) If (Not $_Alpha) Or (Not $_Highlight) Then Return EndIf Local $hGraphics, $hPen, $hBitmap, $Pos If $_Fade Then AdlibUnRegister('_ShowProc') $Fade = 0 $Hold = 0 EndIf If $hRect Then _WinAPI_UpdateLayeredWindowEx($hFrame, -1, -1, $hRect, 0, 1) ; _WinAPI_DeleteObject($hRect) EndIf $Alpha = 0 $hRect = 0 If Not $fShow Then GUISetState(@SW_HIDE, $hFrame) $hFrameIsShown = 0 If $_Fade Then $Fade = 1 $Hold = TimerInit() AdlibRegister('_ShowProc', 10) EndIf Return EndIf $Pos = _WinAPI_GetPosFromRect($tRect) If (Not IsArray($Pos)) Or (Not $Pos[2]) Or (Not $Pos[3]) Then GUISetState(@SW_HIDE, $hFrame) $hFrameIsShown = 0 Return EndIf WinMove($hFrame, '', $Pos[0], $Pos[1], $Pos[2], $Pos[3]) ;~ WinSetOnTop($hFrame, '', 1) If $hOwner Then _SetFrameOrder($hOwner) EndIf $hBitmap = _GDIPlus_BitmapCreateFromScan0($Pos[2], $Pos[3]) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;~ _GDIPlus_GraphicsClear($hGraphics, 0) $hPen = _GDIPlus_PenCreate(BitOR(BitShift($_Alpha, -24), $_Frame), 3) _GDIPlus_GraphicsDrawRect($hGraphics, 1, 1, _Max($Pos[2] - 3, 1), _Max($Pos[3] - 3, 1), $hPen) $hRect = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_PenDispose($hPen) If $hRect Then GUISetState(@SW_SHOWNOACTIVATE, $hFrame) $hFrameIsShown = 1 Else GUISetState(@SW_HIDE, $hFrame) $hFrameIsShown = 0 If $_Fade Then $Hold = TimerInit() Else Return EndIf EndIf If $_Fade Then $Fade = 1 AdlibRegister('_ShowProc', 10) Else If Not _WinAPI_UpdateLayeredWindowEx($hFrame, -1, -1, $hRect, $_Alpha) Then ; Nothing EndIf EndIf EndFunc ;==>_ShowFrame Func _ShowProc() If $Hold Then If TimerDiff($Hold) > 250 Then AdlibUnRegister('_ShowProc') $Fade = 0 $Hold = 0 EndIf Return EndIf $Alpha += $_Alpha / 8 If $Alpha >= $_Alpha Then $Alpha = $_Alpha $Hold = TimerInit() EndIf If Not _WinAPI_UpdateLayeredWindowEx($hFrame, -1, -1, $hRect, $Alpha) Then ; Nothing EndIf EndFunc ;==>_ShowProc Func _Update($fDisable = 0) $Refresh += 1 Opt('GUIOnEventMode', 1) Local $State, $Update = False Local $hItem For $i = 0 To _GUICtrlListView_GetItemCount($hListView) - 1 $hItem = Ptr(_GUICtrlListView_GetItemText($hListView, $i)) If (Not $fDisable) And (_WinAPI_IsWindow($hItem)) Then $State = _WinAPI_IsWindowVisible($hItem) If _GUICtrlListView_GetItemChecked($hListView, $i) <> $State Then If Not $Update Then $Update = _GUICtrlListView_BeginUpdate($hListView) EndIf _GUICtrlListView_SetItemChecked($hListView, $i, $State) If _GUICtrlListView_GetItemState($hListView, $i, $LVIS_SELECTED) Then _SetControlInfo($hItem) EndIf EndIf Else If Not $Update Then $Update = _GUICtrlListView_BeginUpdate($hListView) EndIf If _GUICtrlListView_GetItemChecked($hListView, $i) Then _GUICtrlListView_SetItemChecked($hListView, $i, 0) EndIf If $hItem Then _GUICtrlListView_SetItemText($hListView, $i, $hItem & ChrW(160)) EndIf _GUICtrlListView_RedrawItems($hListView, $i, $i) EndIf Next If $Update Then _GUICtrlListView_EndUpdate($hListView) EndIf Opt('GUIOnEventMode', 0) $Refresh -= 1 EndFunc ;==>_Update Func _ValueCheck($iValue, $iMin, $iMax = Default) If ($iMin <> Default) And ($iValue < $iMin) Then Return $iMin EndIf If ($iMax <> Default) And ($iValue > $iMax) Then Return $iMax EndIf Return $iValue EndFunc ;==>_ValueCheck Func _WriteRegistry() Reg_Write($REG_KEY_NAME, 'XPos', 'REG_DWORD', $_XPos) Reg_Write($REG_KEY_NAME, 'YPos', 'REG_DWORD', $_YPos) ;~ Reg_Write($REG_KEY_NAME, 'About', 'REG_DWORD', $_About) Reg_Write($REG_KEY_NAME, 'ProgmanPos', 'REG_SZ', $_ProgmanPos) Reg_Write($REG_KEY_NAME, 'ClientWidth', 'REG_DWORD', $_Width) Reg_Write($REG_KEY_NAME, 'ClientHeight', 'REG_DWORD', $_Height) Reg_Write($REG_KEY_NAME, 'AlwaysOnTop', 'REG_DWORD', $_Top) Reg_Write($REG_KEY_NAME, 'ColoringCtrls', 'REG_DWORD', $_ColoringCtrls) Reg_Write($REG_KEY_NAME, 'CoordinateMode', 'REG_DWORD', $_Position) Reg_Write($REG_KEY_NAME, 'ColorMode', 'REG_DWORD', $_Color) Reg_Write($REG_KEY_NAME, 'Crosshair', 'REG_DWORD', $_Crosshair) Reg_Write($REG_KEY_NAME, 'Highlight', 'REG_DWORD', $_Highlight) Reg_Write($REG_KEY_NAME, 'HighlightColor', 'REG_DWORD', $_Frame) Reg_Write($REG_KEY_NAME, 'HighlightTransparency', 'REG_DWORD', $_Alpha) Reg_Write($REG_KEY_NAME, 'HighlightFadeIn', 'REG_DWORD', $_Fade) Reg_Write($REG_KEY_NAME, 'Encoding', 'REG_DWORD', $_Code) Reg_Write($REG_KEY_NAME, 'CloneGui', 'REG_DWORD', $_CloneGui) Reg_Write($REG_KEY_NAME, 'CloneEditGuiFile', 'REG_DWORD', $_CloneEditGuiFile) ;~ Reg_Write($REG_KEY_NAME, 'TabIcon', 'REG_DWORD', $_Icon) Reg_Write($REG_KEY_NAME, 'Tab', 'REG_DWORD', $_Tab) Reg_Write($REG_KEY_NAME, 'ControlVisibleColor', 'REG_DWORD', $_Rgb[0]) Reg_Write($REG_KEY_NAME, 'ControlHiddenColor', 'REG_DWORD', $_Rgb[1]) Reg_Write($REG_KEY_NAME, 'ControlMissingColor', 'REG_DWORD', $_Rgb[2]) Reg_Write($REG_KEY_NAME, 'ControlVisibleColorDef', 'REG_DWORD', $_Rgb[3]) Reg_Write($REG_KEY_NAME, 'ControlHiddenColorDef', 'REG_DWORD', $_Rgb[4]) Reg_Write($REG_KEY_NAME, 'ControlMissingColorDef', 'REG_DWORD', $_Rgb[5]) ;~ Reg_Write($REG_KEY_NAME, 'ColumnControlHandle', 'REG_DWORD', $_Column[0]) ; these columns ;~ Reg_Write($REG_KEY_NAME, 'ColumnControlClass', 'REG_DWORD', $_Column[1]) ; are now resized ;~ Reg_Write($REG_KEY_NAME, 'ColumnControlNN', 'REG_DWORD', $_Column[2]) ; on the fly ;~ Reg_Write($REG_KEY_NAME, 'ColumnControlID', 'REG_DWORD', $_Column[3]) ;~ Reg_Write($REG_KEY_NAME, 'ColumnAutoItProcess', 'REG_DWORD', $_Column[4]) ;~ Reg_Write($REG_KEY_NAME, 'ColumnAutoItPID', 'REG_DWORD', $_Column[5]) ;~ Reg_Write($REG_KEY_NAME, 'ColumnAutoItHandle', 'REG_DWORD', $_Column[6]) ;~ Reg_Write($REG_KEY_NAME, 'ColumnAutoItClass', 'REG_DWORD', $_Column[7]) ;~ Reg_Write($REG_KEY_NAME, 'ColumnAutoItTitle', 'REG_DWORD', $_Column[8]) ;~ Reg_Write($REG_KEY_NAME, 'ColumnAutoItVersion', 'REG_DWORD', $_Column[9]) ;~ Reg_Write($REG_KEY_NAME, 'ColumnAutoItPath', 'REG_DWORD', $_Column[10]) ;~ Reg_Write($REG_KEY_NAME, 'ColumnAutoItCmdLine', 'REG_DWORD', $_Column[11]) Reg_Write($REG_KEY_NAME, 'CaptureWidth', 'REG_DWORD', $_Crop[0]) Reg_Write($REG_KEY_NAME, 'CaptureHeight', 'REG_DWORD', $_Crop[1]) Reg_Write($REG_KEY_NAME, 'LiveCapture', 'REG_DWORD', $_Capture) Reg_Write($REG_KEY_NAME, 'AutoItVisible', 'REG_DWORD', $_All) Reg_Write($REG_KEY_NAME, 'AutoItJustAutoItV3', 'REG_DWORD', $_AllJustAutoItv3) Reg_Write($REG_KEY_NAME, 'EmergencyClose', 'REG_DWORD', $_EmergencyCloseOn, " ; 1 = Yes, 0 = No") Reg_Write($REG_KEY_NAME, 'UiaSpy', 'REG_DWORD', $_UiaSpy, " ; 1 = Yes, 0 = No") Reg_Write($REG_KEY_NAME, 'EmergencyTryPClose', 'REG_DWORD', $_EmergencyTryPClose) Reg_Write($REG_KEY_NAME, 'EmergencyTryPAu3Exe', 'REG_DWORD', $_EmergencyTryPAu3Exe) Reg_Write($REG_KEY_NAME, 'EmergencyTryPCloseKey', 'REG_DWORD', $_EmergencyTryPCloseKey, " ; use _IsPressed() value in hexadecimal") Reg_Write($REG_KEY_NAME, 'EmergencyTryPAu3ExeKey', 'REG_DWORD', $_EmergencyTryPAu3ExeKey, " ; use _IsPressed() value in hexadecimal") ;~ If @Compiled Then Reg_Write($REG_KEY_NAME, 'Path', 'REG_SZ', @ScriptFullPath) ; not used EndFunc ;==>_WriteRegistry Func Reg_Write($keyname, $valname, $type, $value, $help = "") Local Static $iUseIni = FileExists($GUI_INI) If $iUseIni Then If $type = "REG_DWORD" Then IniWrite($GUI_INI, "Settings", $valname, (StringLeft($value, 1) = "-" ? "-" : "") & "0x" & (StringLeft($value, 1) = "-" ? Hex(StringTrimLeft($value, 1), 6) : Hex($value, 6)) & $help) Else IniWrite($GUI_INI, "Settings", $valname, $value) EndIf Return EndIf RegWrite($keyname, $valname, $type, $value) EndFunc ;==>Reg_Write #EndRegion Additional Functions #Region Hotkey Assigned Functions Func _HK_Edit() Switch _WinAPI_GetFocus() Case 0 Case $hAutoIt If Not _SCAW() Then GUICtrlSendToDummy($Dummy[4]) EndIf Return EndSwitch GUISetAccelerators(0, $hForm) Send('{ENTER}') GUISetAccelerators($Accel, $hForm) EndFunc ;==>_HK_Edit Func _HK_SelectAll() Local $ID = _WinAPI_GetDlgCtrlID(_WinAPI_GetFocus()) For $i = 0 To UBound($Input) - 1 If $Input[$i] = $ID Then _GUICtrlEdit_SetSel($ID, 0, -1) Return EndIf Next GUISetAccelerators(0, $hForm) Send('^a') GUISetAccelerators($Accel, $hForm) EndFunc ;==>_HK_SelectAll #EndRegion Hotkey Assigned Functions #Region GDI+ Functions Func _GDIPlus_CreateBitmapFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0) Local $Ret = DllCall($__g_hGDIPDll, 'uint', 'GdipCreateBitmapFromScan0', 'int', $iWidth, 'int', $iHeight, 'int', $iStride, 'int', $iPixelFormat, 'ptr', $pScan0, 'ptr*', 0) If (@error) Or ($Ret[0]) Then Return SetError(@error, @extended, 0) EndIf Return $Ret[6] EndFunc ;==>_GDIPlus_CreateBitmapFromScan0 #EndRegion GDI+ Functions #Region Windows Message Functions Func _WM_THEMECHANGED($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam ;~ ConsoleWrite(@SEC & ':' & @MSEC & ' _WM_THEMECHANGED('& $hWnd & ', ' & $Msg & ', ' & $wParam & ', ' & $lParam & ')' & @CRLF) If $lParam And $wParam Then AdlibRegister("Adlib_RefreshDefaultColors", 1000) Return $GUI_RUNDEFMSG EndFunc Func Adlib_RefreshDefaultColors() AdlibUnRegister("Adlib_RefreshDefaultColors") If $_Rgb[3] Then $_Rgb[0] = _WinAPI_GetSysColor($_Rgb[6]) If $_Rgb[4] Then $_Rgb[1] = _WinAPI_GetSysColor($_Rgb[7]) If $_Rgb[5] Then $_Rgb[2] = _WinAPI_GetSysColor($_Rgb[8]) GUICtrlSetBkColor($Label[1], $_Rgb[0]) GUICtrlSetBkColor($Label[2], $_Rgb[1]) GUICtrlSetBkColor($Label[3], $_Rgb[2]) $Col[0] = 0xFF000000 + _WinAPI_GetSysColor($COLOR_HIGHLIGHT) ; 0xFF3E60C5 $Col[1] = 0x1E000000 + _WinAPI_GetSysColor($COLOR_HIGHLIGHT) ; 0x1E3E60C5 _SetBitmap($hPic[1], _Capture_X1(0, 0, $_Crop[0] - 10, $_Crop[1] - 10, $Col[0], $Col[1]), 1) _GUICreate_Aux0() GUICtrlCreate_Label_ColorUp() _WinAPI_RedrawWindow($hForm) EndFunc Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) ; Handler from ColorChooser.au3 CC_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch $hWnd Case $hForm Switch _WinAPI_HiWord($wParam) Case $EN_KILLFOCUS _GUICtrlEdit_SetSel(_WinAPI_LoWord($wParam), 0, 0) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tMMI = DllStructCreate('long Reserved[2];long MaxSize[2];long MaxPosition[2];long MinTrackSize[2];long MaxTrackSize[2]', $lParam) Switch $hWnd Case $hForm If IsArray($Area) Then DllStructSetData($tMMI, 'MinTrackSize', $Area[2], 1) DllStructSetData($tMMI, 'MinTrackSize', $Area[3], 2) DllStructSetData($tMMI, 'MaxTrackSize', $Area[2] * 2, 1) DllStructSetData($tMMI, 'MaxTrackSize', @DesktopHeight - 60, 2) EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_GETMINMAXINFO Func WM_LBUTTONDBLCLK($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Switch $hWnd Case $hForm Local $Info = GUIGetCursorInfo($hForm) If (IsArray($Info)) And ($Info[4] = $Pic) And ($hDesktop) And (Not _SCAW()) Then GUICtrlSendToDummy($Dummy[3]) EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_LBUTTONDBLCLK Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Switch $hWnd Case $hForm Local $Info = GUIGetCursorInfo($hForm) If (IsArray($Info)) And ($Info[4] = $Pic) Then GUICtrlSendToDummy($Dummy[2]) EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_LBUTTONDOWN Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam If $Enum Then Return $GUI_RUNDEFMSG EndIf Local $tNMLVCUSTOMDRAW, $tNMITEMACTIVATE = DllStructCreate($tagNMHDR & ';int Item;int SubItem;uint NewState;uint OldState;uint Changed;long X;long Y;lparam lParam;uint KeyFlags', $lParam) ;~ Local $tNMLVCUSTOMDRAW, $tNMITEMACTIVATE = DllStructCreate($tagNMHDR & (@AutoItX64 ? ';int' : '') & ';int Item;int SubItem;uint NewState;uint OldState;uint Changed;long X;long Y;lparam lParam;uint KeyFlags', $lParam) ;~ Local $tNMITEMACTIVATE = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $hFrom = DllStructGetData($tNMITEMACTIVATE, 'hWndFrom') Local $Index = DllStructGetData($tNMITEMACTIVATE, 'Item') Local $ID = DllStructGetData($tNMITEMACTIVATE, 'Code') Local $hItem, $State = False, $Stage Switch $hFrom Case $hHeader[0] Switch $ID Case $HDN_ITEMCHANGEDW $_Column[$Index + 0] = _GUICtrlListView_GetColumnWidth($hListView, $Index) EndSwitch Case $hHeader[1] Switch $ID Case $HDN_ITEMCHANGEDW $_Column[$Index + 4] = _GUICtrlListView_GetColumnWidth($hAutoIt, $Index) EndSwitch Case $hListView Switch $ID Case $LVN_BEGINDRAG Return 0 Case $NM_CUSTOMDRAW ;~ $tNMLVCUSTOMDRAW = DllStructCreate($tagNMHDR & (@AutoItX64 ? ';int' : '') & ';dword DrawStage;hwnd hDC;long Left;long Top;long Right;long Bottom;dword_ptr ItemSpec;uint ItemState;lparam ItemlParam;dword clrText;dword clrTextBk;int SubItem;dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartId;int StateId;long TextLeft;long TextTop;long TextRight;long TextBottom;uint Align', $lParam) $tNMLVCUSTOMDRAW = DllStructCreate($tagNMHDR & ';dword DrawStage;hwnd hDC;long Left;long Top;long Right;long Bottom;dword_ptr ItemSpec;uint ItemState;lparam ItemlParam;dword clrText;dword clrTextBk;int SubItem;dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartId;int StateId;long TextLeft;long TextTop;long TextRight;long TextBottom;uint Align', $lParam) ;~ Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) $Stage = DllStructGetData($tNMLVCUSTOMDRAW, 'DrawStage') $Index = DllStructGetData($tNMLVCUSTOMDRAW, 'ItemSpec') Local $BGR = $_Rgb[0] Switch $Stage Case $CDDS_ITEMPREPAINT Return $CDRF_NOTIFYSUBITEMDRAW Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) $hItem = Ptr(_GUICtrlListView_GetItemText($hListView, $Index)) If _WinAPI_IsWindow($hItem) Then $State = _WinAPI_IsWindowVisible($hItem) If Not $State Then $BGR = $_Rgb[1] EndIf Else $BGR = $_Rgb[2] If $hItem Then _GUICtrlListView_SetItemText($hListView, $Index, $hItem & ChrW(160)) $hItem = 0 EndIf EndIf If _GUICtrlListView_GetItemChecked($hListView, $Index) <> $State Then _GUICtrlListView_SetItemChecked($hListView, $Index, $State) _GUICtrlListView_RedrawItems($hListView, $Index, $Index) If ($hItem) And (Not $Refresh) And (_GUICtrlListView_GetItemState($hListView, $Index, $LVIS_SELECTED)) Then GUICtrlSendToDummy($Dummy[1], $Index) EndIf EndIf If $_ColoringCtrls Then If $BGR Then DllStructSetData($tNMLVCUSTOMDRAW, 'clrText', _WinAPI_SwitchColor($BGR)) EndIf EndIf EndSwitch Case $LVN_ITEMCHANGING If Not _GUICtrlListView_GetItemChecked($hListView, $Index) Then _GUICtrlListView_SetItemParam($hListView, $Index, 0x7FFFFFFF) Else _GUICtrlListView_SetItemParam($hListView, $Index, 0) EndIf Case $LVN_ITEMCHANGED $hItem = Ptr(_GUICtrlListView_GetItemText($hListView, $Index)) If _GUICtrlListView_GetItemParam($hListView, $Index) Then $State = 1 EndIf If _GUICtrlListView_GetItemChecked($hListView, $Index) <> $State Then If (BitAND(DllStructGetData($tNMITEMACTIVATE, 'NewState'), $LVIS_SELECTED)) And (Not BitAND(DllStructGetData($tNMITEMACTIVATE, 'OldState'), $LVIS_FOCUSED)) Then If _WinAPI_IsWindow($hItem) Then If Not $Browser Then If _WinAPI_IsWindowVisible($hItem) Then _ShowFrame(1, _WinAPI_GetWindowRect($hItem), _WinAPI_GetParent($hItem)) $hOver = $hItem Else _ShowFrame(0) $hOver = 0 EndIf EndIf _SetControlInfo($hItem) Else _SetControlInfo(0) EndIf EndIf If Not $Browser Then GUICtrlSendToDummy($Dummy[0], $Index) EndIf Else If Not $Refresh Then If _WinAPI_IsWindow($hItem) Then If _WinAPI_IsWindowVisible($hItem) Then ControlHide($hItem, '', '') $State = 0 Else ControlShow($hItem, '', '') $State = 1 EndIf If (_WinAPI_IsWindow($hItem)) And (_WinAPI_IsWindowVisible($hItem) = $State) And (_GUICtrlListView_GetItemState($hListView, $Index, $LVIS_SELECTED)) Then _SetControlInfo($hItem) EndIf _Update() EndIf EndIf EndIf EndSwitch Case $hAutoIt Switch $ID Case $LVN_BEGINDRAG Return 0 Case $NM_CUSTOMDRAW ;~ $tNMLVCUSTOMDRAW = DllStructCreate($tagNMHDR & (@AutoItX64 ? ';int' : '') & ';dword DrawStage;hwnd hDC;long Left;long Top;long Right;long Bottom;dword_ptr ItemSpec;uint ItemState;lparam ItemlParam;dword clrText;dword clrTextBk;int SubItem;dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartId;int StateId;long TextLeft;long TextTop;long TextRight;long TextBottom;uint Align', $lParam) $tNMLVCUSTOMDRAW = DllStructCreate($tagNMHDR & ';dword DrawStage;hwnd hDC;long Left;long Top;long Right;long Bottom;dword_ptr ItemSpec;uint ItemState;lparam ItemlParam;dword clrText;dword clrTextBk;int SubItem;dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartId;int StateId;long TextLeft;long TextTop;long TextRight;long TextBottom;uint Align', $lParam) ;~ Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) $Stage = DllStructGetData($tNMLVCUSTOMDRAW, 'DrawStage') $Index = DllStructGetData($tNMLVCUSTOMDRAW, 'ItemSpec') Switch $Stage Case $CDDS_ITEMPREPAINT Return $CDRF_NOTIFYSUBITEMDRAW Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) If $_ColoringCtrls Then Switch _GUICtrlListView_GetItemParam($hAutoIt, $Index) Case 0x7FFFFFFF DllStructSetData($tNMLVCUSTOMDRAW, 'clrText', _WinAPI_SwitchColor($_Rgb[1])) Case 0x7FFFFFF9 DllStructSetData($tNMLVCUSTOMDRAW, 'clrText', _WinAPI_SwitchColor($_Rgb[2])) Case Else DllStructSetData($tNMLVCUSTOMDRAW, 'clrText', _WinAPI_SwitchColor($_Rgb[0])) EndSwitch EndIf EndSwitch Case $LVN_ITEMACTIVATE GUICtrlSendToDummy($Dummy[4]) Case $LVN_KEYDOWN If Not _SCAW() Then Switch BitAND($Index, 0xFF) Case 0x2E ; DEL GUICtrlSendToDummy($Dummy[5]) Case 0x74 ; F5 GUICtrlSendToDummy($Dummy[6]) EndSwitch EndIf Case $NM_RCLICK ShowMenu($hForm, $hAutoItCreated, $hAutoitContext, 1) EndSwitch Case $hTab Switch $ID Case $TCN_SELCHANGE $_Tab = _GUICtrlTab_GetCurSel($hTab) If $_Tab = 3 Then _SetAutoItInfo() EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local $tPlacement Switch $hWnd Case $hForm If Not _WinAPI_IsIconic($hForm) Then $tPlacement = _WinAPI_GetWindowPlacement($hForm) $_XPos = DllStructGetData($tPlacement, 'rcNormalPosition', 1) $_YPos = DllStructGetData($tPlacement, 'rcNormalPosition', 2) ;~ If $_XPos < 0 Then ;~ $_XPos = 0 ;~ EndIf ;~ If $_YPos < 0 Then ;~ $_YPos = 0 ;~ EndIf EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOVE Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Switch $hWnd Case $hForm Switch $wParam Case 0 ; SIZE_RESTORED $_Width = _WinAPI_LoWord($lParam) $_Height = _WinAPI_HiWord($lParam) EndSwitch SizeboxResize() EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func FormResize() SizeboxResize() Local $aSize = WinGetPos($hForm) WinMove($hForm, "", $aSize[0], $aSize[1], $_Width + ($_SM_CXSIZEFRAME * 2), $aSize[3]) EndFunc ;==>FormResize Func SizeboxResize() Local $aSize = WinGetClientSize($hForm) WinMove($hSizebox, "", $aSize[0] - 15, $aSize[1] - 15) EndFunc ;==>SizeboxResize Func WM_SETCURSOR($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam If $Browser Then Return $GUI_RUNDEFMSG EndIf Local $Info, $dX, $dY, $ID = -1 Switch $hWnd Case 0 Case $hForm, $hPopup If $Resize = -1 Then $Info = GUIGetCursorInfo($hForm) If (IsArray($Info)) And ($Info[4] = $Pic) Then Switch _IsCrop($Info[0], $Info[1], $dX, $dY) Case 0 If _IsDown(0x11) Then ; 11 CTRL key If $hDesktop Then If _IsDown($Key) Then $ID = 2 Else $ID = 1 EndIf EndIf EndIf Case 1, 5 $ID = 3 Case 2, 6 $ID = 4 Case 3, 7 $ID = 5 Case 4, 8 $ID = 6 EndSwitch EndIf Else $ID = $Resize EndIf If $ID <> -1 Then _WinAPI_SetCursor($hCursor[$ID]) Return 1 EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_SETCURSOR #EndRegion Windows Message Functions #Region AutoIt Exit Functions Func AutoItExit() ;~ Switch @ExitMethod ;~ Case 3, 4 ; Logoff, Shutdown ;~ Case Else _WriteRegistry() ;~ EndSwitch If $hPrev Then _WinAPI_SetSystemCursor($hPrev, $IDI_APPLICATION, 1) EndIf If $hForm Then GUIDelete($hFrame) GUIDelete($hForm) EndIf _GDIPlus_Shutdown() ;~ For $i = 0 To 7 ;~ _WinAPI_DestroyCursor($hCursor[$i]) ;~ Next DllClose($hDLLuser32) EndFunc ;==>AutoItExit #EndRegion AutoIt Exit Functions #Region Emergency Functions Func Emergency_HotKey_GuiMsg($Msg) Local $i = 0, $n = 0, $timr Switch $Msg Case $BttnEC[0] If Not @Compiled Then Return GUICtrlSetState($BttnEC[0], $GUI_DISABLE) ProcessClose_AutoIt3s() GUICtrlSetState($BttnEC[0], $GUI_ENABLE) $HotKeyd = 0 If _GUICtrlTab_GetCurSel($hTab) = 3 Then _SetAutoItInfo() Case $BttnEC[1] GUICtrlSetState($BttnEC[1], $GUI_DISABLE) $timr = TimerInit() While WinClose_CLASS_AutoIt_v3($n) If TimerDiff($timr) > 5000 Then $i = 1 ExitLoop EndIf Sleep(200) WEnd $HotKeyd = 0 If $i Then ToolTip('Done ' & @extended & ' with WinClose("[CLASS:AutoIt v3;]")', 50, 50, "Emergency close FAILED!", 3) If $_EmergencyTryPClose Then $HotKeyd = $BttnEC[2] ElseIf $_EmergencyTryPAu3Exe Then $HotKeyd = $BttnEC[0] EndIf Else ToolTip('Done "' & @extended & '" with WinClose("[CLASS:AutoIt v3;]")', 50, 50, "Emergency close done in " & Round(TimerDiff($timr)) & " ms.", 1) EndIf AdlibRegister("Emergency_CloseToolTip", 3000) GUICtrlSetState($BttnEC[1], $GUI_ENABLE) If _GUICtrlTab_GetCurSel($hTab) = 3 Then _SetAutoItInfo() Case $BttnEC[2] $timr = TimerInit() GUICtrlSetState($BttnEC[2], $GUI_DISABLE) While ProcessClose_CLASS_AutoIt_v3($n) If TimerDiff($timr) > 10000 Then $i = 1 ExitLoop EndIf Sleep(200) WEnd If $i Then ToolTip('Done "' & @extended & '" with ProcessClose("[CLASS:AutoIt v3;]")', 50, 50, "Emergency close FAILED!", 3) If $_EmergencyTryPAu3Exe Then $HotKeyd = $BttnEC[0] EndIf Else ToolTip('Done "' & @extended & '" with ProcessClose("[CLASS:AutoIt v3;]")', 50, 50, "Emergency close done in " & Round(TimerDiff($timr)) & " ms.", 1) EndIf AdlibRegister("Emergency_CloseToolTip", 3000) GUICtrlSetState($BttnEC[2], $GUI_ENABLE) $HotKeyd = 0 If _GUICtrlTab_GetCurSel($hTab) = 3 Then _SetAutoItInfo() Case $BttnEC[3] GUICtrlSetState($BttnEC[3], $GUI_DISABLE) If Not FileExists(@ScriptDir & "\CV.EXEMPT.TXT") Then FileWriteLine(@ScriptDir & "\CV.EXEMPT.TXT", @TAB & "These first 5 lines are not included as they are meant for this help." & @CRLF & _ @TAB & 'each line is the AutoItWinGetTitle() to be exempt from WinClose and ProcessClose as seen with Opt("WinTitleMatchMode",1)' & @CRLF & _ @TAB & "Close this Editor's PID to reenable the button and reload the file." & @CRLF & _ @TAB & 'ProcessClose("AutoIt3*.exe") will close all AutoIt3*.exe process regardless of the exempt list.' & @CRLF & _ @TAB & "--- End of help ---" & @CRLF & $GUI_UNIQUE & @CRLF & "AutoIt3Compiler_" & @CRLF) $_ExmptPid = ShellExecute(@ScriptDir & "\CV.EXEMPT.TXT") Case $BttnEC[4] If GUICtrlRead($BttnEC[4]) = 1 Then If HotKeySet("!+^{BREAK}", "Emergency_HotKey_Pressed") Then ; Alt-Ctrl-Shift-Break _GUICtrlTab_SetItemImage($hTab, 4, 5) $_EmergencyCloseOn = 1 $g_EmergencyCloseIsOn = 1 Else _GUICtrlTab_SetItemImage($hTab, 4, 4) $_EmergencyCloseOn = 0 $g_EmergencyCloseIsOn = 0 GUICtrlSetState($BttnEC[4], $GUI_UNCHECKED) ToolTip('..in use by another process', MouseGetPos(0), MouseGetPos(1), "HotKeySet() FAILED !", 2) AdlibRegister("Emergency_CloseToolTip", 1000) EndIf Else _GUICtrlTab_SetItemImage($hTab, 4, 4) HotKeySet("!+^{BREAK}") $_EmergencyCloseOn = 0 $g_EmergencyCloseIsOn = 0 EndIf Case $BttnEC[5] $_EmergencyTryPClose = 0 If GUICtrlRead($BttnEC[5]) = 1 Then $_EmergencyTryPClose = 1 Case $BttnEC[6] $_EmergencyTryPAu3Exe = 0 If GUICtrlRead($BttnEC[6]) = 1 Then $_EmergencyTryPAu3Exe = 1 EndSwitch EndFunc ;==>Emergency_HotKey_GuiMsg Func TrayItemSet_Icon($hMenu, $iCmdID, $iIndex) If @Compiled Then _GUICtrlMenu_SetItemBmp($hMenu, $iCmdID, _WinAPI_Create32BitHBITMAP(_WinAPI_ShellExtractIcon(@ScriptFullPath, $iIndex, 16, 16), 1, 1), False) Else _GUICtrlMenu_SetItemBmp($hMenu, $iCmdID, _WinAPI_Create32BitHBITMAP(_WinAPI_ExtractIcon(@ScriptDir & "\Resources\" & 199 + $iIndex & ".ico", 0, True), 1, 1), False) EndIf EndFunc ;==>TrayItemSet_Icon Func Emergency_Tray_On() Local Static $iIsMenuCreated = 0 ;, $hMenu = 0 WinSetState($hForm, "", @SW_HIDE) If Not $iIsMenuCreated Then TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN, "Emergency_Tray_ShowContextMenu") TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Emergency_Tray_ShowGui") $iIsMenuCreated = 1 EndIf TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. TraySetClick(16) TraySetToolTip($GUI_NAME & @CR & @CR & " ") $g_iTray_IsNotOn = 0 EndFunc ;==>Emergency_Tray_On Func Emergency_Tray_ShowContextMenu() Local Static $hGuiContext = GUICreate(ScriptNameOnly() & "_GuiContextMenu", 0, 0, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP), $WS_EX_TOPMOST, $hForm) Local Enum $e_idCPA = 1001, $e_idWCC, $e_idCPC, $e_idShowGUI, $e_idExit Local $i, $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_AddMenuItem($hMenu, Chr(160) & 'ProcessClose("AutoIt3*.exe")', $e_idCPA) _GUICtrlMenu_AddMenuItem($hMenu, Chr(160) & 'WinClose("[CLASS:AutoIt v3;]")', $e_idWCC) _GUICtrlMenu_AddMenuItem($hMenu, Chr(160) & 'ProcessClose("[CLASS:AutoIt v3;]")', $e_idCPC) _GUICtrlMenu_AddMenuItem($hMenu, "", 0) _GUICtrlMenu_AddMenuItem($hMenu, Chr(160) & "Show GUI", $e_idShowGUI) _GUICtrlMenu_SetItemDefault($hMenu, $e_idShowGUI, True, False) _GUICtrlMenu_AddMenuItem($hMenu, "", 0) _GUICtrlMenu_AddMenuItem($hMenu, Chr(160) & "Exit", $e_idExit) TrayItemSet_Icon($hMenu, $e_idCPA, 10) TrayItemSet_Icon($hMenu, $e_idWCC, 10) TrayItemSet_Icon($hMenu, $e_idCPC, 10) TrayItemSet_Icon($hMenu, $e_idShowGUI, 5) TrayItemSet_Icon($hMenu, $e_idExit, 9) GUISetState(@SW_SHOW, $hGuiContext) $i = _GUICtrlMenu_TrackPopupMenu($hMenu, $hGuiContext, -1, -1, 1, 1, 2) GUISetState(@SW_HIDE, $hGuiContext) _GUICtrlMenu_DestroyMenu($hMenu) Switch $i Case 0 ; nothing Case $e_idCPA $HotKeyd = $BttnEC[0] Case $e_idWCC $HotKeyd = $BttnEC[1] Case $e_idCPC $HotKeyd = $BttnEC[2] Case $e_idShowGUI Emergency_Tray_ShowGui() Case $e_idExit Emergency_Tray_ExitScript() EndSwitch EndFunc ;==>Emergency_Tray_ShowContextMenu Func Emergency_Tray_ShowGui() If Not $g_iTray_IsNotOn Then Send("{ESC}") ; ..to help the tray area to "go away" TraySetState($TRAY_ICONSTATE_HIDE) ; Hide the tray menu. WinSetState($hForm, "", @SW_SHOW) WinActivate($hForm) $g_iTray_IsNotOn = 1 ;~ Local $a = GetProgmanPos() If @extended Then WinMove($hForm, "", $_XPos, $_YPos) EndFunc ;==>Emergency_Tray_ShowGui Func Emergency_Tray_ExitScript() GUIDelete() _FMIPC_Close() Exit EndFunc ;==>Emergency_Tray_ExitScript Func Emergency_CloseToolTip() AdlibUnRegister("Emergency_CloseToolTip") ToolTip("") EndFunc ;==>Emergency_CloseToolTip Func Emergency_HotKey_Pressed() If _IsDown($_EmergencyTryPAu3ExeKey) Then ; 0x5A = Z key ; 'ProcessClose("AutoIt3*.exe")' $HotKeyd = $BttnEC[0] ElseIf _IsDown($_EmergencyTryPCloseKey) Then ; 0x41 = A key ; 'ProcessClose("[CLASS:AutoIt v3;]")' $HotKeyd = $BttnEC[2] Else $HotKeyd = $BttnEC[1] EndIf EndFunc ;==>Emergency_HotKey_Pressed Func ProcessClose_AutoIt3s() Local $c, $i = 0, $t = TimerInit() ToolTip("ProcessClose: AutoIt3 # " & $i, 50, 50, "Emergency close ! (" & 20 - Round(TimerDiff($t) / 1000) & " sec.)", 1) Do $c = 0 While ProcessExists("Autoit3.exe") $i += 1 ToolTip("ProcessClose: AutoIt3.exe # " & $i, 50, 50, "Emergency close ! (" & 20 - Round(TimerDiff($t) / 1000) & " sec.)", 1) ProcessClose("AutoIt3.exe") If Not Mod($i, 1000) Then ExitLoop WEnd While ProcessExists("AutoIt3_x64.exe") $i += 1 ToolTip("ProcessClose: AutoIt3_x64.exe # " & $i, 50, 50, "Emergency close ! (" & 20 - Round(TimerDiff($t) / 1000) & " sec.)", 1) ProcessClose("AutoIt3_x64.exe") If Not Mod($i, 1000) Then ExitLoop WEnd If TimerDiff($t) < 5000 And $c Then Sleep(1000) If TimerDiff($t) > 20000 Then ExitLoop Until (Not ProcessExists("AutoIt3.exe") And Not ProcessExists("AutoIt3_x64.exe")) If Not $c Then ToolTip('ProcessClose: "' & $i & '" AutoIt3''s', 50, 50, "Emergency close done in " & Round(TimerDiff($t)) & " ms.", 1) AdlibRegister("Emergency_CloseToolTip", 2000) Else ToolTip("ProcessClose: " & $i & " AutoIt3's", 50, 50, "Emergency close FAILED !", 3) AdlibRegister("Emergency_CloseToolTip", 5000) EndIf Return $i EndFunc ;==>ProcessClose_AutoIt3s Func Emergency_Exempt($sTitle, $iLoad = 0) Local Static $a If $iLoad Then $a = StringSplit($sTitle, @CRLF, 1) For $n = 1 To 5 _ArrayDelete($a, 1) Next For $n = UBound($a) - 1 To 0 Step -1 If StringStripWS($a[$n], 3) = "" Then _ArrayDelete($a, $n) Next $a[0] = UBound($a) - 1 Return $a[0] EndIf If StringInStr($sTitle, $GUI_UNIQUE) Then Return True For $n = 1 To $a[0] If StringInStr($sTitle, $a[$n]) Then Return True Next Return False EndFunc ;==>Emergency_Exempt Func WinClose_CLASS_AutoIt_v3(ByRef $i) Local $c = 0, $n, $aWinList = WinList("[CLASS:AutoIt v3;]") If UBound($aWinList) < 2 Then Return SetError(0, $i, 0) Local $iWinTitleMatchMode = Opt("WinTitleMatchMode", 1) ToolTip(' WinClose: ' & UBound($aWinList) - 2 & ' "[CLASS:AutoIt v3;]" ', 50, 50, "Emergency close !", 1) For $n = UBound($aWinList) - 1 To 1 Step -1 If Emergency_Exempt($aWinList[$n][0]) Then $aWinList[0][0] -= 1 ContinueLoop EndIf WinClose($aWinList[$n][1]) $i += 1 ToolTip(' WinClose: ' & $i & ' of ' & $aWinList[0][0] & ' "[CLASS:AutoIt v3;]" ', 50, 50, "Emergency close !", 1) $c += 1 Next Opt("WinTitleMatchMode", $iWinTitleMatchMode) Return SetError(0, $i, $c) EndFunc ;==>WinClose_CLASS_AutoIt_v3 Func ProcessClose_CLASS_AutoIt_v3(ByRef $i) Local $c = 0, $p, $n, $aWinList = WinList("[CLASS:AutoIt v3;]") Local $iWinTitleMatchMode = Opt("WinTitleMatchMode", 1) ToolTip(' ProcessClose: ' & UBound($aWinList) - 2 & ' "[CLASS:AutoIt v3;]" ', 50, 50, "Emergency close !", 1) For $n = UBound($aWinList) - 1 To 1 Step -1 If Emergency_Exempt($aWinList[$n][0]) Then $aWinList[0][0] -= 1 ContinueLoop EndIf $p = WinGetProcess($aWinList[$n][1]) ProcessClose($p) $i += 1 ToolTip(' ProcessClose: ' & $i & ' of ' & $aWinList[0][0] & ' "[CLASS:AutoIt v3;]" ', 50, 50, "Emergency close !", 1) $c += 1 Next Opt("WinTitleMatchMode", $iWinTitleMatchMode) Return SetError(0, $i, $c) EndFunc ;==>ProcessClose_CLASS_AutoIt_v3 #EndRegion Emergency Functions #Region Context menu ; Show a menu in a given GUI window which belongs to a given GUI ctrl Func ShowMenu($hWnd, $idCtrl, $idContext, $iUseMousePos = 0) Local $aPos, $x, $y Local $hMenu = GUICtrlGetHandle($idContext) If $iUseMousePos Then $aPos = MouseGetPos() $x = $aPos[0] + 20 $y = $aPos[1] - 20 Else $aPos = ControlGetPos($hWnd, "", $idCtrl) $x = $aPos[0] $y = $aPos[1] + $aPos[3] ClientToScreen($hWnd, $x, $y) EndIf TrackPopupMenu($hWnd, $hMenu, $x, $y) EndFunc ;==>ShowMenu ; Convert the client (GUI) coordinates to screen (desktop) coordinates Func ClientToScreen($hWnd, ByRef $x, ByRef $y) Local $tPoint = DllStructCreate("int;int") DllStructSetData($tPoint, 1, $x) DllStructSetData($tPoint, 2, $y) ;DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "struct*", $tPoint) _WinAPI_ClientToScreen($hWnd, $tPoint) $x = DllStructGetData($tPoint, 1) $y = DllStructGetData($tPoint, 2) ; release Struct not really needed as it is a local $tPoint = 0 EndFunc ;==>ClientToScreen ; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd) Func TrackPopupMenu($hWnd, $hMenu, $x, $y) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==>TrackPopupMenu Func WinHandleStrToHWND($s) Local $n, $a = WinList() ; "[CLASS:AutoIt v3]" For $n = 1 To $a[0][0] If $a[$n][1] = $s Then Return $a[$n][1] Next Return SetError(1, 0, 0) EndFunc ;==>WinHandleStrToHWND Func AutoitMenuItemDo($1) Local $H Switch $1 Case $hAutoitMenuItem_ClipPutCmdLine ToolTip(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 7), MouseGetPos(0), MouseGetPos(1), "ClipPut()") ClipPut(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 7)) Sleep(1500) ToolTip("") Case $hAutoitMenuItem_ClipPutTitle ToolTip(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 4), MouseGetPos(0), MouseGetPos(1), "ClipPut()") ClipPut(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 4)) Sleep(1500) ToolTip("") Case $hAutoitMenuItem_ClipPutHandle ToolTip(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 2), MouseGetPos(0), MouseGetPos(1), "ClipPut()") ClipPut(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 2)) Sleep(1500) ToolTip("") Case $hAutoitMenuItem_BrowseToFile $Data = _GUICtrlListView_GetSelectedIndices($hAutoIt) If $Data Then ;~ If $_mOnBr Then GUISetState(@SW_MINIMIZE, $hForm) $Data = _GUICtrlListView_GetItemText($hAutoIt, $Data, 6) If $Data Then _WinAPI_ShellOpenFolderAndSelectItems($Data) EndIf EndIf Case $hAutoitMenuItem_SetTopmost_Yes $H = WinHandleStrToHWND(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 2)) WinActivate($H) WinSetOnTop($H, "", 1) Case $hAutoitMenuItem_SetTopmost_No $H = WinHandleStrToHWND(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 2)) WinActivate($H) WinSetOnTop($H, "", 0) Case $hAutoitMenuItem_show $H = WinHandleStrToHWND(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 2)) WinSetState($H, "", @SW_SHOW) WinActivate($H) Case $hAutoitMenuItem_hide WinSetState(WinHandleStrToHWND(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 2)), "", @SW_HIDE) Case $hAutoitMenuItem_processclose ProcessClose(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 1)) Send("{F5}") Case $hAutoitMenuItem_process_CloseByName Local $i = 0 While ProcessExists(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 0)) $i += 1 ToolTip("ProcessClose - Round " & $i) ProcessClose(_GUICtrlListView_GetItemText($hAutoIt, _GUICtrlListView_GetSelectedIndices($hAutoIt, False), 0)) If $i > 99 Then ExitLoop WEnd ToolTip("") Send("{F5}") EndSwitch EndFunc ;==>AutoitMenuItemDo #EndRegion Context menu #Region UIA ; code from https://github.com/jvanegmond/au3_uiautomation Func _UIA__ShowProperties($oUIElement) Local $s, $Text = _UIA_ControlGetText(Default, $oUIElement) If StringInStr($Text, @CRLF) Then $Text = StringLeft($Text, StringInStr($Text, @CRLF, 0, 4) - 2) & " ... " $s &= "Id: " & _UIA_GetPropertyValue($oUIElement, $UIA_AutomationIdPropertyId) & @CRLF $s &= "Text: " & $Text & @CRLF $s &= "Class: " & _UIA_GetPropertyValue($oUIElement, $UIA_ClassNamePropertyId) & @CRLF $s &= "Native handle: " & _UIA_GetPropertyValue($oUIElement, $UIA_NativeWindowHandlePropertyId) & @CRLF $s &= "Bounding box: " & _ArrayToString(_UIA_GetPropertyValue($oUIElement, $UIA_BoundingRectanglePropertyId), ", ") & @CRLF Return $s ;~ GUICtrlSetData($Edit, $s) EndFunc ;==>_UIA__ShowProperties Func _UIA__CoordEquals($a, $b) If Not IsArray($a) Or Not IsArray($b) Then Return False For $i = 0 To UBound($a) - 1 If $a[$i] <> $b[$i] Then Return False Next Return True EndFunc ;==>_UIA__CoordEquals Func _UIA__Hide() If Not $_UiaSpy Then Return If Not IsObj($UIA_oUIAutomation) Then Return _UIA__ShowFrme(False) EndFunc ;==>_UIA__Hide Func _UIA__Show() If Not $_UiaSpy Then Return If Not IsObj($UIA_oUIAutomation) Then Return Local Static $UIA_MPosWas[2] Local $UIA_MPosIs = MouseGetPos() If _UIA__CoordEquals($UIA_MPosWas, $UIA_MPosIs) Then Return $UIA_MPosWas = $UIA_MPosIs If $hFrameIsShown Then GUISetState(@SW_HIDE, $hFrame) $UIA_oUIElement = _UIA_GetElementFromPoint($UIA_MPosIs) $UIA_controlPos = _UIA_ControlGetPos(0, $UIA_oUIElement) If Not @error And Not _UIA__CoordEquals($UIA_lastKnownPos, $UIA_controlPos) Then $UIA_lastKnownPos = $UIA_controlPos _UIA__ShowFrme(True, $UIA_oUIElement, $UIA_controlPos) EndIf If $hFrameIsShown Then GUISetState(@SW_SHOWNOACTIVATE, $hFrame) EndFunc ;==>_UIA__Show Func _UIA__ShowFrme($fShow, $Element = Null, $Pos = 0) Local Static $UIA_FrameAlpha = 192 ; Constant Local Static $UIA_FrameColor = 0x00FF00 ; Constant Local Static $UIA_Thickness = 2 ; Constant Local Static $UIA_hParent ;~ Local Static $UIA_hFrame[4] If Not $UIA_hParent Then $UIA_hParent = GUICreate("", 100, 100) ; Don't show this to avoid windows appearing in task bar ; WinGetHandle($GUI_UNIQUE) ; For $n = 0 To 3 $UIA_hFrame[$n] = GUICreate("", 100, 100, -1, -1, $WS_POPUP, -1, $UIA_hParent) GUISetBkColor($UIA_FrameColor, $UIA_hFrame[$n]) WinSetTrans($UIA_hFrame[$n], "", $UIA_FrameAlpha) Next EndIf If Not $fShow Or UBound($Pos) <> 4 Then For $n = 0 To 3 GUISetState(@SW_HIDE, $UIA_hFrame[$n]) Next Return EndIf ; If the given element is one of our frame windows, do not change the frame Local $UIA_hWnd = _UIA_GetPropertyValue($Element, $UIA_NativeWindowHandlePropertyId) For $n = 0 To 3 If Int($UIA_hFrame[$n]) == Int($UIA_hWnd) Then Return Next GUICtrlSetData($UIA_Ctrls[2], _UIA__ShowProperties($Element)) WinMove($UIA_hFrame[0], "", $Pos[0], $Pos[1], $UIA_Thickness, $Pos[3]) ; Left WinMove($UIA_hFrame[1], "", $Pos[0], $Pos[1], $Pos[2], $UIA_Thickness) ; Top WinMove($UIA_hFrame[2], "", $Pos[0] + $Pos[2] - $UIA_Thickness, $Pos[1], $UIA_Thickness, $Pos[3]) ; Right WinMove($UIA_hFrame[3], "", $Pos[0], $Pos[1] + $Pos[3] - $UIA_Thickness, $Pos[2], $UIA_Thickness) ; Bottom For $n = 0 To 3 GUISetState(@SW_SHOWNOACTIVATE, $UIA_hFrame[$n]) WinSetOnTop($UIA_hFrame[$n], "", $WINDOWS_ONTOP) Next EndFunc ;==>_UIA__ShowFrme #EndRegion UIA Func _CloneGui($OnlyChecked = 0) Local $mPos = MouseGetPos(), $sInclude, $sSource, $n, $i_ItemCount = _GUICtrlListView_GetItemCount($hListView) - 1 Local $s__Class, $s__Instance, $s__vStyle, $s__vExStyle, $s__sStyle, $s__sExStyle, $s__PosX, $s__PosY, $s__SizeH, $s__SizeW, $s__CtrlType Local $sGlobal = "$Clnd_Form" $sInclude = '#include ; :-----------------------------:' & @CRLF $sInclude &= '#include ; : remove what is not needed :' & @CRLF $sInclude &= '#include ; : and add what is missing. :' & @CRLF $sInclude &= '#include ; :-----------------------------:' & @CRLF $sInclude &= '#include ' & @CRLF $sInclude &= '#include ; :------------------------:' & @CRLF $sInclude &= "#include ; : This is not perfect, :" & @CRLF $sInclude &= '#include ; : just a starting point :' & @CRLF $sInclude &= '#include ; : for Win32 controls. :' & @CRLF $sInclude &= '#include ; :------------------------:' & @CRLF $sInclude &= '#include ' & @CRLF $sSource = '' & @CRLF $sSource &= '#Region ### START cloned GUI section ###' & @CRLF $sSource &= '; *** replace "Clnd" with your own prefix ( Ctrl + H from within SciTE ) ***' & @CRLF $sSource &= '_Clnd_Gui()' & @CRLF $sSource &= 'Func _Clnd_Gui()' & @CRLF $sSource &= @TAB & 'Local $_Left = 0, $_Top = 0 ; These are used to easily reposition the controls' & @CRLF $sSource &= @TAB & '$Clnd_Form = GUICreate("Cloned: ' & GUICtrl_ReadForClone($Input[3]) & '", ' & _ GUICtrl_ReadForClone($Input[11]) & ', ' & GUICtrl_ReadForClone($Input[12]) & ');, ' & GUICtrl_ReadForClone($Input[9]) & ', ' & GUICtrl_ReadForClone($Input[10]) & ');, ' & _ GUICtrl_ReadForClone($Input[5]) & ', ' & GUICtrl_ReadForClone($Input[7]) & ') ; Style: ' & GUICtrl_ReadForClone($Input[6]) & ' ; ExStyle: ' & GUICtrl_ReadForClone($Input[8]) & @CRLF For $n = 0 To $i_ItemCount _GUICtrlListView_EnsureVisible($hListView, $n) _GUICtrlListView_SetItemSelected($hListView, $n, True, True) If $OnlyChecked And Not _GUICtrlListView_GetItemChecked($hListView, $n) Then ContinueLoop ;~ $s_Class = _GUICtrlListView_GetItemText($hListView, $n, 1) ;~ $s_NN = _GUICtrlListView_GetItemText($hListView, $n, 2) $s__Class = GUICtrl_ReadForClone($Input[16]) $s__Instance = GUICtrl_ReadForClone($Input[17]) $s__vStyle = GUICtrl_ReadForClone($Input[21]) $s__vExStyle = GUICtrl_ReadForClone($Input[23]) $s__sStyle = GUICtrl_ReadForClone($Input[22]) $s__sExStyle = GUICtrl_ReadForClone($Input[24]) $s__PosX = GUICtrl_ReadForClone($Input[25]) $s__PosY = GUICtrl_ReadForClone($Input[26]) $s__SizeH = GUICtrl_ReadForClone($Input[28]) $s__SizeW = GUICtrl_ReadForClone($Input[27]) $s__CtrlType = $s__Class If StringInStr($s__sStyle, "0x00000007") Then $s__CtrlType = "Group" If StringInStr($s__sStyle, "0x00000009") Then $s__CtrlType = "Radio" If StringInStr($s__sStyle, "0x00000080") Then $s__CtrlType = "Input" If StringInStr($s__sStyle, "0x0000010E") Then $s__CtrlType = "Pic" If StringInStr($s__sStyle, "0x00000006") And $s__SizeH > 20 Then $s__CtrlType = "Avi" If StringInStr($s__sStyle, "0x00000103") Then $s__CtrlType = "Icon" If $s__CtrlType = "Button" And $s__SizeH < 20 Then $s__CtrlType = "Checkbox" ConsoleWrite('$s__CtrlType = "' & $s__CtrlType & '"' & @CRLF) Switch $s__CtrlType Case "Group" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateGroup("' & GUICtrl_ReadForClone($Input[30]) & '", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF $sSource &= @TAB & 'GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group' & @CRLF Case "Radio" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateRadio("' & GUICtrl_ReadForClone($Input[30]) & '", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ');, ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "Checkbox" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateCheckbox("' & GUICtrl_ReadForClone($Input[30]) & '", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ');, ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "Button" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateButton("' & GUICtrl_ReadForClone($Input[30]) & '", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "Static" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateLabel("' & GUICtrl_ReadForClone($Input[30]) & '", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "Input" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateInput("' & GUICtrl_ReadForClone($Input[30]) & '", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "Edit" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateEdit("' & GUICtrl_ReadForClone($Input[30]) & '", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "SysTreeView32" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateTreeView(' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "SysTabControl32" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateTab(' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "msctls_progress32" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateProgress(' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "msctls_statusbar32" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = _GUICtrlStatusBar_Create($Clnd_Form)' & @CRLF Case "Pic" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateEdit("' & GUICtrl_ReadForClone($Input[30]) & '", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "Avi" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateAvi("' & GUICtrl_ReadForClone($Input[30]) & '", 0, ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "ListBox" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateList("' & GUICtrl_ReadForClone($Input[30]) & '", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "SysListView32" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateListView("' & GUICtrl_ReadForClone($Input[30]) & '", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "ComboBox" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateCombo("' & GUICtrl_ReadForClone($Input[30]) & '", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "msctls_trackbar32" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateSlider(' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "Icon" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateIcon("explorer.exe", 0, ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF Case "SysDateTimePick32" $sGlobal &= ', $Clnd_' & $s__Class & '_' & $s__Instance $sSource &= @TAB & '$Clnd_' & $s__Class & '_' & $s__Instance & ' = GUICtrlCreateDate("", ' $sSource &= $s__PosX & ' + $_Left, ' & $s__PosY & ' + $_Top, ' & $s__SizeW & ', ' & $s__SizeH & ', ' & $s__vStyle & ', ' & $s__vExStyle & ')' $sSource &= ' ; Style: ' & $s__sStyle & ' ; ExStyle: ' & $s__sExStyle & @CRLF EndSwitch Sleep(10) Next $sSource &= @TAB & 'GUISetState(@SW_SHOW, $Clnd_Form)' & @CRLF $sSource &= 'EndFunc ;==>_Clnd_Gui' & @CRLF $sSource &= "#EndRegion ### END cloned GUI section ###" & @CRLF $sSource = $sInclude & @CRLF & 'Global ' & $sGlobal & @CRLF & $sSource & @CRLF $sSource &= '' & @CRLF $sSource &= 'Main_GuiGetMessage()' & @CRLF $sSource &= 'Func Main_GuiGetMessage()' & @CRLF $sSource &= @TAB & 'Local $nMsg' & @CRLF $sSource &= @TAB & 'While 1' & @CRLF $sSource &= @TAB & @TAB & '$nMsg = GUIGetMsg()' & @CRLF $sSource &= @TAB & @TAB & 'Switch $nMsg' & @CRLF $sSource &= @TAB & @TAB & @TAB & 'Case $GUI_EVENT_CLOSE' & @CRLF $sSource &= @TAB & @TAB & @TAB & @TAB & 'Console' & 'Write("- Case $GUI_EVENT_CLOSE" & @CRLF)' & @CRLF $sSource &= @TAB & @TAB & @TAB & @TAB & 'GUIDelete($Clnd_Form)' & @CRLF $sSource &= @TAB & @TAB & @TAB & @TAB & 'ExitLoop' & @CRLF $sSource &= @TAB & @TAB & 'EndSwitch' & @CRLF $sSource &= @TAB & 'WEnd' & @CRLF $sSource &= 'EndFunc ;==>Main_GuiGetMessage' & @CRLF $sSource &= '' & @CRLF $sSource &= '' & @CRLF Local $sOnCase = @CRLF, $sOnEvent, $aOnEvent = StringSplit(StringStripWS($sGlobal, 8), ',', 0), $u = UBound($aOnEvent) - 1 $sOnEvent = @CRLF & @CRLF & @CRLF $sOnEvent &= 'GUISetOnEvent($GUI_EVENT_CLOSE, "On_Clnd_FormEvents")' & @CRLF $sOnEvent &= 'GUISetOnEvent($GUI_EVENT_MINIMIZE, "On_Clnd_FormEvents")' & @CRLF $sOnEvent &= 'GUISetOnEvent($GUI_EVENT_RESTORE, "On_Clnd_FormEvents")' & @CRLF & @CRLF For $n = 2 To $u $sOnEvent &= 'GUICtrlSetOnEvent(' & $aOnEvent[$n] & ', "On_' & StringTrimLeft($aOnEvent[$n], 1) & '")' & @CRLF Next $sOnEvent &= @CRLF & ';~ Main_OnEvent()' & @CRLF $sOnEvent &= 'Func Main_OnEvent()' & @CRLF $sOnEvent &= @TAB & 'Opt("GUIOnEventMode", 1) ; *** Rearrange the code for GUIOnEventMode ***' & @CRLF $sOnEvent &= @TAB & 'While 1' & @CRLF $sOnEvent &= @TAB & @TAB & 'Sleep(100)' & @CRLF $sOnEvent &= @TAB & 'WEnd' & @CRLF $sOnEvent &= 'EndFunc ;==>Main_OnEvent' & @CRLF & @CRLF $sOnEvent &= @CRLF & @CRLF & @CRLF $sOnEvent &= 'Func On_Clnd_FormEvents()' & @CRLF $sOnEvent &= @TAB & 'Switch @GUI_CtrlId' & @CRLF $sOnEvent &= @TAB & @TAB & 'Case $GUI_EVENT_CLOSE' & @CRLF $sOnEvent &= @TAB & @TAB & @TAB & 'Console' & 'Write("- Window Close, ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & @CRLF)' & @CRLF $sOnEvent &= @TAB & @TAB & @TAB & 'GUIDelete($Clnd_Form)' & @CRLF $sOnEvent &= @TAB & @TAB & @TAB & 'Exit 0' & @CRLF $sOnEvent &= @TAB & @TAB & 'Case $GUI_EVENT_MINIMIZE' & @CRLF $sOnEvent &= @TAB & @TAB & @TAB & 'Console' & 'Write("- Window Minimized, ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & @CRLF)' & @CRLF $sOnEvent &= @TAB & @TAB & 'Case $GUI_EVENT_RESTORE' & @CRLF $sOnEvent &= @TAB & @TAB & @TAB & 'Console' & 'Write("- Window Restored, ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & @CRLF)' & @CRLF $sOnEvent &= @TAB & 'EndSwitch' & @CRLF $sOnEvent &= 'EndFunc ;==>On_Clnd_FormEvents' & @CRLF & @CRLF For $n = 2 To $u $sOnEvent &= 'Func On_' & StringTrimLeft($aOnEvent[$n], 1) & '()' & @CRLF $sOnEvent &= @TAB & 'Console' & 'Write("+ Func On_' & StringTrimLeft($aOnEvent[$n], 1) & '()" & @CRLF)' & @CRLF $sOnEvent &= 'EndFunc ;==>On_' & StringTrimLeft($aOnEvent[$n], 1) & @CRLF & @CRLF $sOnCase &= @TAB & @TAB & @TAB & 'Case ' & $aOnEvent[$n] & @CRLF $sOnCase &= @TAB & @TAB & @TAB & @TAB & 'Console' & 'Write("- Case ' & $aOnEvent[$n] & '" & @CRLF)' & @CRLF & @CRLF Next $sOnCase &= @TAB & @TAB & 'EndSwitch' & @CRLF $sSource = StringReplace($sSource, @TAB & @TAB & 'EndSwitch' & @CRLF, $sOnCase) $sSource &= $sOnEvent Local $tempFile = 'CV.ClonedGUI.' & @YEAR & @MON & @MDAY & '.' & @HOUR & @MIN & @SEC & '.au3' Switch $_CloneGui Case 0 ClipPut($sSource) ToolTip("Source is in the clipboard", $mPos[0], $mPos[1], "CV - ClipPut") AdlibRegister("ToolTipOff", 1500) Case 1 $tempFile = @MyDocumentsDir & '\' & $tempFile FileWriteLine($tempFile, $sSource) If $_CloneEditGuiFile Then ShellExecute($tempFile, "", "", "Edit") Case 2 If Not _ShellReportDlg($hForm, $sSource, $tempFile, $_CloneEditGuiFile) Then MsgBox(16, $GUI_NAME, 'Unable to save file', 0, $hForm) EndIf EndSwitch Sleep(500) EndFunc ;==>_CloneGui Func ToolTipOff() AdlibUnRegister("ToolTipOff") ToolTip("") EndFunc ;==>ToolTipOff Func GUICtrl_ReadForClone($iCtrl) Local $s = GUICtrlRead($iCtrl) $s = StringReplace($s, @CRLF, '" & @CRLF & "') $s = StringReplace($s, @CR, '" & @CR & "') $s = StringReplace($s, @LF, '" & @LF & "') Return $s EndFunc ;==>GUICtrl_ReadForClone Func ScriptNameOnly() Local Static $Ret = "" If $Ret == "" Then Local $a = StringSplit(@ScriptName, "_.", 0) $Ret = $a[1] EndIf Return $Ret EndFunc ;==>ScriptNameOnly Func ScriptFullPathOnly() Return @ScriptDir & '\' & ScriptNameOnly() EndFunc ;==>ScriptFullPathOnly #Region _CanBeAdmin Func _CanBeAdmin() Local Static $iCanBeAdmin = "" If $iCanBeAdmin == "" Then If IsAdmin() Then $iCanBeAdmin = 2 Return $iCanBeAdmin EndIf Local $i = _IsUACAdmin() If $i = 0 And @extended = 1 Then $iCanBeAdmin = 1 Return $iCanBeAdmin Else $iCanBeAdmin = 0 Return $iCanBeAdmin EndIf EndIf Return $iCanBeAdmin EndFunc ;==>_CanBeAdmin Func _IsUACAdmin() ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IsUACAdmin ; Description ...: Determines if process has Admin privileges and whether running under UAC. ; Syntax ........: _IsUACAdmin() ; Parameters ....: None ; Return values .: Success - 1 - User has full Admin rights (Elevated Admin w/ UAC) ; Failure - 0 - User is not an Admin, sets @extended: ; | 0 - User cannot elevate ; | 1 - User can elevate ; Author ........: Erik Pilsits ; Modified ......: ; Remarks .......: THE GOOD STUFF: returns 0 w/ @extended = 1 > UAC Protected Admin ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== ; check elevation If StringRegExp(@OSVersion, "_(XP|20(0|3))") Or (Not _IsUACEnabled()) Then ; XP, XPe, 2000, 2003 > no UAC ; no UAC available or turned off If IsAdmin() Then Return SetExtended(0, 1) Else Return SetExtended(0, 0) EndIf Else ; check UAC elevation ; ; get process token groups information Local $hToken = _Security__OpenProcessToken(_WinAPI_GetCurrentProcess(), $TOKEN_QUERY) Local $tTI = _Security__GetTokenInformation($hToken, $TOKENGROUPS) _WinAPI_CloseHandle($hToken) ; Local $pTI = DllStructGetPtr($tTI) Local $cbSIDATTR = DllStructGetSize(DllStructCreate("ptr;dword")) Local $Count = DllStructGetData(DllStructCreate("dword", $pTI), 1) Local $pGROUP1 = DllStructGetPtr(DllStructCreate("dword;STRUCT;ptr;dword;ENDSTRUCT", $pTI), 2) Local $tGROUP ;, $sGROUP = "" ; ; S-1-5-32-544 > BUILTINAdministrators > $SID_ADMINISTRATORS ; S-1-16-8192 > Mandatory LabelMedium Mandatory Level (Protected Admin) > $SID_MEDIUM_MANDATORY_LEVEL ; S-1-16-12288 > Mandatory LabelHigh Mandatory Level (Elevated Admin) > $SID_HIGH_MANDATORY_LEVEL ; SE_GROUP_USE_FOR_DENY_ONLY = 0x10 ; ; check SIDs Local $inAdminGrp = False, $denyAdmin = False, $elevatedAdmin = False, $sSID For $i = 0 To $Count - 1 $tGROUP = DllStructCreate("ptr;dword", $pGROUP1 + ($cbSIDATTR * $i)) $sSID = _Security__SidToStringSid(DllStructGetData($tGROUP, 1)) If StringInStr($sSID, "S-1-5-32-544") Then ; member of Administrators group $inAdminGrp = True ; check for deny attribute If (BitAND(DllStructGetData($tGROUP, 2), 0x10) = 0x10) Then $denyAdmin = True ElseIf StringInStr($sSID, "S-1-16-12288") Then $elevatedAdmin = True EndIf Next ; If $inAdminGrp Then ; check elevated If $elevatedAdmin Then ; check deny status If $denyAdmin Then ; protected Admin CANNOT elevate Return SetExtended(0, 0) Else ; elevated Admin Return SetExtended(1, 1) EndIf Else ; protected Admin Return SetExtended(1, 0) EndIf Else ; not an Admin Return SetExtended(0, 0) EndIf EndIf EndFunc ;==>_IsUACAdmin Func _IsUACEnabled() Return (RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "EnableLUA") = 1) EndFunc ;==>_IsUACEnabled #EndRegion _CanBeAdmin #Region _TaskSched Func _TaskSched_Run() If Not $__g_TaskSched_TriggerType Then Return Local $addedType = "_OnDemand" If $__g_TaskSched_TriggerType = 2 Then $addedType = "_OnLogon" If RunWait('schtasks.exe /Run /TN "' & StringReplace($__g_TaskSched_InfoURI & $addedType, "\\", "\") & '"', '', @SW_HIDE) = 0 Then Exit 0 EndIf EndFunc ;==>_TaskSched_Run Func _TaskSched_ForGui() $__g_TaskSched_TriggerType = 0 If _TaskSched_AlreadyInstalled("_OnLogon") Then $__g_TaskSched_TriggerType = 2 If _TaskSched_AlreadyInstalled("_OnDemand") Then $__g_TaskSched_TriggerType = 1 Switch $__g_TaskSched_TriggerType Case 2 GUICtrlSetData($Menu[24], 'Remove on Logon') GUICtrlSetState($Menu[25], $GUI_DISABLE) GUICtrlSetState($Menu[24], $GUI_ENABLE) $__g_TaskSched_TriggerOnLogon = 1 Case 1 GUICtrlSetData($Menu[25], 'Remove on demand') GUICtrlSetState($Menu[24], $GUI_DISABLE) GUICtrlSetState($Menu[25], $GUI_ENABLE) $__g_TaskSched_TriggerOnLogon = 0 Case 0 GUICtrlSetData($Menu[24], 'Add on Logon') GUICtrlSetState($Menu[25], $GUI_ENABLE) GUICtrlSetData($Menu[25], 'Add on demand') GUICtrlSetState($Menu[24], $GUI_ENABLE) EndSwitch ConsoleWrite('+ Func _TaskSched_ForGui() : Type=' & $__g_TaskSched_TriggerType & ', OnLogon=' & $__g_TaskSched_TriggerOnLogon & @CRLF) EndFunc ;==>_TaskSched_ForGui Func _TaskSched_FromGui($i) GUICtrlSetState($Menu[24], $GUI_DISABLE) GUICtrlSetState($Menu[25], $GUI_DISABLE) ConsoleWrite('+ Func _TaskSched_FromGui("' & $i & '") : Type=' & $__g_TaskSched_TriggerType & @CRLF) Switch $__g_TaskSched_TriggerType Case 0 Switch $i Case 2 $__g_TaskSched_TriggerOnLogon = 1 _TaskSched_Add("_OnLogon") Case 1 $__g_TaskSched_TriggerOnLogon = 0 _TaskSched_Add("_OnDemand") EndSwitch Case 2 $__g_TaskSched_TriggerOnLogon = 1 _TaskSched_Remove("_OnLogon") Case 1 $__g_TaskSched_TriggerOnLogon = 0 ConsoleWrite(_TaskSched_Remove("_OnDemand") & @CRLF) EndSwitch _TaskSched_ForGui() EndFunc ;==>_TaskSched_FromGui Func _TaskSched_Add($addedType = "", $extraArgument = "") If _TaskSched_AlreadyInstalled($addedType) Then Return 6 Else If _TaskSched_Install($addedType, $extraArgument) Then Return 0 Else Return 5 EndIf EndIf EndFunc ;==>_TaskSched_Add Func _TaskSched_Remove($addedType = "") If _TaskSched_AlreadyInstalled($addedType) Then If _TaskSched_Uninstall($addedType) Then Return 0 Else Return 5 EndIf Else Return 6 EndIf EndFunc ;==>_TaskSched_Remove Func _TaskSched_AlreadyInstalled($addedType = "") ConsoleWrite('_TaskSched_AlreadyInstalled >' & StringReplace($__g_TaskSched_InfoURI & $addedType, "\\", "\") & '<' & @CRLF) ;~ If @Compiled And Not FileExists(@ScriptName) Then Return False If RunWait('schtasks.exe /Query /TN "' & StringReplace($__g_TaskSched_InfoURI & $addedType, "\\", "\") & '"', '', @SW_HIDE) <> 0 Then Return False Return True EndFunc ;==>_TaskSched_AlreadyInstalled Func _TaskSched_Install($addedType = "", $extraArgument = "") Local $xml = "" $xml &= '' $xml &= @CRLF & '' $xml &= @CRLF & ' ' $xml &= @CRLF & ' 2000-01-01T12:00:00' $xml &= @CRLF & ' ' & $__g_TaskSched_InfoAuthor & '' $xml &= @CRLF & ' ' & $__g_TaskSched_InfoDescription & '' ; $InfoDescription = "mb aid" $xml &= @CRLF & ' ' & StringReplace($__g_TaskSched_InfoURI & $addedType, "\\", "\") & '' ; $InfoURI = "\au3\mbAID" $xml &= @CRLF & ' ' If $__g_TaskSched_TriggerOnLogon Then $xml &= @CRLF & ' ' $xml &= @CRLF & ' ' $xml &= @CRLF & ' true' $xml &= @CRLF & ' ' & $__g_TaskSched_InfoAuthor & '' If $__g_TaskSched_TriggerDelay Then $xml &= @CRLF & ' PT' & $__g_TaskSched_TriggerDelay & 'S' ; delay 10 sec. TriggerDelay = 10 EndIf $xml &= @CRLF & ' ' $xml &= @CRLF & ' ' Else $xml &= @CRLF & ' ' EndIf $xml &= @CRLF & ' ' $xml &= @CRLF & ' ' $xml &= @CRLF & ' ' & $__g_TaskSched_InfoAuthor & '' ;~ $xml &= @CRLF & ' ' & $__g_TaskSched_GroupId & '' $xml &= @CRLF & ' InteractiveToken' If IsAdmin() Then $xml &= @CRLF & ' HighestAvailable' Else $xml &= @CRLF & ' LeastPrivilege' EndIf $xml &= @CRLF & ' ' $xml &= @CRLF & ' ' $xml &= @CRLF & ' ' $xml &= @CRLF & ' Parallel' $xml &= @CRLF & ' false' $xml &= @CRLF & ' false' $xml &= @CRLF & ' true' $xml &= @CRLF & ' false' $xml &= @CRLF & ' false' $xml &= @CRLF & ' ' $xml &= @CRLF & ' false' $xml &= @CRLF & ' false' $xml &= @CRLF & ' ' $xml &= @CRLF & ' true' $xml &= @CRLF & ' true' $xml &= @CRLF & ' false' $xml &= @CRLF & ' false' $xml &= @CRLF & ' false' $xml &= @CRLF & ' PT0S' $xml &= @CRLF & ' 7' $xml &= @CRLF & ' ' $xml &= @CRLF & ' ' $xml &= @CRLF & ' ' $xml &= @CRLF & ' ' & $__g_TaskSched_ExecCommand & '' $xml &= @CRLF & ' ' & $__g_TaskSched_ExecArguments & $extraArgument & '' $xml &= @CRLF & ' ' & $__g_TaskSched_ExecWorkingDirectory & '' $xml &= @CRLF & ' ' $xml &= @CRLF & ' ' $xml &= @CRLF & '' Local $sFileXML = @TempDir & '\$~schtsk_' & @MIN & @SEC & @MSEC & '.xml' FileDelete($sFileXML) FileWrite($sFileXML, $xml) If FileRead($sFileXML) <> $xml Then Return False ConsoleWrite('_TaskSched_Install >' & StringReplace($__g_TaskSched_InfoURI & $addedType, "\\", "\") & '<' & @CRLF) If RunWait('schtasks.exe /Create /XML "' & $sFileXML & '" /TN "' & StringReplace($__g_TaskSched_InfoURI & $addedType, "\\", "\") & '"', '', @SW_HIDE) <> 0 Then FileDelete($sFileXML) Return False EndIf FileDelete($sFileXML) Return True EndFunc ;==>_TaskSched_Install Func _TaskSched_Uninstall($addedType = "") ;~ RunWait('schtasks.exe /End /TN "' & $__g_TaskSched_InfoURI & '"', '', @SW_HIDE) ConsoleWrite('_TaskSched_Uninstall >' & StringReplace($__g_TaskSched_InfoURI & $addedType, "\\", "\") & '<' & @CRLF) If RunWait('schtasks.exe /Delete /F /TN "' & StringReplace($__g_TaskSched_InfoURI & $addedType, "\\", "\") & '"', '', @SW_HIDE) <> 0 Then Return False Sleep(3000) ;~ If Not FileDelete($sDrive & '\mbAid_AuxSched.exe') Then Return False DirRemove(@SystemDir & '\Tasks' & $__g_TaskSched_URI_Folder) ; remove the folder only if empty Return True EndFunc ;==>_TaskSched_Uninstall #EndRegion _TaskSched #Region Elevate Func _EleDeElevate() If IsAdmin() Then Local $iPID = _RunWithReducedPrivileges(@ScriptName, " /FromTaskSched /Elevated", @ScriptDir) ;~ Local $iError = @error If ProcessExists($iPID) Then Exit 0 Else If $__g_TaskSched_TriggerType And $__g_TaskSched_CanBeAdmin Then _TaskSched_Run() Exit Else _FMIPC_Close() If ShellExecute(@ScriptName, "/FromTaskSched /Elevated", "", "runas") Then GUIDelete() Exit 0 Else _FMIPC_Create(StringStripWS($GUI_UNIQUE & @UserName, 8)) EndIf EndIf EndIf EndFunc ;==>_EleDeElevate ; =============================================================================================================================== ; <_RunWithReducedPrivileges.au3> ; ; Function to run a program with reduced privileges. ; Useful when running in a higher privilege mode, but need to start a program with reduced privileges. ; - A common problem this fixes is drag-and-drop not working, and misc functions (sendmessage, etc) not working. ; ; Functions: ; _RunWithReducedPrivileges() ; runs a process with reduced privileges if currently running in a higher privilege mode ; ; INTERNAL Functions: ; _RWRPCleanup() ; Helper function for the above ; ; Reference: ; See 'Creating a process with Medium Integration Level from the process with High Integration Level in Vista' ; @ http://www.codeproject.com/KB/vista-security/createprocessexplorerleve.aspx ; See Elmue's comment 'Here the cleaned and bugfixed code' ; Also see: 'High elevation can be bad for your application: How to start a non-elevated process at the end of the installation' ; @ http://www.codeproject.com/KB/vista-security/RunNonElevated.aspx ; (Elmue has the same code here too in his response to FaxedHead's comment ('Another alternative to this method')) ; Another alternative using COM methods: ; 'Getting the shell to run an application for you - Part 2:How | BrandonLive' ; @ http://brandonlive.com/2008/04/27/getting-the-shell-to-run-an-application-for-you-part-2-how/ ; ; Author: Ascend4nt, based on code by Elmue's fixed version of Alexey Gavrilov's code ; =============================================================================================================================== ; =================================================================================================================== ; Func _RunWithReducedPrivileges($sPath,$sCmd='',$sFolder='',$iShowFlag=@SW_SHOWNORMAL,$bWait=False) ; ; Function to run a program with reduced privileges. ; Useful when running in a higher privilege mode, but need to start a program with reduced privileges. ; - A common problem this fixes is drag-and-drop not working, and misc functions (sendmessage, etc) not working. ; ; $sPath = Path to executable ; $sCmd = Command-line (optional) ; $sFolder = Folder to start in (optional) ; $iShowFlag = how the program should appear on startup. Default is @SW_SHOWNORMAL. ; All the regular @SW_SHOW* macros should work here ; $bWait = If True, waits for the process to finish before returning with an exit code ; If False, it returns without waiting for the process to finish, with the process ID # ; ; Returns: ; Success: If $bWait=True, the exit code of the Process. If $bWait=False, then the Process ID # of the process ; Failure: 0, with @error set: ; @error = 2 = DLLCall error. @extended contains the DLLCall error code (see AutoIt Help) ; @error = 3 = API returned failure. Call 'GetLastError' API function to get more info. ; ; Author: Ascend4nt, based on code by Elmue's fixed version of Alexey Gavrilov's code ; =================================================================================================================== Func _RunWithReducedPrivileges($sPath, $sCmd = '', $sFolder = '', $iShowFlag = @SW_SHOWNORMAL, $bWait = False) Local $aRet, $iErr, $iRet = 1, $hProcess, $hToken, $hDupToken, $stStartupInfo, $stProcInfo Local $sCmdType = "wstr", $sFolderType = "wstr" ;~ Run normally if not in an elevated state, or if pre-Vista O/S If Not IsAdmin() Or StringRegExp(@OSVersion, "_(XP|200(0|3))") Then ; XP, XPe, 2000, or 2003? If $bWait Then Return RunWait($sPath & ' ' & $sCmd, $sFolder) Return Run($sPath & ' ' & $sCmd, $sFolder) EndIf ;~ Check Parameters and adjust DLLCall types accordingly If Not IsString($sCmd) Or $sCmd = '' Then $sCmdType = "ptr" $sCmd = 0 EndIf If Not IsString($sFolder) Or $sFolder = '' Then $sFolderType = "ptr" $sFolder = 0 EndIf #cs ; STARTUPINFOW struct: cb,lpReserved,lpDesktop,lpTitle,dwX,dwY,dwXSize,dwYSize,dwXCountChars,dwYCountChars,dwFillAttribute, ; dwFlags,wShowWindow,cbReserved2,lpReserved2,hStdInput,hStdOutput,hStdError ; NOTE: This is for process creation info. Also, not sure if the Std I/O can be redirected..? #ce $stStartupInfo = DllStructCreate("dword;ptr[3];dword[7];dword;word;word;ptr;handle[3]") DllStructSetData($stStartupInfo, 1, DllStructGetSize($stStartupInfo)) DllStructSetData($stStartupInfo, 4, 1) ; STARTF_USESHOWWINDOW DllStructSetData($stStartupInfo, 5, $iShowFlag) ; PROCESS_INFORMATION struct: hProcess, hThread, dwProcessId, dwThreadId ; This is for *receiving* info $stProcInfo = DllStructCreate("handle;handle;dword;dword") ;~ Open a handle to the Process ; Explorer runs under a lower privilege, so it is the basis for our security info. ; Open the process with PROCESS_QUERY_INFORMATION (0x0400) access ;$aRet = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", 0x0400, "bool", False, "dword", ProcessExists("explorer.exe")) $aRet = _WinAPI_OpenProcess(0x0400, 0, ProcessExists("explorer.exe")) If @error Then Return SetError(2, @error, 0) If Not $aRet Then Return SetError(3, 0, 0) $hProcess = $aRet ;~ Open a handle to the Process's token (for duplication) ; TOKEN_DUPLICATE = 0x0002 ;$aRet = DllCall("advapi32.dll", "bool", "OpenProcessToken", "handle", $hProcess, "dword", 2, "handle*", 0) $aRet = _Security__OpenProcessToken($hProcess, 2) If @error Then Return SetError(_RWRPCleanup($hProcess, 0, 0, 2, @error), @extended, 0) If Not $aRet Then Return SetError(_RWRPCleanup($hProcess, 0, 0, 3), @extended, 0) $hToken = $aRet ;~ Duplicate the token handle ; TOKEN_ALL_ACCESS = 0xF01FF, SecurityImpersonation = 2, TokenPrimary = 1, ;$aRet = DllCall("advapi32.dll", "bool", "DuplicateTokenEx", "handle", $hToken, "dword", 0xF01FF, "ptr", 0, "int", 2, "int", 1, "handle*", 0) $aRet = _Security__DuplicateTokenEx($hToken, 0xF01FF, 2, 1) If @error Then Return SetError(_RWRPCleanup($hProcess, $hToken, 0, 2, @error), @extended, 0) If Not $aRet Then Return SetError(_RWRPCleanup($hProcess, $hToken, 0, 3), @extended, 0) $hDupToken = $aRet ;~ Create the process using 'CreateProcessWithTokenW' (Vista+ O/S function) $aRet = DllCall("advapi32.dll", "bool", "CreateProcessWithTokenW", "handle", $hDupToken, "dword", 0, "wstr", $sPath, $sCmdType, $sCmd, _ "dword", 0, "ptr", 0, $sFolderType, $sFolder, "ptr", DllStructGetPtr($stStartupInfo), "ptr", DllStructGetPtr($stProcInfo)) $iErr = @error _RWRPCleanup($hProcess, $hToken, $hDupToken, 2, @error) If $iErr Then Return SetError(2, $iErr, 0) If Not $aRet[0] Then Return SetError(3, 0, 0) ;~ MsgBox(0,"Info","Process info data: Process handle:"&DllStructGetData($stProcInfo,1)&", Thread handle:"&DllStructGetData($stProcInfo,2)& _ ;~ ", Process ID:"&DllStructGetData($stProcInfo,3)&", Thread ID:"&DllStructGetData($stProcInfo,4)&@CRLF) $iRet = DllStructGetData($stProcInfo, 3) ; Process ID ;~ If called in 'RunWait' style, wait for the process to close If $bWait Then ProcessWaitClose($iRet) $iRet = @extended ; Exit code EndIf ;~ Close Thread and then Process handles (order here is important): _RWRPCleanup(0, DllStructGetData($stProcInfo, 2), DllStructGetData($stProcInfo, 1), 0) Return $iRet EndFunc ;==>_RunWithReducedPrivileges ; =================================================================================================================== ; Func _RWRPCleanup($hProcess,$hToken,$hDupToken,$iErr=0,$iExt=0) ; ; INTERNAL: Helper function for _RunWithReducedPrivileges() ; ; Author: Ascend4nt ; =================================================================================================================== Func _RWRPCleanup($hProcess, $hToken, $hDupToken, $iErr = 0, $iExt = 0) Local $aHandles[3] = [$hToken, $hDupToken, $hProcess] ; order is important For $i = 0 To 2 If $aHandles[$i] <> 0 Then _WinAPI_CloseHandle($aHandles[$i]) ;DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $aHandles[$i]) Next Return SetExtended($iExt, $iErr) EndFunc ;==>_RWRPCleanup #EndRegion Elevate #Region IsItBootRun ConsoleWrite('IsItBootRun() = ' & IsItBootRun() & @CRLF) Func IsItBootRun($secs = 120) Local $v = False, $i = 0, $s2, $s1 $s1 = GetProcessTimes('explorer.exe') $s2 = GetProcessTimes(StringTrimRight(@ScriptName, 4) & '.exe') If Not StringInStr($s2, "/") Or Not StringInStr($s1, "/") Then Return SetError(1, $i, $v) $i = Int(_DateDiff("s", $s1, $s2)) If $i < $secs And $i > -1 Then $v = True ;~ ConsoleWrite('+++ > IsItBootRun = ' & $i & " = " & $v & @CRLF) Return SetError(0, $i, $v) EndFunc ;==>IsItBootRun Func GetProcessTimes($sProcessName = 'explorer.exe') Local $aFT, $tFT, $sST, $aID = ProcessPidUserSelf($sProcessName) If Not $aID Then Return SetError(1, 0, "") $aFT = _WinAPI_GetProcessTimes($aID) If Not UBound($aFT) Then Return SetError(2, 0, "") $tFT = _Date_Time_FileTimeToLocalFileTime($aFT[0]) $sST = _Date_Time_FileTimeToStr($tFT, 1) Return $sST EndFunc ;==>GetProcessTimes Func ProcessPidUserSelf($sProcessName = 'explorer.exe') Local $aData, $aList = 0 $aList = ProcessList($sProcessName) For $i = 1 To UBound($aList) - 1 $aData = _WinAPI_GetProcessUser($aList[$i][1]) If IsArray($aData) Then If $aData[0] = @UserName Then Return $aList[$i][1] EndIf Next Return SetError(1, 0, 0) EndFunc ;==>ProcessPidUserSelf #EndRegion IsItBootRun