Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/22/2020 in all areas

  1. @ur This might help you
    2 points
  2. water

    OutlookEX_GUI UDF

    The OutlookEX UDF has become quite large. So I have split the UDF into two pieces: OutlookEX: This UDF holds the functions to automate items (folders, mails, contacts ...) in the background. Can be seen like an API. OutlookEX_GUI: This UDF holds the functions to automate the Outlook GUI. This thread describes OutlookEX_GUI. At the moment you will find functions to automate the following Outlook elements: BarGroups NavigationFolders Views (not fully finished) Documentation Download
    1 point
  3. 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
  4. Just suggestions, no idea if that helps you. https://www.autoitscript.com/forum/topic/168087-gifcamex/ Without AutoIt : https://www.cockos.com/licecap/
    1 point
  5. Why don't you look at your script's detailed log file that includes error messages, progress messages, state information, and any other information that could be used to debug problems? What's that? Your script doesn't create such a log file? Well maybe it should so you don't have to ask others to guess why some random PC isn't reacting the way you think it should.
    1 point
  6. No, but I just tried by copying the following files to my G:\Scripts directory -- G:\Scripts\chromedriver.exe G:\Scripts\test3.au3 G:\Scripts\wd_core.au3 I then ran test3.au3 from Scite and it worked as expected.
    1 point
  7. Here's a customized version I use in SMF. Return buffer size is defined in row containing Local $iFileBufferSize = 32768 * 10 #include <Array.au3> #include <WindowsConstants.au3> #include <WinAPIDlg.au3> Global $f_CDN__FileDialogsEx_Start = 1 $sFile = _FileOpenDialog_Ex("SMF _FileOpenDialog_Ex", @ScriptDir, "All (*.*)", 1 + 2, "", 0, 1) $aFiles = StringSplit($sFile, "|") _ArrayDisplay($aFiles) Func _FileOpenDialog_Ex($sTitle, $sInitDir, $sFilter, $iOptions = 0, $sDefaultName = "", $hWnd = 0, $iType = 0) #cs https://groups.google.com/forum/?hl=en&fromgroups=#!topic/microsoft.public.vc.mfc/HafQr4gIRY0 The problem is that GetOpenFileName changes the current directory to the last browsed one. The current directory and any of its parents cannot be deleted. #ce If Not $sInitDir Then If Not FileExists("\\?\" & $sInitDir) Then $sInitDir = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" ; CLSID for "My Computer" EndIf Local $sWorkingDir = @WorkingDir If $iType = 1 Then $f_CDN__FileDialogsEx_Start = 1 Local $sFilename = _FileOpenDialogEx($sTitle, $sInitDir, $sFilter, BitOR($OFN_ENABLESIZING, $OFN_ALLOWMULTISELECT), $sDefaultName, $hWnd) Else Local $sFilename = FileOpenDialog($sTitle, $sInitDir, $sFilter, $iOptions, $sDefaultName, $hWnd) EndIf Local $iError = @error FileChangeDir($sWorkingDir) Return SetError($iError, 0, $sFilename) EndFunc ;==>_FileOpenDialog_Ex Func _FileOpenDialogEx($sTitle = "", $sInitDir = "", $sFilter = "All Files (*.*)", $iOptions = 0, $sDefaultName = "", $hParent = 0, $hTemplate = 0, $sTemplateName = "") Local $sRet = _GetOpenSaveFileName('GetOpenFileNameW', $hTemplate, $sTemplateName, $hParent, $sTitle, $sInitDir, $sFilter, $iOptions, $sDefaultName) If @error Then SetError(@error) Return $sRet EndFunc ;==>_FileOpenDialogEx Func _GetOpenSaveFileName($sFunction, $hTemplate, $sTemplateName, $hParent, $sTitle, $sInitDir, $sFilter, $iOptions, $sDefaultName) Local $taFilters, $tFile, $_OFN_HookProc = 0, $iFlagsEx = 0, $iFlagsForced = BitOR($OFN_EXPLORER, $OFN_HIDEREADONLY, $OFN_NODEREFERENCELINKS) $iOptions = BitOR($iFlagsForced, $iOptions) If BitAND($iOptions, $OFN_EX_NOPLACESBAR) Then $iOptions = BitXOR($iOptions, $OFN_EX_NOPLACESBAR) $iFlagsEx = $OFN_EX_NOPLACESBAR EndIf Local $tagBuffer = "wchar[4096]", $iBufferSize = 4095 Local $aFilters = StringSplit($sFilter, "|"), $saFilters = "", $tagFilters = "", $aFiltSplit, $i For $i = 1 To $aFilters[0] $aFiltSplit = StringRegExp($aFilters[$i], "(?U)\A\h*(.+)\h*\((.*)\)", 1) $saFilters &= $aFilters[$i] & Chr(0) & $aFiltSplit[1] & Chr(0) Next $tagFilters = "wchar[" & StringLen($saFilters) + 3 & "]" $taFilters = DllStructCreate($tagFilters) DllStructSetData($taFilters, 1, $saFilters) Local $iFileBufferSize = 32768 * 10 Local $tagFileBuffer = "wchar[" & $iFileBufferSize & "]" $tFile = DllStructCreate($tagFileBuffer) ; Win2000/XP: should be 32k for ansi, unlimited for unicode If $sDefaultName <> "" Then DllStructSetData($tFile, 1, $sDefaultName) Local $tOFN = DllStructCreate('dword lStructSize;hwnd hwndOwner;hwnd hInstance;' & _ 'ptr lpstrFilter;ptr lpstrCustomFilter;dword nMaxCustFilter;dword nFilterIndex;' & _ 'ptr lpstrFile;dword nMaxFile;ptr lpstrFileTitle;dword nMaxFileTitle;ptr lpstrInitialDir;ptr lpstrTitle;' & _ 'dword Flags;short nFileOffset;short nFileExtension;ptr lpstrDefExt;dword lCustData;ptr lpfnHook;ptr lpTemplateName;' & _ 'dword Reserved[2];dword FlagsEx') DllStructSetData($tOFN, 'lStructSize', DllStructGetSize($tOFN)) If IsHWnd($hParent) Then DllStructSetData($tOFN, 'hwndOwner', $hParent) DllStructSetData($tOFN, 'lpstrFilter', DllStructGetPtr($taFilters)) DllStructSetData($tOFN, 'nFilterIndex', 1) DllStructSetData($tOFN, 'lpstrFile', DllStructGetPtr($tFile)) DllStructSetData($tOFN, 'nMaxFile', $iFileBufferSize) DllStructSetData($tOFN, 'FlagsEx', $iFlagsEx) If $hTemplate <> 0 Then If $sTemplateName <> "" Then $iOptions = BitOR($iOptions, $OFN_ENABLETEMPLATE) DllStructSetData($tOFN, 'hInstance', $hTemplate) Local $tTemplateName = DllStructCreate($tagBuffer) ; 'char[256]') DllStructSetData($tTemplateName, 1, $sTemplateName) DllStructSetData($tOFN, 'lpTemplateName', DllStructGetPtr($tTemplateName)) Else $iOptions = BitOR($iOptions, $OFN_ENABLETEMPLATEHANDLE) DllStructSetData($tOFN, 'hInstance', $hTemplate) EndIf EndIf $iOptions = BitOR($iOptions, $OFN_ENABLEHOOK, $OFN_ENABLEINCLUDENOTIFY) $_OFN_HookProc = DllCallbackRegister("_OFN_HookProc", "int", "hwnd;uint;wparam;lparam") DllStructSetData($tOFN, 'lpfnHook', DllCallbackGetPtr($_OFN_HookProc)) If $sTitle <> "" Then Local $tTitle = DllStructCreate($tagBuffer) DllStructSetData($tTitle, 1, String($sTitle)) DllStructSetData($tOFN, "lpstrTitle", DllStructGetPtr($tTitle)) EndIf If $sInitDir <> "" Then Local $tInitDir = DllStructCreate($tagBuffer) DllStructSetData($tInitDir, 1, String($sInitDir)) DllStructSetData($tOFN, "lpstrInitialDir", DllStructGetPtr($tInitDir)) EndIf DllStructSetData($tOFN, 'Flags', $iOptions) Local $aRet = DllCall('comdlg32.dll', 'int', $sFunction, 'ptr', DllStructGetPtr($tOFN)) Local $iError = @error If $_OFN_HookProc <> 0 Then DllCallbackFree($_OFN_HookProc) If $iError Then Return SetError(2, $iError, "") ElseIf $aRet[0] Then Local $iChar = 1 While $iChar < $iFileBufferSize + 1 If DllStructGetData($tFile, 1, $iChar) = "" Then If DllStructGetData($tFile, 1, $iChar + 1) = "" Then ExitLoop DllStructSetData($tFile, 1, "|", $iChar) EndIf $iChar += 1 WEnd Return SetError(0, 0, DllStructGetData($tFile, 1)) Else Return SetError(1, 0, "") EndIf EndFunc ;==>_GetOpenSaveFileName Volatile Func _OFN_HookProc($hWnd, $Msg, $wParam, $lParam) Switch $Msg Case $WM_NOTIFY Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate("hwnd hWndFrom;int idFrom;int code", $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iIDFrom = DllStructGetData($tNMHDR, "idFrom") $iCode = DllStructGetData($tNMHDR, "code") Switch $iCode Case $CDN_FOLDERCHANGE If $f_CDN__FileDialogsEx_Start Then ; if executing first time Local $aRet = DllCall('user32.dll', 'hwnd', 'FindWindowEx', 'hwnd', $hWndFrom, 'hwnd', 0, 'str', "SHELLDLL_DefView", 'str', "") If $aRet[0] = 0 Then ConsoleWrite("_OFN_HookProc" & @TAB & "_FindWindowEx Error" & @CRLF) Else DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $aRet[0], 'uint', $WM_COMMAND, 'wparam', 0x702c, 'lparam', 0) ; $ODM_VIEW_DETAIL EndIf WinMove($hWndFrom, "", @DesktopWidth / 2 - 650 / 2, @DesktopHeight / 2 - 600 / 2, 650, 600) $f_CDN__FileDialogsEx_Start = 0 ; to make sure these tweaks happens only once. EndIf EndSwitch Case Else EndSwitch Return 0 EndFunc ;==>_OFN_HookProc
    1 point
  8. The above code doesn't work for you?
    1 point
  9. @r2du-soft This code seems to work: #include <WinAPISys.au3> Global $iLayout = 0x0409 If _WinAPI_LoadKeyboardLayout($iLayout, $KLF_ACTIVATE) <> 0 Then ConsoleWrite("_WinAPI_LoadKeyboardLayout OK!" & @CRLF) Sleep(5000) ; So you can see if the language is present in the language box ConsoleWrite("_WinAPI_UnloadKeyboardLayout = " & _WinAPI_UnloadKeyboardLayout($iLayout) & @CRLF) EndIf Did you check in the language box if the language desired is present?
    1 point
  10. @r2du-soft What is the return value of the function, and, eventually, what is the value of_WinAPI_GetLastError() after the function call?
    1 point
  11. LeftyGuitar

    GLFW3 Wrapper

    Hello all, I have made a wrapper for GLFw3 for use with AutoIt 3. You can grab it here from here: Here #include <GLFW3.au3> Local $gl = glfwInit() if $gl = -1 Then MsgBox(1,"Error","Failed to init GLFW!") EndIf Local $w = 640, $h = 480 Local $win = glfwCreateWindow($w,$h,"MyWin",Null,Null) If $win = -1 Then MsgBox(1,"Error","Failed to create GLFW Window!") glfwTerminate() EndIf glfwMakeContextCurrent($win) While not glfwWindowShouldClose($win) ;glfwSwapBuffers($win) glfwPollEvents() WEnd glfwTerminate()
    1 point
  12. Once the item deleted, the selection is lost (rectangle set to previous item, well actually to current one, that take the place of the deleted one), take the value before deletion, and i think better to use _GUICtrlListBox_GetCurSel. Case $button_Remove $iSel = _GUICtrlListBox_GetCurSel($list_data_sample) _GUICtrlListBox_DeleteString($list_data_sample, $iSel) GUICtrlSetData($results,"zero-based index " & $iSel & " deleted!")
    1 point
×
×
  • Create New...