Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/06/2018 in all areas

  1. wraithdu

    _SysTray UDF

    Here is my highly modified version of Tuape's UDF. The example shows how to get different info and how to remove dead icons (no mouse move required). I've included support for the Windows 7 NotifyIconOverflowWindow icons as well, however I recommend using my _OsVersionInfo UDF to determine the OS instead of @OSVersion. This should work on Win2000+, but some testers on XP and Vista would be appreciated. _SysTray #include-once ; ---------------------------------------------------------------------------- ; ; Author: Tuape ; Modified: Erik Pilsits ; ; Script Function: ; Systray UDF - Functions for reading icon info from system tray / removing ; any icon. ; ; Last Update: 5/13/2013 ; ; ---------------------------------------------------------------------------- ;=============================================================================== ; ; Function Name: _SysTrayIconCount($iWin = 1) ; Description: Returns number of icons on systray ; Note: Hidden icons are also reported ; Parameter(s): $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns number of icons found ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconCount($iWin = 1) Local Const $TB_BUTTONCOUNT = 1048 Local $hWnd = _FindTrayToolbarWindow($iWin) If $hWnd = -1 Then Return -1 Local $count = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $TB_BUTTONCOUNT, "wparam", 0, "lparam", 0) If @error Then Return -1 Return $count[0] EndFunc ;==>_SysTrayIconCount ;=============================================================================== ; ; Function Name: _SysTrayIconTitles($iWin = 1) ; Description: Get list of all window titles that have systray icon ; Parameter(s): $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; Requirement(s): ; Return Value(s): On Success - Returns an array with all window titles ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconTitles($iWin = 1) Local $count = _SysTrayIconCount($iWin) If $count <= 0 Then Return -1 Local $titles[$count] ; Get icon owner window"s title For $i = 0 To $count - 1 $titles[$i] = WinGetTitle(_SysTrayIconHandle($i, $iWin)) Next Return $titles EndFunc ;==>_SysTrayIconTitles ;=============================================================================== ; ; Function Name: _SysTrayIconPids($iWin = 1) ; Description: Get list of all processes id's that have systray icon ; Parameter(s): $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; Requirement(s): ; Return Value(s): On Success - Returns an array with all process id's ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconPids($iWin = 1) Local $count = _SysTrayIconCount($iWin) If $count <= 0 Then Return -1 Local $processes[$count] For $i = 0 To $count - 1 $processes[$i] = WinGetProcess(_SysTrayIconHandle($i, $iWin)) Next Return $processes EndFunc ;==>_SysTrayIconPids ;=============================================================================== ; ; Function Name: _SysTrayIconProcesses($iWin = 1) ; Description: Get list of all processes that have systray icon ; Parameter(s): $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; Requirement(s): ; Return Value(s): On Success - Returns an array with all process names ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconProcesses($iWin = 1) Local $pids = _SysTrayIconPids($iWin) If Not IsArray($pids) Then Return -1 Local $processes[UBound($pids)] ; List all processes Local $list = ProcessList() For $i = 0 To UBound($pids) - 1 For $j = 1 To $list[0][0] If $pids[$i] = $list[$j][1] Then $processes[$i] = $list[$j][0] ExitLoop EndIf Next Next Return $processes EndFunc ;==>_SysTrayIconProcesses ;=============================================================================== ; ; Function Name: _SysTrayIconIndex($test, $mode = 0, $iWin = 1) ; Description: Get list of all processes id"s that have systray icon ; Parameter(s): $test - process name / window title text / process PID ; $mode ; | 0 - get index by process name (default) ; | 1 - get index by window title ; | 2 - get index by process PID ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; Requirement(s): ; Return Value(s): On Success - Returns index of found icon ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconIndex($test, $mode = 0, $iWin = 1) Local $ret = -1, $compare = -1 If $mode < 0 Or $mode > 2 Or Not IsInt($mode) Then Return -1 Switch $mode Case 0 $compare = _SysTrayIconProcesses($iWin) Case 1 $compare = _SysTrayIconTitles($iWin) Case 2 $compare = _SysTrayIconPids($iWin) EndSwitch If Not IsArray($compare) Then Return -1 For $i = 0 To UBound($compare) - 1 If $compare[$i] = $test Then $ret = $i ExitLoop EndIf Next Return $ret EndFunc ;==>_SysTrayIconIndex ; INTERNAL ===================================================================== ; ; Function Name: _SysTrayGetButtonInfo($iIndex, $iWin = 1, $iInfo = 0) ; Description: Gets Tray Button Info ; Parameter(s): $iIndex - icon index (Note: starting from 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; $iInfo - Info to return ; | 1 - TBBUTTON structure ; | 2 - TRAYDATA structure ; | 3 - tooltip ; | 4 - icon position ; Requirement(s): ; Return Value(s): On Success - Returns requested info ; On Failure - Sets @error and returns -1 ; | 1 - Failed to find tray window ; | 2 - Failed to get tray window PID ; | 3 - Failed to open process ; | 4 - Failed to allocate memory ; | 5 - Failed to get TBBUTTON info ; ; Author(s): Erik Pilsits, Tuape ; ;=============================================================================== Func _SysTrayGetButtonInfo($iIndex, $iWin = 1, $iInfo = 1) Local Const $TB_GETBUTTON = 1047 ;~ Local Const $TB_GETBUTTONTEXT = 1099 ;~ Local Const $TB_GETBUTTONINFO = 1089 Local Const $TB_GETITEMRECT = 1053 Local Const $ACCESS = BitOR(0x0008, 0x0010, 0x0400) ; VM_OPERATION, VM_READ, QUERY_INFORMATION Local $TBBUTTON If @OSArch = "X86" Then $TBBUTTON = DllStructCreate("int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[2];dword dwData;int iString") Else ; X64 $TBBUTTON = DllStructCreate("int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[6];uint64 dwData;int64 iString") EndIf Local $TRAYDATA If @OSArch = "X86" Then $TRAYDATA = DllStructCreate("hwnd hwnd;uint uID;uint uCallbackMessage;dword Reserved[2];handle hIcon") Else $TRAYDATA = DllStructCreate("uint64 hwnd;uint uID;uint uCallbackMessage;dword Reserved[2];uint64 hIcon") EndIf Local $trayHwnd = _FindTrayToolbarWindow($iWin) If $trayHwnd = -1 Then Return SetError(1, 0, -1) Local $return, $err = 0 Local $ret = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $trayHwnd, "dword*", 0) If @error Or Not $ret[2] Then SetError(2, 0, -1) Local $pId = $ret[2] Local $procHandle = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $ACCESS, "bool", False, "dword", $pId) If @error Or Not $procHandle[0] Then Return SetError(3, 0, -1) Local $lpData = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $procHandle[0], "ptr", 0, "ulong", DllStructGetSize($TBBUTTON), "dword", 0x1000, "dword", 0x04) If Not @error And $lpData[0] Then $ret = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETBUTTON, "wparam", $iIndex, "lparam", $lpData[0]) If Not @error And $ret[0] Then DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", $lpData[0], "struct*", $TBBUTTON, "ulong", DllStructGetSize($TBBUTTON), "ulong*", 0) Switch $iInfo Case 2 ; TRAYDATA structure DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", DllStructGetData($TBBUTTON, 6), "struct*", $TRAYDATA, "ulong", DllStructGetSize($TRAYDATA), "ulong*", 0) $return = $TRAYDATA Case 3 ; tooltip $return = "" If BitShift(DllStructGetData($TBBUTTON, 7), 16) <> 0 Then Local $intTip = DllStructCreate("wchar[1024]") ; we have a pointer to a string, otherwise it is an internal resource identifier DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", DllStructGetData($TBBUTTON, 7), "struct*", $intTip, "ulong", DllStructGetSize($intTip), "ulong*", 0) $return = DllStructGetData($intTip, 1) ;else internal resource EndIf Case 4 ; icon position If Not BitAND(DllStructGetData($TBBUTTON, 3), 8) Then ; 8 = TBSTATE_HIDDEN Local $pos[2], $RECT = DllStructCreate("int;int;int;int") DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETITEMRECT, "wparam", $iIndex, "lparam", $lpData[0]) DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", $lpData[0], "struct*", $RECT, "ulong", DllStructGetSize($RECT), "ulong*", 0) $ret = DllCall("user32.dll", "int", "MapWindowPoints", "hwnd", $trayHwnd, "ptr", 0, "struct*", $RECT, "uint", 2) $pos[0] = DllStructGetData($RECT, 1) $pos[1] = DllStructGetData($RECT, 2) $return = $pos Else $return = -1 EndIf Case Else ; TBBUTTON $return = $TBBUTTON EndSwitch Else $err = 5 EndIf DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $procHandle[0], "ptr", $lpData[0], "ulong", 0, "dword", 0x8000) Else $err = 4 EndIf DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $procHandle[0]) If $err Then Return SetError($err, 0, -1) Else Return $return EndIf EndFunc ;==>_SysTrayGetButtonInfo ;=============================================================================== ; ; Function Name: _SysTrayIconHandle($iIndex, $iWin = 1) ; Description: Gets hwnd of window associated with systray icon of given index ; Parameter(s): $iIndex - icon index (Note: starting from 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns hwnd of found icon ; On Failure - Sets @error and returns -1 ; | See _SysTrayGetButtonInfo for @error returns ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconHandle($iIndex, $iWin = 1) Local $TRAYDATA = _SysTrayGetButtonInfo($iIndex, $iWin, 2) If @error Then Return SetError(@error, 0, -1) Else Return Ptr(DllStructGetData($TRAYDATA, 1)) EndIf EndFunc ;==>_SysTrayIconHandle ;=============================================================================== ; ; Function Name: _SysTrayIconTooltip($iIndex, $iWin = 1) ; Description: Gets the tooltip text of systray icon of given index ; Parameter(s): $iIndex - icon index (Note: starting from 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns tooltip text of icon ; On Failure - Sets @error and returns -1 ; | See _SysTrayGetButtonInfo for @error returns ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconTooltip($iIndex, $iWin = 1) Local $ret = _SysTrayGetButtonInfo($iIndex, $iWin, 3) If @error Then Return SetError(@error, 0, -1) Else Return $ret EndIf EndFunc ;==>_SysTrayIconTooltip ;=============================================================================== ; ; Function Name: _SysTrayIconPos($iIndex, $iWin = 1) ; Description: Gets x & y position of systray icon ; Parameter(s): $iIndex - icon index (Note: starting from 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns array, x [0] and y [1] position of icon ; On Failure - Sets @error and returns -1 ; | -1 - Icon is hidden (Autohide on XP, etc) ; | See _SysTrayGetButtonInfo for additional @error returns ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconPos($iIndex, $iWin = 1) Local $ret = _SysTrayGetButtonInfo($iIndex, $iWin, 4) If @error Then Return SetError(@error, 0, -1) Else If $ret = -1 Then Return SetError(-1, 0, -1) Else Return $ret EndIf EndIf EndFunc ;==>_SysTrayIconPos ;=============================================================================== ; ; Function Name: _SysTrayIconVisible($iIndex, $iWin = 1) ; Description: Gets the visibility of a systray icon ; Parameter(s): $iIndex - icon index (Note: starting from 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns True (visible) or False (hidden) ; On Failure - Sets @error and returns -1 ; | See _SysTrayGetButtonInfo for @error returns ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconVisible($iIndex, $iWin = 1) Local $TBBUTTON = _SysTrayGetButtonInfo($iIndex, $iWin, 1) If @error Then Return SetError(@error, 0, -1) Else Return Not BitAND(DllStructGetData($TBBUTTON, 3), 8) ;TBSTATE_HIDDEN EndIf EndFunc ;==>_SysTrayIconVisible ;=============================================================================== ; ; Function Name: _SysTrayIconHide($index, $iFlag, $iWin = 1) ; Description: Hides / unhides any icon on systray ; ; Parameter(s): $index - icon index. Can be queried with _SysTrayIconIndex() ; $iFlag - hide (1) or show (0) icon ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns 1 if operation was successfull or 0 if ; icon was already hidden/unhidden ; On Failure - Sets @error and returns -1 ; | See _SysTrayGetButtonInfo for @error returns ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconHide($index, $iFlag, $iWin = 1) ;~ Local Const $TB_HIDEBUTTON = 0x0404 ; WM_USER + 4 Local $TBBUTTON = _SysTrayGetButtonInfo($index, $iWin, 1) If @error Then Return SetError(@error, 0, -1) Local $visible = Not BitAND(DllStructGetData($TBBUTTON, 3), 8) ;TBSTATE_HIDDEN If ($iFlag And Not $visible) Or (Not $iFlag And $visible) Then Return 0 Else Local $TRAYDATA = _SysTrayGetButtonInfo($index, $iWin, 2) If @error Then Return SetError(@error, 0, -1) Local $NOTIFYICONDATA = DllStructCreate("dword cbSize;hwnd hWnd;uint uID;uint uFlags;uint uCallbackMessage;handle hIcon;wchar szTip[128];" _ & "dword dwState;dword dwStateMask;wchar szInfo[256];uint uVersion;wchar szInfoTitle[64];dword dwInfoFlags;" _ & "STRUCT;ulong;ushort;ushort;byte[8];ENDSTRUCT;handle hBalloonIcon") DllStructSetData($NOTIFYICONDATA, 1, DllStructGetSize($NOTIFYICONDATA)) DllStructSetData($NOTIFYICONDATA, 2, Ptr(DllStructGetData($TRAYDATA, 1))) DllStructSetData($NOTIFYICONDATA, 3, DllStructGetData($TRAYDATA, 2)) DllStructSetData($NOTIFYICONDATA, 4, 8) ; NIF_STATE DllStructSetData($NOTIFYICONDATA, 8, $iFlag) ; dw_State, 0 or 1 = NIS_HIDDEN DllStructSetData($NOTIFYICONDATA, 9, 1) ; dwStateMask Local $ret = DllCall("shell32.dll", "bool", "Shell_NotifyIconW", "dword", 0x1, "struct*", $NOTIFYICONDATA) ; NIM_MODIFY DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", WinGetHandle("[CLASS:Shell_TrayWnd]"), "uint", 0x001A, "wparam", 0, "lparam", 0) ; WM_SETTINGCHANGE If IsArray($ret) And $ret[0] Then Return 1 Else Return 0 EndIf ;~ $ret = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_HIDEBUTTON, "wparam", DllStructGetData($TBBUTTON, 2), "lparam", $iHide) ;~ If @error Or Not $ret[0] Then ;~ $return = -1 ;~ Else ;~ $return = $ret[0] ;~ EndIf EndIf EndFunc ;==>_SysTrayIconHide ;=============================================================================== ; ; Function Name: _SysTrayIconMove($curPos, $newPos, $iWin = 1) ; Description: Moves systray icon ; ; Parameter(s): $curPos - icon's current index (0 based) ; $newPos - icon's new position ; ($curPos+1 = one step to right, $curPos-1 = one step to left) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): AutoIt3 Beta ; Return Value(s): On Success - Returns 1 if operation was successfull, 0 if not ; On Failure - Sets @error and returns -1 ; | 1 - Bad parameters ; | 2 - Failed to find tray window ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconMove($curPos, $newPos, $iWin = 1) Local Const $TB_MOVEBUTTON = 0x0452 ; WM_USER + 82 Local $iconCount = _SysTrayIconCount($iWin) If $curPos < 0 Or $newPos < 0 Or $curPos > $iconCount - 1 Or $newPos > $iconCount - 1 Or Not IsInt($curPos) Or Not IsInt($newPos) Then Return SetError(1, 0, -1) Local $hWnd = _FindTrayToolbarWindow($iWin) If $hWnd = -1 Then Return SetError(2, 0, -1) Local $ret = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $TB_MOVEBUTTON, "wparam", $curPos, "lparam", $newPos) If @error Or Not $ret[0] Then Return 0 Else Return 1 EndIf EndFunc ;==>_SysTrayIconMove ;=============================================================================== ; ; Function Name: _SysTrayIconRemove($index, $iWin = 1) ; Description: Removes systray icon completely. ; ; Parameter(s): $index - Icon index (first icon is 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Return Value(s): On Success - Returns 1 if icon successfully removed, 0 if not ; On Failure - Sets @error and returns -1 ; | See _SysTrayGetButtonInfo for @error returns ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconRemove($index, $iWin = 1) Local Const $TB_DELETEBUTTON = 1046 Local $TRAYDATA = _SysTrayGetButtonInfo($index, $iWin, 2) If @error Then Return SetError(@error, 0, -1) Local $NOTIFYICONDATA = DllStructCreate("dword cbSize;hwnd hWnd;uint uID;uint uFlags;uint uCallbackMessage;handle hIcon;wchar szTip[128];" _ & "dword dwState;dword dwStateMask;wchar szInfo[256];uint uVersion;wchar szInfoTitle[64];dword dwInfoFlags;" _ & "STRUCT;ulong;ushort;ushort;byte[8];ENDSTRUCT;handle hBalloonIcon") DllStructSetData($NOTIFYICONDATA, 1, DllStructGetSize($NOTIFYICONDATA)) DllStructSetData($NOTIFYICONDATA, 2, Ptr(DllStructGetData($TRAYDATA, 1))) DllStructSetData($NOTIFYICONDATA, 3, DllStructGetData($TRAYDATA, 2)) Local $ret = DllCall("shell32.dll", "bool", "Shell_NotifyIconW", "dword", 0x2, "struct*", $NOTIFYICONDATA) ; NIM_DELETE DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", WinGetHandle("[CLASS:Shell_TrayWnd]"), "uint", 0x001A, "wparam", 0, "lparam", 0) ; WM_SETTINGCHANGE If IsArray($ret) And $ret[0] Then Return 1 Else Return 0 EndIf ;~ Local $hWnd = _FindTrayToolbarWindow($iWin) ;~ If $hwnd = -1 Then Return -1 ;~ Local $ret = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $TB_DELETEBUTTON, "wparam", $index, "lparam", 0) ;~ If @error Or Not $ret[0] Then Return -1 ;~ Return $ret[0] EndFunc ;==>_SysTrayIconRemove ;=============================================================================== ; ; Function Name: _FindTrayToolbarWindow($iWin = 1) ; Description: Utility function for finding Toolbar window hwnd ; Parameter(s): $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns Toolbar window hwnd ; On Failure - returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _FindTrayToolbarWindow($iWin = 1) Local $hwnd, $ret = -1 If $iWin = 1 Then $hWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "Shell_TrayWnd", "ptr", 0) If @error Then Return -1 $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "TrayNotifyWnd", "ptr", 0) If @error Then Return -1 If @OSVersion <> "WIN_2000" Then $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "SysPager", "ptr", 0) If @error Then Return -1 EndIf $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "ToolbarWindow32", "ptr", 0) If @error Then Return -1 $ret = $hwnd[0] ElseIf $iWin = 2 Then ; NotifyIconOverflowWindow for Windows 7 $hWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "NotifyIconOverflowWindow", "ptr", 0) If @error Then Return -1 $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "ToolbarWindow32", "ptr", 0) If @error Then Return -1 $ret = $hwnd[0] EndIf Return $ret EndFunc ;==>_FindTrayToolbarWindow Example #NoTrayIcon #include <_SysTray.au3> #include <Process.au3> $count = _SysTrayIconCount() ConsoleWrite("Count visible tray: " & $count & @CRLF) For $i = $count - 1 To 0 Step -1 $handle = _SysTrayIconHandle($i) $visible = _SysTrayIconVisible($i) $pid = WinGetProcess($handle) $name = _ProcessGetName($pid) $title = WinGetTitle($handle) $tooltip = _SysTrayIconTooltip($i) ConsoleWrite("index: " & $i & @TAB & "visible: " & $visible & @TAB & "handle: " & $handle & @TAB & "pid: " & _ $pid & @TAB & "proc: " & $name & @TAB & @TAB & "title: " & $title & @TAB & @TAB & "tooltip: " & $tooltip & @CRLF) If $pid = -1 Then _SysTrayIconRemove($i) Next If _FindTrayToolbarWindow(2) <> -1 Then ConsoleWrite("-====================-" & @CRLF) $countwin7 = _SysTrayIconCount(2) ConsoleWrite("Count overflow area: " & $countwin7 & @CRLF) For $i = $countwin7 - 1 To 0 Step -1 $handle = _SysTrayIconHandle($i, 2) $visible = _SysTrayIconVisible($i, 2) $pid = WinGetProcess($handle) $name = _ProcessGetName($pid) $title = WinGetTitle($handle) $tooltip = _SysTrayIconTooltip($i, 2) ConsoleWrite("index: " & $i & @TAB & "visible: " & $visible & @TAB & "handle: " & $handle & @TAB & "pid: " & _ $pid & @TAB & "proc: " & $name & @TAB & @TAB & "title: " & $title & @TAB & @TAB & "tooltip: " & $tooltip & @CRLF) If $pid = -1 Then _SysTrayIconRemove($i, 2) Next EndIf
    1 point
  2. behadsoft, Only a little different: ;#RequireAdmin #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GuiTreeView.au3> #include <Array.au3> #include <File.au3> Local $Count = 0 ; Now you need this <<<<<<<<<<<<<<<<<<<<<< Global Const $SourcesPath = @ScriptDir ;Create GUI Local $GUI = GUICreate("TreeView") ; Create InputBox Local $Input = GUICtrlCreateInput("", 100, 25) Local $idInputChange = GUICtrlCreateDummy() ; Crete TreeView Local $TreeObject = GUICtrlCreateTreeView(100, 70, 200, 250) Local $hTreeObject = GUICtrlGetHandle($TreeObject) ;Get Folder name to Array $GetFolderList = _FileListToArray($SourcesPath, "*", $FLTA_FOLDERS) ;Create parent and child folders - child is a 1D array to hold all the child ControlIDs <<<<<<<<<<<<<<<<<<< Local $Parent[UBound($GetFolderList)] Local $Child[1] ;Get SubFolders and Add Child to Tree View Item For $a = 1 To UBound($Parent) - 1 $Parent[$a] = GUICtrlCreateTreeViewItem($GetFolderList[$a], $TreeObject) ; Note you need to add the "\" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $RecordChildFolder = _FileListToArrayRec($SourcesPath & "\" & $GetFolderList[$a], "*", $FLTAR_FOLDERS, $FLTAR_NORECUR, $FLTAR_SORT) ; if folders were found <<<<<<<<<<<<<<<<<<<<<<< If Not @error Then ; Adjust the size of the child array to fit the new children <<<<<<<<<<<<<<<<<<<<<<<<< ReDim $Child[UBound($Child) + $RecordChildFolder[0]] For $b = 1 To UBound($RecordChildFolder) - 1 ; Increase count to get next insertion point $Count += 1 $Child[$Count] = GUICtrlCreateTreeViewItem($RecordChildFolder[$b], $Parent[$a]) Next EndIf Next ;Local $iEnd = GUICtrlCreateDummy() GUISetState() ConsoleWrite("Search for 0 - 14" & @CRLF & @CRLF) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") While 1 Switch GUIGetMsg() ; Search in InputBox Case $idInputChange _Search() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($GUI) Func _Search() $InputText = GUICtrlRead($Input) If $InputText <> "" Then ; Now look through the 2D array to find matches For $i = 1 To UBound($Child) - 1 $TreeItemText = GUICtrlRead($Child[$i], 1) If StringInStr($TreeItemText, $InputText) <> 0 Then MsgBox(0, "", $TreeItemText) EndIf Next EndIf EndFunc ;==>_Search Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF) ; LoWord - this gives the control which sent the message Local $iCode = BitShift($wParam, 16) ; HiWord - this gives the message that was sent If $iCode = $EN_CHANGE Then ; If we have the correct message Switch $iIDFrom ; See if it comes from one of the inputs Case $Input GUICtrlSendToDummy($idInputChange) EndSwitch EndIf EndFunc ;==>MY_WM_COMMAND And please when you reply in future, use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - responders know what they wrote and it just pads the thread unnecessarily. Thanks in advance for your cooperation. M23
    1 point
  3. behdadsoft, You are constantly reusing the same $Child array to list the contents of each folder - so you only ever end up with the final folder contents in that array. Not surprising that you do not find the contents of the other folders. You also limit this array to 10 elements - what happens if there are more than 10 folders within a folder? You need to store all of the child ControlIDs - like this: ;#RequireAdmin #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GuiTreeView.au3> #include <Array.au3> #include <File.au3> ;Local $Count = 0 ; What is this for? <<<<<<<<<<<<<<<<<<<<<< Global Const $SourcesPath = @ScriptDir ;Create GUI Local $GUI = GUICreate("TreeView") ; Create InputBox Local $Input = GUICtrlCreateInput("", 100, 25) Local $idInputChange = GUICtrlCreateDummy() ; Crete TreeView Local $TreeObject = GUICtrlCreateTreeView(100, 70, 200, 250) Local $hTreeObject = GUICtrlGetHandle($TreeObject) ;Get Folder name to Array $GetFolderList = _FileListToArray($SourcesPath, "*", $FLTA_FOLDERS) ;Create parent and child folders - child is a 2D array to hold all the child ControlIDs <<<<<<<<<<<<<<<<<<< Local $Parent[UBound($GetFolderList)] Local $Child[UBound($GetFolderList)][1] ;Get SubFolders and Add Child to Tree View Item ;Local $iStart = GUICtrlCreateDummy() : Why are you doing this? <<<<<<<<<<<<<<<<<<< For $a = 1 To UBound($Parent) - 1 $Parent[$a] = GUICtrlCreateTreeViewItem($GetFolderList[$a], $TreeObject) ; Note you need to add the "\" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $RecordChildFolder = _FileListToArrayRec($SourcesPath & "\" & $GetFolderList[$a], "*", $FLTAR_FOLDERS, $FLTAR_NORECUR, $FLTAR_SORT) ; if folders were found <<<<<<<<<<<<<<<<<<<<<<< If Not @error Then ; Adjust the size of the child array to fit <<<<<<<<<<<<<<<<<<<<<<<<< If $RecordChildFolder[0] > UBound($Child, 2) - 1 Then ReDim $Child[UBound($GetFolderList)][$RecordChildFolder[0] + 1] EndIf For $b = 1 To UBound($RecordChildFolder) - 1 $Child[$a][$b] = GUICtrlCreateTreeViewItem($RecordChildFolder[$b], $Parent[$a]) Next EndIf Next ;Local $iEnd = GUICtrlCreateDummy() GUISetState() ConsoleWrite("Search for 0 - 14" & @CRLF & @CRLF) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") While 1 Switch GUIGetMsg() ; Search in InputBox Case $idInputChange _Search() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($GUI) Func _Search() $InputText = GUICtrlRead($Input) If $InputText <> "" Then ; Now look through the 2D array to find matches For $i = 0 To UBound($Child) - 1 For $j = 0 To UBound($Child, 2) - 1 $TreeItemText = GUICtrlRead($Child[$i][$j], 1) If StringInStr($TreeItemText, $InputText) <> 0 Then MsgBox(0, "", $TreeItemText) EndIf Next Next EndIf EndFunc ;==>_Search Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF) ; LoWord - this gives the control which sent the message Local $iCode = BitShift($wParam, 16) ; HiWord - this gives the message that was sent If $iCode = $EN_CHANGE Then ; If we have the correct message Switch $iIDFrom ; See if it comes from one of the inputs Case $Input GUICtrlSendToDummy($idInputChange) EndSwitch EndIf EndFunc ;==>MY_WM_COMMAND That works fine for me. M23
    1 point
  4. can you post your code fixed code and mark this thread as Solved? you can edit the first post and add Solved to your thread title so others with this issue might find it useful
    1 point
  5. just thinking outside the box - download it to a ram drive then when outlook closes, delete the ram drive.
    1 point
  6. careca

    GPO Tool

    Version 1.0.0

    851 downloads

    This is a tool to back up/export current settings in the group policy, or to import. The export button simply exports the group policies to a folder with a random name. The import prompts for a folder selection, and then tries to import the policy present in that folder. I made this because i found it was the most reliable and simpler way of doing it, now i just saved the exported folder, renamed it, and when i install windows again i just import the folder and all settings are placed.
    1 point
  7. Check if the return value equals 0 Local $hIniWrite $hIniWrite = IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "Conversion", $aConversion, 1) If $hIniWrite = 0 Or @Error Then _IniWriteError("Conversion") $hIniWrite = IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "AIO", $aAIO, 1) If $hIniWrite = 0 Or @Error Then _IniWriteError("AIO") $hIniWrite = IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "Data", $aData, 1) If $hIniWrite = 0 Or @Error Then _IniWriteError("Data") $hIniWrite = IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "Redist", $aRedist, 1) If $hIniWrite = 0 Or @Error Then _IniWriteError("Redist") $hIniWrite = IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "Split", $aSplit, 1) If $hIniWrite = 0 Or @Error Then _IniWriteError("Split") $hIniWrite = IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "Autorun", $aAutorun, 1) If $hIniWrite = 0 Or @Error Then _IniWriteError("Autorun") Func _IniWriteError($sSection = "") MsgBox(4096, "Error Writing " & $sSection, "Error writing to Ini File or data format is invalid") Exit EndFunc
    1 point
  8. I'm not that great at Regex but this should work: #include <Array.au3> Local $aLaptopLog[6] = ["06.06.2018 LaptopA started", "06.06.2018 Laptop started", "06.06.2018 LaptopA started", "06.06.2018 LaptopB started", "06.06.2018 LaptopA started", "06.06.2018 Laptop started"] Local $sLaptop_to_be_searched = "Laptop" Local $aOccurrences_Laptops = _ArrayFindAll($aLaptopLog, "(?<![\w\d])" & $sLaptop_to_be_searched & "(?![\w\d])", 0, 0, 0, 3) _ArrayDisplay($aOccurrences_Laptops)
    1 point
  9. JLogan3o13

    multi threading

    @borsTiHD The help file is your friend...
    1 point
  10. The tools in this example will achieve BMP image comparison. Unless I am wrong, and I am never wrong. It's just an example of the tools however. This is kind of what you want. #include <GDIPlus.au3> _GDIPlus_Startup() $hBMP_somefile = _GDIPlus_BitmapCreateFromFile($filepath) For $y To $height For $x To $width If _GDIPlus_BitmapGetPixel($hBMP_Screen, $x, $y) = _GDIPlus_BitmapGetPixel($hBMP_somefile, $x, $y) Then ; Maybe you want to say if Not Equal <> ; I do it with a counter checksum, but then you must set a counter EndIf Next; x Next; y _GDIPlus_Shutdown() Forgive I didn't put much time into this example. Also it may not be the 'best'. It's not as fast as CPP (writing this in CPP is not that difficult and it's probably 100..1000 times faster). There are lots of other examples that I have been hopeful of, but this is what works for me. Perhaps a hash could be generated from screenshot area, and image loaded from file as hash. Never done it that way, but this concept code can do what you want in a reasonable amount of time. Remember to keep the compared area as small as you can. Less pixels; done faster. You can also use a mask to disregard pixels from a rectangular area or use a list. Use the tools in my posts above to collect the image screen data. ScreenCapture or whatever.
    1 point
  11. You do it this way: #RequireAdmin #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GuiTreeView.au3> #include <Array.au3> #include <File.au3> local Const $Path = @ScriptDir Dim $Parent[3] Dim $Child[15] local $Count = 0 ;Create GUI local $GUI = GUICreate("TreeView") GUISetState(@SW_SHOW) ; Create InputBox local $Input = GUICtrlCreateInput("",100,25) Local $idInputChange = GUICtrlCreateDummy() ; Crete TreeViewObject local $TreeObject = GUICtrlCreateTreeView(100,70,200,250) ;Create Tree Parent for $i = 0 to UBound($Parent) - 1 $Parent[$i] = GUICtrlCreateTreeViewItem("Parent " & $i, $TreeObject) ConsoleWrite( "Parent " & $i & @CRLF ) ;Add Child to Parents for $j = 0 to 4 $Child[$Count] = GUICtrlCreateTreeViewItem("Child " & $Count, $Parent[$i]) ConsoleWrite( " Child " & $Count & @CRLF ) $Count += 1 Next ConsoleWrite( @CRLF ) Next ConsoleWrite( "Search for 0 - 14" & @CRLF & @CRLF ) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") while 1 Switch GUIGetMsg() ; Search in InputBox ; Search for 0 - 14 Case $idInputChange $InputText = GUICtrlRead($Input) if $InputText <> "" Then ConsoleWrite( "$InputText = [" & $InputText & "]" & @CRLF ) Local $sParent, $aMatches[15], $iMatches = 0 for $i = 0 to UBound($Child) - 1 if StringInStr(GUICtrlRead($Child[$i],1), $InputText) <> 0 Then $sParent = _GUICtrlTreeView_GetText($TreeObject, _GUICtrlTreeView_GetParentHandle($TreeObject, $Child[$i])) For $j = 0 To $iMatches - 1 If $aMatches[$j] = $sParent Then ExitLoop Next If $j = $iMatches Then ; Parent not found, add parent $aMatches[$iMatches] = $sParent $iMatches += 1 EndIf EndIf Next ConsoleWrite( "Number of parent matches = " & $iMatches & @CRLF ) If $iMatches Then For $j = 0 To $iMatches - 1 ConsoleWrite( $aMatches[$j] & @CRLF ) Next EndIf ConsoleWrite( @CRLF ) EndIf Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($GUI) Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF) ; LoWord - this gives the control which sent the message Local $iCode = BitShift($wParam, 16) ; HiWord - this gives the message that was sent If $iCode = $EN_CHANGE Then ; If we have the correct message Switch $iIDFrom ; See if it comes from one of the inputs Case $Input GUICtrlSendToDummy( $idInputChange ) EndSwitch EndIf EndFunc ;==>MY_WM_COMMAND
    1 point
  12. Here is another method, sorry codes a bit of a mess, just threw it together. #cs ## Save Installs.ini to the same folder as your script ## [Department] All = Section All Finance = Section Finance HR = Section HR IT = Section IT Operation = Section Operation Procurement = Section Procurement Projects = Section Projects [Section All] Adobe Reader = Key - Adobe Reader Adobe Flash = Key - Adobe Flash Java Runtime = Key - Java Runtime [Section Finance] Adobe Flash = Key - Adobe Flash Java Runtime = Key - Java Runtime [Section HR] Adobe Flash = Key - Adobe Flash Java Runtime = Key - Java Runtime [Section IT] Adobe Flash = Key - Adobe Flash Java Runtime = Key - Java Runtime [Section Operation] Adobe Flash = Key - Adobe Flash Java Runtime = Key - Java Runtime [Section Procurement] Adobe Flash = Key - Adobe Flash Java Runtime = Key - Java Runtime [Section Projects] Adobe Flash = Key - Adobe Flash Java Runtime = Key - Java Runtime [Commands] Key - Adobe Reader = Msiexec.exe /i "@ScriptDir@\Adobe.msi" /QN /NORESTART Key - Adobe Flash = Msiexec.exe /i "@ScriptDir@\Flash.msi" /QN /NORESTART Key - Java Runtime = "@ScriptDir@\JavaRuntime.exe" /s #ce #include <Array.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt("ExpandVarStrings", 1) Global $sIniFile = @ScriptDir & "\Installs.ini" Global $aDeparments = IniReadSection($sIniFile, "Departments") If @error Then Exit Global $_sDepartment = "" Global $hGUI, $idDeparment, $idSubtitle, $idListView $hGui = GUICreate("Department", 500, 190) $idSubtitle = GUICtrlCreateLabel("Department", 10, 10, 130) GUICtrlSetFont(-1, 16, 400) $idDeparment = GUICtrlCreateCombo("Select Department", 10, 40, 200, 20, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, _ArrayToString($aDeparments, "|", 1, -1, "|", 0, 0), "Select Department") $idListView = GUICtrlCreateListView("Product Name|Install Command", 10, 65, 480, 100) GUISetState() AdlibRegister("_SetDepartment") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _SetDepartment() Local $aProducts, $sProducts Local $sDepartment = GUICtrlRead($idDeparment) If $_sDepartment = $sDepartment Then Return Switch $sDepartment Case "Select Department" _GUICtrlListView_DeleteAllItems($idListView) GUICtrlSetData($idSubtitle, $sDepartment) Case Else _GUICtrlListView_DeleteAllItems($idListView) GUICtrlSetData($idSubtitle, $sDepartment) $aProducts = IniReadSection($sIniFile, "Section - " & $sDepartment) If @error Then Return For $i = 1 To $aProducts[0][0] $sProducts = IniRead($sIniFile, "Commands", $aProducts[$i][1], "") GUICtrlCreateListViewItem($aProducts[$i][0] & "|" & $sProducts, $idListView) _GUICtrlListView_SetColumnWidth($idListView, 1, $LVSCW_AUTOSIZE_USEHEADER) Next EndSwitch $_sDepartment = $sDepartment EndFunc
    1 point
  13. @rakesh2804, Here's a starting code for you. #include <GUIConstantsEx.au3> Global $hGUI, $ctrlCombo $hGui = GUICreate("Department", 250, 120) $ctrlCombo = GUICtrlCreateCombo("All", 10, 35) GUICtrlSetData(-1, "IT|Finance|Operation|HR|Procurement|Projects", "All") $ctrlButton = GUICtrlCreateButton("SET Finance", 10, 60, 110, 30) $Label = GUICtrlCreateLabel("Choose a Department", 10, 10, 200) GUICtrlSetFont(-1, 12, 800, 4) ; 12 is the font size, 800 is a bold font, 4 is the underline, GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $ctrlButton $sComboRead = GUICtrlRead($ctrlCombo) MsgBox(0, "", "The combobox is currently displaying: " & $sComboRead, 0, $hGUI) ; You can start your searching of whatever you want to do... those pop-up things. ; Just $sComboRead as your value to get what you want. EndSwitch WEnd If you want to have a it working then detailed all your needs and we'll try to compose one.
    1 point
  14. #include <GUIConstantsEx.au3> #include <ComboConstants.au3> Global $hGUI, $ctrlCombo $hGui = GUICreate("Department", 300, 150) GUICtrlCreateLabel("Choose a Department", 10, 10, 200, 25) GUICtrlSetFont(-1, 12) $ctrlCombo = GUICtrlCreateCombo("All", 10, 35, 200, 25, BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) GUICtrlSetData(-1, "IT|Finance|Operation|HR|Procurement|Projects", "All") GUICtrlSetFont(-1, 12) $ctrlButton = GUICtrlCreateButton("SET Finance", 100, 75, 100, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $ctrlButton ControlCommand($hGui, "", $ctrlCombo, "SelectString", "Finance") EndSwitch WEnd For choosing of list of applications for cathegory use Listview (with checkboxes). EDIT: You can use Koda Form Designer - it's visual GUI editor which will generate apropriate AU3 code fo you
    1 point
  15. Have tried looking at Help file? try checking with GUICtrlCreateCombo() and see if that's what you want. Is there any coding you've made for this? post it and will see how we can help you with the GUI pop-up you want. Edit: Create you own version of coding and post it here so we can start checking and help you more. Help file is a friendly stuff, so check on it and compose your code.
    1 point
  16. TheDcoder

    AutoIt Snippets

    This functions lets you check if a window is responding or not. Equal to checking if a Window goes white after a while using your eye #include <WinAPISys.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: IsWindowNotResponding ; Description ...: Checks if a Window is not responding ; Syntax ........: IsWindowNotResponding($hWindow[, $iTimeout = 5000]) ; Parameters ....: $hWindow - A window handle. ; $iTimeout - [optional] Shouldn't matter, Timeout in milliseconds. Default is 5000. ; Return values .: @error set by _WinAPI_SendMessageTimeout ; Author ........: Damon Harris (TheDcoder) ; Remarks .......: The way it works is that it exploits SendMessageTimeout's SMTO_ABORTIFHUNG option. ; Do more research on Process.Responding and how it works (C# function for checking if a window is responding) ; Link ..........: https://git.io/vbcvJ ; Example .......: If IsWindowNotResponding($hWindow) Then DoSomething() ; =============================================================================================================================== Func IsWindowNotResponding($hWindow, $iTimeout = 5000) _WinAPI_SendMessageTimeout($hWindow, 0, 0, 0, $iTimeout, $SMTO_ABORTIFHUNG) Return @error EndFunc
    1 point
  17. darkshark, Perhaps this will help? #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #Include <ScreenCapture.au3> #Include <Misc.au3> Global $iX1, $iY1, $iX2, $iY2, $aPos, $sMsg, $sBMP_Path ; Create GUI $hMain_GUI = GUICreate("Select Rectangle", 240, 50) $hRect_Button = GUICtrlCreateButton("Mark Area", 10, 10, 80, 30) $hCancel_Button = GUICtrlCreateButton("Cancel", 150, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $hCancel_Button FileDelete(@ScriptDir & "Rect.bmp") Exit Case $hRect_Button GUISetState(@SW_HIDE, $hMain_GUI) Mark_Rect() ; Capture selected area $sBMP_Path = @ScriptDir & "Rect.bmp" _ScreenCapture_Capture($sBMP_Path, $iX1, $iY1, $iX2, $iY2, False) GUISetState(@SW_SHOW, $hMain_GUI) ; Display image $hBitmap_GUI = GUICreate("Selected Rectangle", $iX2 - $iX1 + 1, $iY2 - $iY1 + 1, 100, 100) $hPic = GUICtrlCreatePic(@ScriptDir & "Rect.bmp", 0, 0, $iX2 - $iX1 + 1, $iY2 - $iY1 + 1) GUISetState() EndSwitch WEnd ; ------------- Func Mark_Rect() Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp Local $UserDLL = DllOpen("user32.dll") ; Create transparent GUI with Cross cursor $hCross_GUI = GUICreate("Test", @DesktopWidth, @DesktopHeight - 20, 0, 0, $WS_POPUP, $WS_EX_TOPMOST) WinSetTrans($hCross_GUI, "", 8) GUISetState(@SW_SHOW, $hCross_GUI) GUISetCursor(3, 1, $hCross_GUI) Global $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0x000000) ; Wait until mouse button pressed While Not _IsPressed("01", $UserDLL) Sleep(10) WEnd ; Get first mouse position $aMouse_Pos = MouseGetPos() $iX1 = $aMouse_Pos[0] $iY1 = $aMouse_Pos[1] ; Draw rectangle while mouse button pressed While _IsPressed("01", $UserDLL) $aMouse_Pos = MouseGetPos() $hMaster_Mask = _WinAPI_CreateRectRgn(0, 0, 0, 0) $hMask = _WinAPI_CreateRectRgn($iX1, $aMouse_Pos[1], $aMouse_Pos[0], $aMouse_Pos[1] + 1) ; Bottom of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) $hMask = _WinAPI_CreateRectRgn($iX1, $iY1, $iX1 + 1, $aMouse_Pos[1]) ; Left of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) $hMask = _WinAPI_CreateRectRgn($iX1 + 1, $iY1 + 1, $aMouse_Pos[0], $iY1) ; Top of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) $hMask = _WinAPI_CreateRectRgn($aMouse_Pos[0], $iY1, $aMouse_Pos[0] + 1, $aMouse_Pos[1]) ; Right of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) ; Set overall region _WinAPI_SetWindowRgn($hRectangle_GUI, $hMaster_Mask) If WinGetState($hRectangle_GUI) < 15 Then GUISetState() Sleep(10) WEnd ; Get second mouse position $iX2 = $aMouse_Pos[0] $iY2 = $aMouse_Pos[1] ; Set in correct order if required If $iX2 < $iX1 Then $iTemp = $iX1 $iX1 = $iX2 $iX2 = $iTemp EndIf If $iY2 < $iY1 Then $iTemp = $iY1 $iY1 = $iY2 $iY2 = $iTemp EndIf GUIDelete($hRectangle_GUI) GUIDelete($hCross_GUI) DllClose($UserDLL) EndFunc ;==>Mark_Rect Any use? M23
    1 point
  18. OMG! RTFM mate, you're getting brilliant help, yet you ain't trying one bit! So here you go. Your answer. Plucked it ALL from in the example in the help file that Uten mentioned. Amazing aint it? #include <GUIConstants.au3> #Include <GuiTreeView.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 183, 175, 193, 115) $hTreeView = GUICtrlCreateTreeView(8, 8, 169, 129) $parent_1 = _GUICtrlTreeView_Add($hTreeView, 0, "Parent 1") $parent_2 = _GUICtrlTreeView_Add($hTreeView, 0, "Parent 2") $child_1_1 = _GUICtrlTreeView_AddChild($hTreeView, $parent_1, "Child 1") $child_1_2 = _GUICtrlTreeView_AddChild($hTreeView, $parent_1, "Child 2") $child_1_3 = _GUICtrlTreeView_AddChild($hTreeView, $parent_1, "Child 3") $child_2_1 = _GUICtrlTreeView_AddChild($hTreeView, $parent_2, "Child 4") $child_2_2 = _GUICtrlTreeView_AddChild($hTreeView, $parent_2, "Child 4") $child_2_2_1 = _GUICtrlTreeView_AddChild($hTreeView, $child_2_2, "Child 5") $Button1 = GUICtrlCreateButton("Exit", 16, 144, 75, 25, 0) $Button2 = GUICtrlCreateButton("Delete Child 3", 96, 144, 75, 25, 0) _GUICtrlTreeView_Expand($hTreeView) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit Case $Button2 $ret = _GUICtrlTreeView_Delete ($hTreeView, $child_1_3) EndSwitch WEnd
    1 point
×
×
  • Create New...