Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/01/2012 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. 1 point
  3. Mechaflash, Not that difficult: #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("", 100, 100, -1, -1, $WS_POPUP, BitOr($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) ; Must be within GUI window $cButton_Exit = GUICtrlCreateButton(" Exit ", 10, 10, 80, 30) $cVol_Up = GUICtrlCreateButton("Vol Up", 10, 40, 80, 30) $cVol_Dn = GUICtrlCreateButton("Vol Down", 10, 70, 80, 30) GUISetControlsVisible($hGUI) GUISetState() While 1 Switch GUIGetMsg() Case $cVol_Up ConsoleWrite("Up" & @CRLF) Case $cVol_Dn ConsoleWrite("Down" & @CRLF) Case $cButton_Exit Exit EndSwitch WEnd Func GUISetControlsVisible($hWnd) Local $aM_Mask, $aCtrlPos, $aMask $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0) $aLastID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", GUICtrlGetHandle(-1)) For $i = 3 To $aLastID[0] $aCtrlPos = ControlGetPos($hWnd, '', $i) If Not IsArray($aCtrlPos) Then ContinueLoop $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", _ "long", $aCtrlPos[0], _ "long", $aCtrlPos[1], _ "long", $aCtrlPos[0] + $aCtrlPos[2], _ "long", $aCtrlPos[1] + $aCtrlPos[3]) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2) Next DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aM_Mask[0], "int", 1) EndFunc M23
    1 point
  4. Raffav, You can do that yourself - just edit the first post and select the "Use Full Editor" option to open up the title for editing. But if you are going to ask a more complicated question regarding those control types, I suggest you start another thread. M23
    1 point
  5. As bogQ suggested: Insert Sleep and your script should exactly do what you want.
    1 point
  6. then insert Sleep(1000*60*3);1000ms 60sec 3min on new empty line just after WinActivate("MaxTalk")
    1 point
  7. Where in the registry is the setting? Because if it's in HKCU, then the user can change it even without admin rights.
    1 point
  8. Kevin, if I remember when I used to develop with Windows many years back, there is actually a file hook that you can trap and listen into. Scanning folders and files takes too much file intensive operations. You don't have to run jobs to scan the file system. Its a waste of resources. . Rather, what you want to do is listen in on the file changes and filter out only the directory and files you are interested in. You can keep a running change list and avoid having to clobber the file system every time you want to run a job to dirctory walk. In other words, let the events come to you, rather than you forcing the issue looking for them. I'll point you to FileSystemWatcher class in the .NET Framework 4.5 for now to study. Have fun.
    1 point
  9. Hey Positive Results.............. I got that 2147483647 is the Maximum Value that a Edit Control Can Hold Using This Code #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiEdit.au3> #include <GuiConstantsEx.au3> Opt('MustDeclareVars', 1) $Debug_Ed = False ; Check ClassName being passed to Edit functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hEdit ; Create GUI GUICreate("Edit Set Limit Text", 400, 300) $hEdit = GUICtrlCreateEdit("This is a test" & @CRLF & "Another Line", 2, 2, 394, 268) GUISetState() MsgBox(4160, "Information", "Text Limit: " & _GUICtrlEdit_GetLimitText($hEdit)) MsgBox(4160, "Information", "Setting Text Limit") Local $x=2147483630,$sdata While 1 _GUICtrlEdit_SetLimitText($hEdit,$x) $sdata=_GUICtrlEdit_GetLimitText($hEdit) ConsoleWrite("Information"&@TAB&"Text Limit: " &$sdata &@CRLF) If $sdata<=0 Then ExitLoop $x+=1 WEnd GUIDelete() EndFunc ;==>_Main Thumbs Up If it Helped Regards Phoenix XL
    1 point
  10. Yes it does work. I can have now 2000000 char. and 43739 lines #include #include #include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 449, 192, 114) $Edit1 = GUICtrlCreateEdit("", 8, 16, 609, 409) GUICtrlSetLimit(-1, 2000000) ; sets the limit to 2000000 characters or you can put the maximum 2147483647 as user PhoenixXL sugests GUICtrlSetData(-1, "") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
    1 point
  11. Have you looked at GUICtrlSetLimit ? Set the limit to 2000000 characters and see if that fixes it.
    1 point
  12. Au3PreProcessor 1.8 - a totally rewrite of one old application of mine that gave me gray hear of trouble but durring the long and dark month here in the December nights in Copenhagen, Denmark - Well almost a black hole, shi¤%/&(... The application started years ago when I discovered some trouble with the autoit3 compile concepts - to buildin all includes totally, no selective of only used functions and constants and that is just what this tool do - read in depth what is used and not, no limits how deep it goes 'reused functions from other .udf in these includes' . Another thing is that some peoble has concerns that scripts can be read after the 'wrap into an execute' well this tool makes script almost non readable - check out this script your self... One has to remember with these third level interpretted languages as 'autoit3' that they has to read in every character one by one, build constant variable lists and function lists before any action take place and Au3PreProcess can speed up the execute process and squize the application weight for some 500 Kb in some conditions as the final script only holds the used constans and functions... The application is a beta version as only the PreProcess action is written and functional and I would like to get responce or ideers for implimentations but planned is to be able to write a Makefile to easy do a directly recompile, do a testing execute process and to do a directly compile pass to 'CompileIt.exe with or without intuition... There is no way the application can cobe for directly created function calls with the function 'Call' and I do thing that it could be a problem with plug-ins' but I don't know jet here... Copy the script below to a directory and use the Process gadget - this will do a PreProcessed Clone from the Process options in the local path with a '_Pre' attached... Please report trouble but beaware that autoit3 is a 'typeless language' and not every Process options is wice in every conditions as ';' is a parametre for comments but could also be written into a string and then the string would be half and faulty... CODEGlobal Const $LVM_FIRST=0x1000Global Const $GUI_CHECKED= 1 Global Const $LVS_EX_GRIDLINES= 0x00000001 Global Const $LVS_EX_CHECKBOXES= 0x00000004 Global Const $LV_ERR=-1 Global Const $LVIF_STATE=0x8 Global Const $LVIS_STATEIMAGEMASK=0xF000 Global Const $LVM_SETITEMSTATE=($LVM_FIRST+43) Global Const $MEM_MAP="uint;uint;ptr" Global Const $MEM_MAP_HPROC=1 Global Const $MEM_MAP_ISIZE=2 Global Const $MEM_MAP_PMEM=3 Global Const $MEM_COMMIT=0x00001000 Global Const $MEM_RESERVE=0x00002000 Global Const $MEM_SHARED=0x08000000 Global Const $PAGE_READWRITE=0x00000004 Global Const $PROCESS_VM_OPERATION=0x00000008 Global Const $PROCESS_VM_READ=0x00000010 Global Const $PROCESS_VM_WRITE=0x00000020 HotKeySet("^q",'Exits');trap Q to quit Global Const $Prefs='HKEY_CURRENT_USER\software\Au3PreProcess\Prefs'; preferences entry Global Const $title='Au3Preprocess',$Rev='1.8'; title Global $dm1,$Main,$Edit,$ListC,$ConstC,$FuncC,$PreproC,$RemCommBC,$RemCommTC,$RemBlankC,$RemTabsC,$RemLinesC,$RemOpeC,$RemPreC,$DoCompC,$DoCheckC,$LabelC,$WriteC,$ReloadC,$RemoveC,$DoTestC,$CompileC; Global main controls Global Const $Au3Path=RegRead('HKLM\Software\AutoIt v3\AutoIt','InstallDir'); get AutoIt3 path Global $RemCommB,$RemCommT,$RemBlank,$RemTabs,$RemLines,$RemOpe,$DoComp,$DoCheck; buttons variables to preferences Global $ProTM,$RunTM,$ComTM,$TopTM,$AboTM,$ExiTM; Tray menus item variables Global $includelist,$functionlist,$UsedFunctionslist; internal database variables with a blank character as sepperator Global $Chars; The main script to check-to speedup process we hold it Global Const $cc=Chr(0x3B),$ch=$cc&' ======================================================================='&@CRLF GLobal $filein,$fileout,$inpath ReadPrefs($Prefs); read in the preferences MainWin(); open main intuition While 1 $msg=GUIGetMsg(1) Select Case $msg[1]=0x00000000; Non initiated ticks handle Case $msg[1]=$Main; Main window handle Select Case $msg[0]=-3; Quit main window handle Exits() Case $msg[0]=$RemCommBC $RemCommB=GUICtrlRead($RemCommBC) Case $msg[0]=$RemCommTC $RemCommT=GUICtrlRead($RemCommTC) Case $msg[0]=$RemBlankC $RemBlank=GUICtrlRead($RemBlankC) Case $msg[0]=$RemTabsC $RemTabs=GUICtrlRead($RemTabsC) Case $msg[0]=$RemLinesC $RemLines=GUICtrlRead($RemLinesC) Case $msg[0]=$RemOpeC $RemOpe=GUICtrlRead($RemOpeC) Case $msg[0]=$DoCompC $DoComp=GUICtrlRead($DoCompC) Case $msg[0]=$DoCheckC $DoCheck=GUICtrlRead($DoCheckC) Case $msg[0]=$PreproC ExecutePreProcess() Case $msg[0]=$DoTestC GUICtrlSetData($LabelC,'Not inteplementated jet-Use Process...') Case $msg[0]=$WriteC GUICtrlSetData($LabelC,'Not inteplementated jet-Use Process...') EndSelect EndSelect Wend Exits() Func ExecutePreProcess() If $Filein='' Or StringRight($Filein,1)='\' Then $f=FileLoad('Load in a file to PreProcess...',$inPath,'Scripts (*.aut;*.au3)') If $f='' Then MsgBox(48,'ERROR...','Okay Project Cancel') Return Else If FileExists($f) Then $Filein=$f Else MsgBox(48,'ERROR...','ERROR-Project file failed') Return Endif EndIf EndIf GUICtrlSendMsg($ListC,0x1009,0,0) GUICtrlSendMsg($FuncC,0x1009,0,0) GUICtrlSendMsg($ConstC,0x1009,0,0) $fileout=StringReplace($filein,'.','_Pre.') GetIncludeList($Filein); Init the variable $includelist containing used #includes GetSubIncludes(); Check all subincludes for includes and insert these into the listview display MakeFuncAvailableList() MakeDeepCheckForNewFunctions() SampleMainAndSubFunctionsTemporary() CheckTemporaryScriptForGlobalConstants() WritePreprocessedScriptAndCleanUp($fileout) Dim $includelist='',$functionlist='',$UsedFunctionslist='',$inpath=StringMid($filein,1,StringInStr($filein,'\',0,-1)),$filein='' EndFunc Func WritePreprocessedScriptAndCleanUp($file) Dim $in=@ScriptDir&'\Temp\TmpScript.txt',$header=$ch&$cc&' '&$title&' '&$Rev&' Preprocessed-Date '&@MDAY&':'&@MON&':'&@YEAR&' Time '&@HOUR&':'&@MIN&@CRLF&$ch $IDI=FileOpen($in,2) $ID=FileOpen(@ScriptDir&'\Temp\TmpConstants.txt',0) $chars=$header&FileRead($ID)&$chars FileClose($ID) FileWrite($IDI,$chars) FileClose($IDI) $IDO=FileOpen($file,2) $IDI=FileOpen($in,0) While 1 $Line=FileReadLine($IDI) If @error Then Exitloop $wd=StringInStr($line,$cc) if $RemCommB=1 AND $wd=1 Then; remove comment blocks $line='?' ElseIf $RemCommT=1 AND $wd>1 Then; remove traling comments $Line=StringMid($line,1,$wd-1) EndIf if StringInStr($line,'#include ')=1 Then; Remove Includes If StringLeft($line,1)='#' Then $line='?' EndIf Elseif $RemLines=1 AND StringLen(StringStripWS($Line,8))=0 Then; remove empty lines $line='?' Elseif $RemBlank=1 Then $line=StringStripWS($Line,7) EndIf if $RemTabs=1 Then; remove tab characters $line=StringReplace($Line,'','') EndIf If $line<>'?' then FileWriteLine($IDO,$Line) WEnd FileClose($IDI) FileClose($IDO) If $RemOpe=1 Then; remove blank characters around operators $IDI=FileOpen($file,0) $chars=FileRead($IDI) FileClose($IDI) $chars=StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(Strin gReplace(StringReplace($chars,'=','='),'+','+'),'-','-'),'>','>'),'<','<'),'*','*'),'<>','<>'),'&','&') $IDO=FileOpen($file,2) FileWrite($IDO,StringReplace(StringReplace(StringReplace(StringReplace(StringReplace($chars,'>=','>='),'<=','<='),',',','),'+=','+='),'-=','-=')) FileClose($IDI) EndIf If $DoCheck=1 Then $IDI=FileOpen($file,0) $chars=FileRead($IDI) FileClose($IDI) If StringInStr($chars,'Case $msg[1]=0x00000000')=0 Or StringInStr($chars,'Case $msg[1]=0')=0 then _say('no ticks catch function') If StringInStr($chars,' Call(')>0 then _say('ERROR-Posible trouble with user-defined function durring the "CALL" function') If StringInStr($chars,'PluginOpen(')>0 then _say('ERROR-Posible trouble with plugin as this feature is not preprocessed') EndIf CleanUp() EndFunc Func CheckTemporaryScriptForGlobalConstants() Dim $tmp=@ScriptDir&'\Temp\Constants.txt',$in=@ScriptDir&'\Temp\TmpScript.txt',$out=@ScriptDir&'\Temp\TmpConstants.txt',$lines[9999] $ID=FileOpen($tmp,0) $IDI=FileOpen($in,0) $chars=FileRead($IDI) $IDO=FileOpen($out,10) dim $a=1,$t='' While 1 $Line=FileReadLine($ID) If @error Then Exitloop $wd=_GetWord($Line,3) If StringLeft($wd,1)='$' Then $a+=1 $lines[$a]=$line If StringInStr($chars,$wd) Then FileWriteLine($IDO,$Line) GUICtrlCreateListViewItem($wd,$ConstC) $t=$t&$wd EndIf EndIf WEnd $lines[0]=$a FileClose($ID) FileClose($IDI) FileClose($IDO) $IDO=FileOpen($out,0) $tmpconst=FileRead($IDO) FileClose($IDO) $a=0 Do $a+=1 $wd=_GetWord($Lines[$a],3) If StringInStr($tmpconst,$wd)>0 AND StringInStr($t,$wd)=0 Then $tmpconst=$lines[$a]&@CRLF&$tmpconst $t=$t&$wd $a=0 GUICtrlCreateListViewItem($wd,$ConstC) EndIf Until $a=$lines[0] $IDO=FileOpen($out,2) FileWrite($IDO,$tmpconst) FileClose($IDO) EndFunc Func SampleMainAndSubFunctionsTemporary() Dim $tmp=@ScriptDir&'\Temp\TmpFunctions.txt',$out=@ScriptDir&'\Temp\TmpScript.txt' $IDI=FileOpen($tmp,0) $IDO=FileOpen($out,10) $Funcs=FileRead($IDI) FileWrite($IDO,$chars) FileWriteLine($IDO,@CRLF&$ch&'; Preprocessed included functions...'&@CRLF&$ch) FileWrite($IDO,$Funcs) FileClose($IDI) FileClose($IDO) EndFunc Func MakeDeepCheckForNewFunctions() $tmp=@ScriptDir&'\Temp\TmpFunctions.txt' If Fileexists($tmp) Then FileDelete($tmp) Do $tmpfunctionlist=_CountWords($UsedFunctionslist) GetMainScriptUsedFunctions($Filein) CheckForFuncInFunctions() Until _CountWords($UsedFunctionslist)=$tmpfunctionlist EndFunc Func CheckForFuncInFunctions() Dim $tmp=@ScriptDir&'\Temp\TmpFunctions.txt' $ID=FileOpen($tmp,0) While 1 $Line=FileReadLine($ID) If @error Then Exitloop $wd=StringInStr($Line,' _'); check for blank character before If $wd=0 Then $wd=StringInStr($Line,'_'); check for Tab character before ElseIf $wd=0 Then $wd=StringInStr($Line,'=_'); check for non blank character before EndIf If $wd>4 then $wd=_Getword(StringReplace(StringMid($line,$wd),'(',' '),1); get first word with change the ( character to blank character-then the function call is first word If StringInStr($UsedFunctionslist,$wd)=0 Then; check for dubblets in database and if not pressent include into temporary database and file-tmpfunctions.txt $UsedFunctionslist=$UsedFunctionslist&' '&$wd GUICtrlCreateListViewItem($wd,$FuncC) $IDO=FileOpen($tmp,9) $IDI=FileOpen(@ScriptDir&'\Temp\'&$wd&'.au3',0) $Funcs=FileRead($IDI) FileWrite($IDO,$Funcs) FileClose($IDI) FileClose($IDO) Endif EndIf WEnd FileClose($ID) EndFunc Func GetMainScriptUsedFunctions($File) Dim $tmp=@ScriptDir&'\Temp\TmpFunctions.txt' $ID=FileOpen($File,0) IF $ID=-1 THEN Return $chars=FileRead($ID) FileClose($ID) $NumOfFunctions=_CountWords($functionlist) For $a=1 To $NumOfFunctions $wd=_GetWord($functionlist,$a) If StringInStr($chars,$wd)>0 Then If StringInStr($UsedFunctionslist,$wd)=0 Then $UsedFunctionslist=$UsedFunctionslist&' '&$wd GUICtrlCreateListViewItem($wd,$FuncC) $IDI=FileOpen(@ScriptDir&'\Temp\'&$wd&'.au3',0) $IDO=FileOpen($tmp,9) $Funcs=FileRead($IDI) FileWrite($IDO,$Funcs) FileClose($IDI) FileClose($IDO) EndIf EndIf Next EndFunc Func MakeFuncAvailableList() Dim $NumIncludes=_CountWords($includelist),$sw=0 For $a=1 To $NumIncludes $wd=_GetWord($includelist,$a) $ID=FileOpen($Au3Path&'\Include\'&$wd,0) While 1 $Line=FileReadLine($ID) If @error Then Exitloop If StringLower(StringLeft($Line,5))='func ' Then $tmp=_Getword(StringReplace($Line,'(',' '),2) $IDO=FileOpen(@ScriptDir&'\Temp\'&$tmp&'.au3',10) FileWriteLine($IDO,$Line) $functionlist=$functionlist&' '&$tmp $sw=1 Elseif $sw=1 Then FileWriteLine($IDO,$Line) If StringLower(StringLeft($Line,7))='endfunc' Then $sw=1 FileClose($IDO) EndIf EndIf WEnd FileClose($ID) Next EndFunc Func GetIncludeList($File) If StringInStr($File,'.au3')=0 then Return; check for filetype $ID=FileOpen($File,0) IF $ID=-1 THEN Return GUICtrlSetData($LabelC,'Checking for include lines-Please wait...') For $a=1 To 50 $Line=FileReadLine($ID) If @error Then Exitloop $pos=StringInStr($line,'#include') If $pos>0 then If StringInStr(StringLeft($Line,$Pos),$cc)=0 AND StringInStr($line,'-once')=0 Then $tmp=StringReplace(StringReplace(StringReplace(StringReplace($line,"'",' '),'"',' '),'<',' '),'>',' ') $tmp=_Getword(StringMid($tmp,$Pos+9),1) If StringInStr($includelist,$tmp)=0 Then $includelist=$includelist&' '&$tmp EndIf EndIf EndIf Next FileClose($ID) GUICtrlSetData($LabelC,'Done...') Return EndFunc Func GetSubIncludes() dim $NumIncludes=_CountWords($includelist),$a=0,$wd,$tmp=@ScriptDir&'\Temp\Constants.txt' If Fileexists($tmp) Then FileDelete($tmp) Do; Get all used includes also in sub scripts $a+=1 $wd=_GetWord($includelist,$a) GetIncludeList($Au3Path&'\Include\'&$wd) $NumIncludes=_CountWords($includelist) GUICtrlCreateListViewItem($wd,$listC); display all in the listview _GUICtrlListViewSetCheckState($listC,$a-1,1); check them all $ID=FileOpen($Au3Path&'\Include\'&$wd,0) $IDO=FileOpen($tmp,9) While 1 $Line=FileReadLine($ID) If @error OR StringLower(StringLeft($Line,5))='func ' Then Exitloop If StringInStr($line,'Global ')>0 then FileWriteLine($IDO,$Line) EndIf WEnd FileClose($ID) FileClose($IDO) Until $a=$NumIncludes EndFunc Func MainWin() $Main=GuiCreate($title&' '&$Rev,620,305 ,$dm1[1],$dm1[2]) ;GUISetIcon(@ScriptDir&"\Data\Default.ico",'',$Main) $ListC=GUICtrlCreateListView('Checked Includes',0,0,150,280,-1,BitOr($LVS_EX_CHECKBOXES,$LVS_EX_GRIDLINES)) $FuncC=GUICtrlCreateListView('Builin Functions',150,0,150,280,-1,$LVS_EX_GRIDLINES) $ConstC=GUICtrlCreateListView('Included Global Constants',300,0,150,280,-1,$LVS_EX_GRIDLINES) GUICtrlCreateGroup('Special PreProcess Actions',460,5,152,178) $RemCommBC=GUICtrlCreateCheckbox('Remove comment blocks',467,20,-1,-1) $RemCommTC=GUICtrlCreateCheckbox('Remove trail comments',467,40,-1,-1) $RemBlankC=GUICtrlCreateCheckbox('Remove multi blank chars',467,60,-1,-1) $RemTabsC=GUICtrlCreateCheckbox('Remove Tab chars',467,80,-1,-1) $RemLinesC=GUICtrlCreateCheckbox('Remove empty Lines',467,100,-1,-1) $RemOpeC=GUICtrlCreateCheckbox('Remove around operators',467,120,-1,-1) $DoCompC=GUICtrlCreateCheckbox('Auto Compile',467,160,-1,-1) $LabelC=GUICtrlCreateInput('',0,284,620,20) GUICtrlCreateGroup('MakeFile',460,185,72,94) $WriteC=GUICtrlCreateButton('Write',465,205,60,20) $ReloadC=GUICtrlCreateButton('ReLoad',465,230,60,20) $RemoveC=GUICtrlCreateButton('Remove',465,255,60,20) GUICtrlCreateGroup('Action',540,185,72,94) $PreproC=GUICtrlCreateButton('Process',545,205,60,20) $DoTestC=GUICtrlCreateButton('Run test',545,230,60,20) $CompileC=GUICtrlCreateButton('Compile',545,255,60,20) GUICtrlSendMsg($listC,0x101E,0,146) GUICtrlSendMsg($ConstC,0x101E,0,146) GUICtrlSendMsg($FuncC,0x101E,0,146) GUICtrlSendMsg($ListC,0x14,0,2) If $RemCommB=1 Then GuiCtrlSetState($RemCommBC,$GUI_CHECKED) If $RemCommT=1 Then GuiCtrlSetState($RemCommTC,$GUI_CHECKED) If $RemBlank=1 Then GuiCtrlSetState($RemBlankC,$GUI_CHECKED) If $RemTabs=1 Then GuiCtrlSetState($RemTabsC,$GUI_CHECKED) If $RemLines=1 Then GuiCtrlSetState($RemLinesC,$GUI_CHECKED) If $RemOpe=1 Then GuiCtrlSetState($RemOpeC,$GUI_CHECKED) If $DoComp=1 Then GuiCtrlSetState($DoCompC ,$GUI_CHECKED) If $DoCheck=1 Then GuiCtrlSetState($DoCheckC ,$GUI_CHECKED) GuiSetState() TraySetIcon(@ScriptDir&"\Data\Default.ico",0) TraySetToolTip('Au3PreProcess 1.8-The AutoIt3 script PreProcessor') EndFunc Func ReadPrefs($Prefs) $var=RegRead($Prefs,"1") If @error Then $var='182 234';Main: x y $dm1=StringSplit($var," ") $RemCommB=RegRead($Prefs,'RemCommB') If @error Then $RemCommB='4' $RemCommT=RegRead($Prefs,'RemCommT') If @error Then $RemCommT='4' $RemBlank=RegRead($Prefs,'RemBlank') If @error Then $RemBlank='4' $RemTabs=RegRead($Prefs,'RemTabs') If @error Then $RemTabs='4' $RemLines=RegRead($Prefs,'RemLines') If @error Then $RemLines='4' $RemOpe=RegRead($Prefs,'RemOperators') If @error Then $RemOpe='4' $RemPre=RegRead($Prefs,'RemPreprocess') If @error Then $RemPre='4' $DoComp=RegRead($Prefs,'DoCompile') If @error Then $DoComp='4' $DoCheck=RegRead($Prefs,'CheckSpecial') If @error Then $DoCheck='4' $inpath=RegRead($Prefs,'InFilePath') If @error then $inpath=$Au3Path EndFunc Func WritePrefs($Prefs) $tmp=WinGetPos($Main) If $tmp[0]>0 Then RegWrite($Prefs,'1','REG_SZ',$tmp[0]&' '&$tmp[1]) If @error Then MsgBox(48,"ERROR...","Save preferences failed") RegWrite($Prefs,'RemCommB','REG_SZ',$RemCommB) RegWrite($Prefs,'RemCommT','REG_SZ',$RemCommT) RegWrite($Prefs,'RemBlank','REG_SZ',$RemBlank) RegWrite($Prefs,'RemTabs','REG_SZ',$RemTabs) RegWrite($Prefs,'RemLines','REG_SZ',$RemLines) RegWrite($Prefs,'RemOperators','REG_SZ',$RemOpe) RegWrite($Prefs,'CheckSpecial','REG_SZ',$DoCheck) RegWrite($Prefs,'DoCompile','REG_SZ',$DoComp) RegWrite($Prefs,'InFilePath','REG_SZ',$inpath) EndIf EndFunc Func Exits() WritePrefs($Prefs) CleanUp() Exit EndFunc Func CleanUp() local $d=@ScriptDir&'\Temp' If FileExists($d) Then IF DirRemove($d,1) Then GUICtrlSetData($LabelC,'Temporary files removed and Preprocessed file created...') Else GUICtrlSetData($LabelC,'ERROR-Failed to remove temporary files but the preprocessed file created...') EndIf EndIf EndFunc Func FileLoad($mess,$Path,$suff) $var=FileOpenDialog($mess,$Path,$Suff,5) If @error Then Return '' Return StringReplace($var,"|",@CRLF) EndFunc Func _GUICtrlListViewSetCheckState($h_listview,$i_index,$i_check=1) Local $struct="int;int;int;int;int;ptr;int;int;int;int;int;ptr",$ret Local $p=DllStructCreate($struct) If @error Then Return SetError($LV_ERR,$LV_ERR,$LV_ERR) DllStructSetData($p,1,$LVIF_STATE) DllStructSetData($p,2,$i_index) If ($i_check) Then DllStructSetData($p,4,0x2000) Else DllStructSetData($p,4,0x1000) EndIf DllStructSetData($p,5,$LVIS_STATEIMAGEMASK) If IsHWnd($h_listview) Then Local $pIndex=DllStructGetPtr($p) Local $iSize=DllStructGetSize($p) Local $rMemMap Local $pMemory=_MemInit ($h_listview,$iSize+4096,$rMemMap) If @error Then Return SetError($LV_ERR,$LV_ERR,$LV_ERR) _MemWrite ($rMemMap,$pIndex) If @error Then Return SetError($LV_ERR,$LV_ERR,$LV_ERR) $ret=_SendMessage ($h_listview,$LVM_SETITEMSTATE,$i_index,$pMemory) If @error Then Return SetError($LV_ERR,$LV_ERR,$LV_ERR) _MemFree ($rMemMap) If @error Then Return SetError($LV_ERR,$LV_ERR,$LV_ERR) Else $ret=GUICtrlSendMsg($h_listview,$LVM_SETITEMSTATE,$i_index,DllStructGetPtr($p)) EndIf Return $ret EndFunc;==>_GUICtrlListViewSetCheckState Func _GetWord($st,$no) If NOT IsString($st) OR NOT IsInt($no) OR $no<1 Then SetError(1) Return '' EndIf $st=StringReplace(StringReplace(StringReplace($st,'',' '),' ',' '),' ',' ') $len=StringLen($st) FOR $a=1 TO $len $b=StringMid($st,$a,1) If $b<>' ' Then Exitloop Next $st=StringMid($st,$a) $st=StringSplit($st,' ') If $no>$st[0] Then return '' Return $st[$no] EndFunc Func _CountWords($st) If NOT IsString($st) Then SetError(1) Return '' EndIf $st=StringReplace(StringReplace(StringReplace($st,'',' '),' ',' '),' ',' ') $len=StringLen($st) FOR $a=1 TO $len $b=StringMid($st,$a,1) If $b<>' ' Then Exitloop Next For $b=$len TO 1 Step -1 $c=StringMid($st,$b,1) If $c<>' ' Then Exitloop Next $st=StringSplit(StringMid($st,$a,$b-$a+1),' ') Return $st[0] EndFunc Func _Say($st) ConsoleWrite($st&@CR) EndFunc Func _MemInit($hWnd,$iSize,ByRef $rMemMap,$pAddress=0) Local $iAccess,$iAllocation Local $pMemory,$hProcess Local $iProcessID _GetWindowThreadProcessId($hWnd,$iProcessID) $iAccess=BitOR($PROCESS_VM_OPERATION,$PROCESS_VM_READ,$PROCESS_VM_WRITE) $hProcess=_OpenProcess($iAccess,False,$iProcessID) Switch @OSVersion Case "WIN_ME","WIN_98","WIN_95" $iAllocation=BitOR($MEM_RESERVE,$MEM_COMMIT,$MEM_SHARED) $pMemory=_VirtualAlloc($pAddress,$iSize,$iAllocation,$PAGE_READWRITE) Case Else $iAllocation=BitOR($MEM_RESERVE,$MEM_COMMIT) $pMemory=_VirtualAllocEx($hProcess,$pAddress,$iSize,$iAllocation,$PAGE_READWRITE) EndSwitch If @error Then Return SetError(-1,-1,0) $rMemMap=DllStructCreate($MEM_MAP) DllStructSetData($rMemMap,$MEM_MAP_HPROC,$hProcess) DllStructSetData($rMemMap,$MEM_MAP_ISIZE,$iSize) DllStructSetData($rMemMap,$MEM_MAP_PMEM,$pMemory) Return $pMemory EndFunc;==>_MemInit Func _SendMessage($h_hWnd,$i_msg,$wParam=0,$lParam=0,$i_r=0,$s_t1="int",$s_t2="int") Local $a_ret=DllCall("user32.dll","long","SendMessage","hwnd",$h_hWnd,"int",$i_msg,$s_t1,$wParam,$s_t2,$lParam) If @error Then Return SetError(@error,@extended,"") If $i_r>=0 And $i_r<=4 Then Return $a_ret[$i_r] Return $a_ret EndFunc;==>_SendMessage Func _GetWindowThreadProcessId($hWnd,ByRef $iProcessID) Local $rProcessID,$aResult $rProcessID=DllStructCreate("int") $aResult=DllCall("User32.dll","int","GetWindowThreadProcessId","hwnd",$hWnd,"ptr",DllStructGetPtr($rProcessID)) If @error Or Not IsArray($aResult) Then Return SetError(-1,-1,0) $iProcessID=DllStructGetData($rProcessID,1) Return $aResult[0] EndFunc;==>_GetWindowThreadProcessId Func _OpenProcess($iAccess,$bInherit,$iProcessID) Local $aResult=DllCall("Kernel32.Dll","int","OpenProcess","int",$iAccess,"int",$bInherit,"int",$iProcessID) If @error Or Not IsArray($aResult) Then Return SetError(-1,-1,0) Return $aResult[0] EndFunc;==>_OpenProcess Func _VirtualAlloc($pAddress,$iSize,$iAllocation,$iProtect) Local $aResult=DllCall("Kernel32.dll","ptr","VirtualAlloc","ptr",$pAddress,"int",$iSize,"int",$iAllocation,"int",$iProtect) If @error Or Not IsArray($aResult) Then Return SetError(-1,-1,0) Return $aResult[0] EndFunc;==>_VirtualAlloc Func _VirtualAllocEx($hProcess,$pAddress,$iSize,$iAllocation,$iProtect) Local $aResult=DllCall("Kernel32.dll","ptr","VirtualAllocEx","int",$hProcess,"ptr",$pAddress,"int",$iSize,"int",$iAllocation,"int",$iProtect) If @error Or Not IsArray($aResult) Then Return SetError(-1,-1,0) Return $aResult[0] EndFunc;==>_VirtualAllocEx Happy new year kjactive
    1 point
×
×
  • Create New...