
Foxnolds
Members-
Posts
12 -
Joined
-
Last visited
About Foxnolds
- Birthday September 5
Profile Information
-
Location
Sydney, Australia
-
WWW
http://www.ewise.com
Foxnolds's Achievements

Seeker (1/7)
0
Reputation
-
No problem. I've edited the first post and included a check for user defined button text length. I used 2 characters for between button space padding. Just a guess... Let be know if it helps. If not, please give a sample of the button text that is giving you a problem and I will look into it.
-
Ah ha, another Aussie burning the Midnight Oil! Thanks for the feedback Mhz and rbhkamal. I forgot to mention that I only write for the latest Beta Version. I am new to Autoit and I found version 3.1.1.0 too limiting. For my needs, it was not worth investing any time in it at all. I don't know why the old 3.1.1.0 is still around? Version 2 is the legacy version...
-
Here is my MsgBoxEx UDF: OK, you all use that last parameter in MsgBox to auto select the defualt button in "x" number of seconds... BUT how do you see how many seconds you have left before you need to panic?? Well use this UDF instead! Not only does it count down the seconds remaining in the Default button text but it will ALSO change the wording in the dialog text as well via a token string substitution. But there's more... Wouldn't it be nice to BOLD a few lines to help get the message text across... Wouldn't it be nice to be able to PARENT the Dialog back to your main Autoit window so if it closes, the dialog also closes... Wouldn't it be nice if the dialog was modeless or modal allowing events in your main Autoit window to happen and process while the Dialog is displayed... Here is a STILL snapshot of my MsgBoxEx in action. The MsgBoxEx UDF and a simple Test example. v1.01 MsgBoxEx.zip The Extentsion to the normal old MsgBox is that it:- Will add Count-down text to the default button that counts down... Will replace the characters <##> with the current remaining number of seconds on up to 5 lines of textWill BOLD a while line of text if <b> or </B> tags are seen on any message line.Accepts optional Parent window parameter so when parent minimises, closes then so does MsgBoxEx dialog.Supports Minimize and Close SysMenu buttonsWorks as a drop-in Modal like replacement for MsgBox() but can also work modeless in your own EventLoop environment. Button action generate Callbacks to your event handler.The 1 to 3 buttons can be of ANY text by an optional Array of button text and button count values.Special Return Codes for Type 8 buttons - PC Lock/Cancel.P.S. The best Parent Window examples of MsgBoxEx use is on the About Dialog Test Button actions in my UnAttended Script .. Edited 15 August 2006: Added Button Text length check for User Defined Buttons Text. The UDF: (I use Tabs) ; Include Version:1.01 (15 August 2006) #include-once ; ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.1.1.133+ ; Language: English ; Description: Alternative to MsgBox() with extended functionality. ; ; ------------------------------------------------------------------------------ Global $ghMBEX = 0, $giMBEX_Secs = 0, $gaMBEX_SecLines[6][2], $gsMBEX_Text, $giMBEX_PrevOnEventMode Global $ghMBEX_Button1, $ghMBEX_Button2, $ghMBEX_Button3, $ghMBEX_Button, $giMBEX_ButtonFlag Global $gsMBEX_ButtonText, $gsMBEX_CallBack, $giMBEX_RtnVal, $gaMBEX_BT[4], $gbMBEX_ButtonHasCD Global $giMBEX_TmrStart, $giMBEX_TmrEnd ; #include <GUIDefaultConstants.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> ; ; ;=============================================================================== ; ; Function Name: _MsgBoxEx() and _MsgBoxExCreate() ; Description: Extensions to the inbuilt MsgBox() Function. ; Adds a drop in replacement or Event driven Mode ; Adds CountDown of Timeout to Default Buttons and|or Text. ; Adds Bolding of up to 5 text lines ; Author(s): Foxnolds <foxnolds at ewise dot com> ; ;=============================================================================== ;=============================================================================== ; +++ This is to emulate a Modal MsgBox($iFlag, $sTitle, $sText [, $iTimeout]) +++ ; _MsgBoxEx($iFlag, $sTitle, $sText [, $iTimeout [, $sReturnCallBack [, $iLeft [, $iTop [, $hParent]]]]]) ; ; +++ This is the call to use if you have your own EventLoop where you call _MBEX_TickTock() +++ ; _MsgBoxExCreate($iFlag, $sTitle, $sText [, $iTimeout [, $sReturnCallBack [, $iLeft [, $iTop [, $hParent]]]]]) ; __________________________________________________________________________________________________________________ ; $iFlag The flag indicates the type of message box and the possible button combinations. See remarks. ; $sTitle The title of the message box. ; $sText The text of the message box. "<b>" and/or "</b>" will Bold Text of whole Line only. ; Upto 5 lines may have <##> text replaced with the current second countdown value. ; $iTimeout [optional] Timeout in seconds. After the timeout has elapsed the message box will be closed. ; Default value of 0 will disable timeout. ; $sReturnCallBack [optional] The name of a function you provide that takes a single argument, the ReturnCode. ; Default value is Null String "" which is replaced with internal handler when ; _MsgBoxEx() funcion called. ; If using _MsgBoxExCreate(), ; you MUST register your own ReturnCallBack function here... ; And in your Event Loop, you need to call _MBEX_TickTock() to update timers. ; $iLeft [optional] X Position of Dialog, default of -1 centers dialog horizontally. ; $iTop [optional] Y Position of Dialog, default of -1 centers dialog vertically. ; $hParent [optional] Handle to a Parent Window, defaults to 0. ; __________________________________________________________________________________________________________________ ; ; Note, as this is Modeless, this version does not support multiple instances which can be invoked. ; The code uses the Dialog handle of non-zero to test if another is running already. ; ; Failure: Returns -1 if the message box timed out. ; ; Button Pressed Return Value sent to $gsMBEX_CallBack function you provide ; OK 1 ; CANCEL 2 ; ABORT 3 ; RETRY 4 ; IGNORE 5 ; YES 6 ; NO 7 ; TRY AGAIN ** 10 ; CONTINUE ** 11 ; LOCK PC 12 - You have to do the locking... ; CLOSE 13 - New Return code ; _____________________________________________________________________ ; ; The flag parameter can be a combination of the following values: ; ; decimal flag Button-related Result hexadecimal flag ; 0 OK button 0x0 ; 1 OK and Cancel 0x1 ; 2 Abort, Retry, and Ignore 0x2 ; 3 Yes, No, and Cancel 0x3 ; 4 Yes and No 0x4 ; 5 Retry and Cancel 0x5 ; 6 ** Cancel, Try Again, Continue 0x6 ; 7 ++ +++ See Note7 +++ 0x7 ; 8 ++ Lock PC, Cancel 0x8 ; ; +++ Note7 +++ User sets the Global Array Variables Before Calling this Function ; $gaMBEX_BT[0] = 1, 2 or 3 ; $gaMBEX_BT[1] = "Left Button" ; $gaMBEX_BT[2] = "Right Button" ; $gaMBEX_BT[3] = "Middle Button" ; _____________________________________________________________________ ; decimal flag Icon-related Result hexadecimal flag ; 0 (No icon) 0x0 ; 16 Stop-sign icon 0x10 ; 32 Question-mark icon 0x20 ; 48 Exclamation-point icon 0x30 ; 64 Information-sign icon consisting of an 'i' in a circle 0x40 ; _____________________________________________________________________ ; decimal flag Default-related Result hexadecimal flag ; 0 First button is default button 0x0 ; 256 Second button is default button 0x100 ; 512 Third button is default button 0x200 ; 1024 +++ Default Button has CountDown text 0x400 ; _____________________________________________________________________ ; decimal flag Modality-related Result hexadecimal flag ; 0 Application 0x0 ; 4096 ++ System modal (dialog has an icon) 0x1000 ; 8192 -- Task modal - Not supported 0x2000 ; _____________________________________________________________________ ; decimal flag Miscellaneous-related Result hexadecimal flag ; 0 (nothing else special) 0x0 ; 262144 MsgBox has top-most attribute set 0x40000 ; 524288 -- title and text are right-justified 0x80000 ; ; ** was Only valid on Windows 2000/XP and above. ; ________________________________________________________________ ; ;=============================================================================== ; +++ This is to emulate a Modal MsgBox($iFlag, $sTitle, $sText [, $iTimeout]) +++ ; _MsgBoxEx($iFlag, $sTitle, $sText [, $iTimeout [, $sReturnCallBack [, $iLeft [, $iTop [, $hParent]]]]]) ; ; Function Entry for backwards compatability for MsgBox() is really a ; Local EventLoop to service this _MsgBoxEx UDF. ; Usually you would use your own EventLoop but this will do if none other. ;=============================================================================== Func _MsgBoxEx($piFlag, $psTitle, $psText, $piTimeout = 0, $psReturnCallBack = "", $piLeft = -1, $piTop = -1, $phParent = 0) _MsgBoxExCreate($piFlag, $psTitle, $psText, $piTimeout, $psReturnCallBack, $piLeft, $piTop, $phParent) ; Local Event Loop for Timer CountDown Tick While $giMBEX_RtnVal == 0 Sleep(250) ; Allow events to happen... _MBEX_TickTock(True) ; Do CountDown display as required WEnd ; Restore Previous OnEventMode Opt("GUIOnEventMode", $giMBEX_PrevOnEventMode) ; 0=disabled, 1=OnEvent mode enabled Return $giMBEX_RtnVal EndFunc ;=============================================================================== ; +++ This is the call to use if you have your own EventLoop where you call _MBEX_TickTock() +++ ; _MsgBoxExCreate($iFlag, $sTitle, $sText [, $iTimeout [, $sReturnCallBack [, $iLeft [, $iTop [, $hParent]]]]]) ;=============================================================================== Func _MsgBoxExCreate($piFlag, $psTitle, $psText, $piTimeout = 0, $psReturnCallBack = "", $piLeft = -1, $piTop = -1, $phParent = 0) Local $liPrevCoordMode, $laText, $li, $liMaxStrLen = 0, $liTextWidth, $lsValue, $liStyle, $liStyleEx, $lbTabs Local $liIconOffset, $liIconIndex, $liXpos, $lbBold, $liButtonWidth, $liBoldVOffset = 0, $liHeight, $lbButton1Centered Local $liNumOfButtons, $lsButton1Text, $lsButton2Text, $lsButton3Text, $liDefButtonNum, $liLeftGrow, $liRightGrow Local Const $lciCharWidth = 5, $lciBtnCharWidth = 7, $lciButtonWidth = 70, $lciBoldWidth = 7 Local Const $lciCharHeight = 15, $lciLineHeight = 12, $lciButtonHeight = 25, $lciBoldHeight = 16 If $ghMBEX Then Return 0 ; Already displayed! If $psReturnCallBack == "" Then $psReturnCallBack = "_MBEX_DefaultReturnCallBack" ; No CallBack provided - Mandatory! $gsMBEX_CallBack = $psReturnCallBack $liPrevCoordMode = Opt("GUICoordMode", 1) ; 1 = absolute coordinates (default) still relative to the dialog box. ; 0 = relative position to the start of the last control (upper left corner). ; 2 = cell positionining relative to current cell. ; A -1 for left or top parameter don't increment the start. ; So next line is -1,offset; next cell is offset,-1; current cell is -1,-1. $giMBEX_PrevOnEventMode = Opt("GUIOnEventMode", 1) ; 0=disabled, 1=OnEvent mode enabled $gaMBEX_SecLines[0][0] = 0 ; Initialse Counter of Lines needing SECONDS update <##> to Zero $gaMBEX_SecLines[0][1] = "" $giMBEX_Secs = $piTimeout $gsMBEX_Text = " (<##> secs)" $laText = StringSplit($psText, @LF, 1) $liMaxStrLen = 0 For $li = 1 To $laText[0] $lbBold = False $lbTabs = False $liTextWidth = StringLen($laText[$li]) If StringInStr($laText[$li], "<b>", 0, 1) > 0 OR StringInStr($laText[$li], "</b>", 0, 1) > 0 Then $lbBold = True If StringInStr($laText[$li], @TAB, 0, 1) > 0 Then ; Expand TAB characters.. to 4-Char boundary $lbTabs = True Local $liLen = 0, $c = "" For $liIconOffset = 1 to $liTextWidth $c = StringMid($laText[$li], $liIconOffset, 1) If $c == @TAB Then If Mod($liLen, 4) == 0 Then $liLen += 4 Else $liLen += Mod($liLen, 4) EndIf Else $liLen += 1 EndIf Next $liTextWidth = $liLen EndIf If $lbBold Then $liTextWidth = $liTextWidth * $lciBoldWidth $liBoldVOffset = $liBoldVOffset + $lciBoldHeight - $lciLineHeight ElseIf $lbTabs Then $liTextWidth = $liTextWidth * $lciBoldWidth Else $liTextWidth = $liTextWidth * $lciCharWidth EndIf If $liTextWidth > $liMaxStrLen Then $liMaxStrLen = $liTextWidth Next $liTextWidth = 250 If $liMaxStrLen > $liTextWidth Then $liTextWidth = $liMaxStrLen ; Set up Button info $lbButton1Centered = False Select Case BitAND($piFlag, 8) == 8 ; Lock PC, Cancel $liNumOfButtons = 2 $lsButton1Text = "Lock PC" $lsButton2Text = "Cancel" $lsButton3Text = "" $giMBEX_ButtonFlag = 8 Case BitAND($piFlag, 7) == 7 ; User Defined ; User sets the Global Variables Before Calling this Function $liNumOfButtons = $gaMBEX_BT[0] ; 1, 2 or 3 $lsButton1Text = $gaMBEX_BT[1] ; "Left Button" $lsButton2Text = $gaMBEX_BT[2] ; "Right Button" $lsButton3Text = $gaMBEX_BT[3] ; "Middle Button" $giMBEX_ButtonFlag = 7 If $liNumOfButtons == 1 Then $lbButton1Centered = True Case BitAND($piFlag, 6) == 6 ; Cancel, Try Again, Continue $liNumOfButtons = 3 $lsButton1Text = "Cancel" $lsButton2Text = "Continue" $lsButton3Text = "Try Again" $giMBEX_ButtonFlag = 6 Case BitAND($piFlag, 5) == 5 ; Retry and Cancel $liNumOfButtons = 2 $lsButton1Text = "Retry" $lsButton2Text = "Cancel" $lsButton3Text = "" $giMBEX_ButtonFlag = 5 Case BitAND($piFlag, 4) == 4 ; Yes and No $liNumOfButtons = 2 $lsButton1Text = "Yes" $lsButton2Text = "No" $lsButton3Text = "" $giMBEX_ButtonFlag = 4 Case BitAND($piFlag, 3) == 3 ; Yes, No, and Cancel $liNumOfButtons = 3 $lsButton1Text = "Yes" $lsButton2Text = "Cancel" $lsButton3Text = "No" $giMBEX_ButtonFlag = 3 Case BitAND($piFlag, 2) == 2 ; Abort, Retry, and Ignore $liNumOfButtons = 3 $lsButton1Text = "Abort" $lsButton2Text = "Ignore" $lsButton3Text = "Retry" $giMBEX_ButtonFlag = 2 Case BitAND($piFlag, 1) == 1 ; OK and Cancel $liNumOfButtons = 2 $lsButton1Text = "OK" $lsButton2Text = "Cancel" $lsButton3Text = "" $giMBEX_ButtonFlag = 1 Case Else ; OK button $liNumOfButtons = 1 $lsButton1Text = "OK" $lsButton2Text = "" $lsButton3Text = "" $lbButton1Centered = True $giMBEX_ButtonFlag = 0 EndSelect ; Select default Button to Count Down $liDefButtonNum = 1 ; First button is default button $gsMBEX_ButtonText = $lsButton1Text If BitAND($piFlag, 256) == 256 Then ; Second button is default button If $liNumOfButtons == 2 Then $liDefButtonNum = 2 ; Second of 2 $gsMBEX_ButtonText = $lsButton2Text ElseIf $liNumOfButtons == 3 Then $liDefButtonNum = 3 ; The Middle button $gsMBEX_ButtonText = $lsButton3Text Else $liDefButtonNum = 1 ; First button is default button $gsMBEX_ButtonText = $lsButton1Text EndIf ElseIf BitAND($piFlag, 512) == 512 Then ; Third button is default button If $liNumOfButtons == 3 Then $liDefButtonNum = 2 ; Button 2 is always the RHS one. $gsMBEX_ButtonText = $lsButton2Text ElseIf $liNumOfButtons == 2 Then $liDefButtonNum = 2 ; Button 2 is always the RHS one. $gsMBEX_ButtonText = $lsButton2Text ElseIf $liNumOfButtons == 1 Then $liDefButtonNum = 1 ; Button 1 is the only one. $gsMBEX_ButtonText = $lsButton1Text EndIf EndIf ; Look for CoutDown text on Default Button request $gbMBEX_ButtonHasCD = False If BitAND($piFlag, 1024) == 1024 Then $gbMBEX_ButtonHasCD = True ; Look for Icon Index $liIconOffset = 10 $liIconIndex = 0 If BitAND($piFlag, 48) == 48 Then $liIconIndex = 1 ; 48x48 WinXP Icon - 48 - Exclamation $liIconOffset = 60 ElseIf BitAND($piFlag, 16) == 16 Then $liIconIndex = 3 ; 48x48 WinXP Icon - 16 - Stop Sign $liIconOffset = 60 ElseIf BitAND($piFlag, 32) == 32 Then $liIconIndex = 2 ; 48x48 WinXP Icon - 32 - Ques Mark $liIconOffset = 60 ElseIf BitAND($piFlag, 64) == 64 Then $liIconIndex = 4 ; 48x48 WinXP Icon - 64 - Information $liIconOffset = 60 EndIf ; Test for enough room for 3 standard Buttons If $liNumOfButtons == 3 And $gbMBEX_ButtonHasCD AND ($liTextWidth + $liIconOffset) < 290 Then $liTextWidth = 290 - $liIconOffset EndIf ; redo width calculation incase User Defined Button text is large? If $giMBEX_ButtonFlag == 7 Then $liMaxStrLen = StringLen($lsButton1Text) + StringLen($gsMBEX_Text) + 2 If $liNumOfButtons > 1 Then $liMaxStrLen += StringLen($lsButton2Text) + 2 If $liNumOfButtons > 2 Then $liMaxStrLen += StringLen($lsButton3Text) + 2 $liMaxStrLen = ($liMaxStrLen * $lciBtnCharWidth) - $liIconOffset ; buttons can use Icon horizontal space If $liMaxStrLen > $liTextWidth Then $liTextWidth = $liMaxStrLen EndIf ; Get Topmost flag $liStyleEx = -1 If BitAND($piFlag, 262144) == 262144 Then $liStyleEx = $WS_EX_TOPMOST $liStyle = BitOr($WS_CAPTION, $WS_POPUP) If BitAND($piFlag, 4096) == 4096 Then $liStyle = BitOr($WS_CAPTION, $WS_POPUP, $WS_MINIMIZEBOX, $WS_SYSMENU) ; System Modal has Icon.. If BitAND($piFlag, 524288) == 524288 Then $liStyle = BitOr($liStyle, $SS_RIGHT) If $phParent == 0 Then $ghMBEX = GuiCreate($psTitle, $liTextWidth + $liIconOffset + 10, 55 + ($laText[0] * $lciLineHeight) + $liBoldVOffset, $piLeft, $piTop, $liStyle, $liStyleEx) Else $ghMBEX = GuiCreate($psTitle, $liTextWidth + $liIconOffset + 10, 55 + ($laText[0] * $lciLineHeight) + $liBoldVOffset, $piLeft, $piTop, $liStyle, $liStyleEx, $phParent) EndIf If @Compiled Then GUISetIcon(@AutoItExe, 0) GUISetOnEvent($GUI_EVENT_CLOSE, "_MBEX_SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "_MBEX_SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "_MBEX_SpecialEvents") If $liIconIndex > 0 Then GUICtrlCreateIcon("user32.dll", $liIconIndex, 10, 10) $liBoldVOffset = 0 For $li = 1 To $laText[0] $lbBold = False $lsValue = StringStripCR($laText[$li]) If StringInStr($lsValue, "<b>", 0, 1) > 0 Then $lbBold = True $lsValue = StringReplace($lsValue, "<b>", "", 0, 0) EndIf If StringInStr($lsValue, "</b>", 0, 1) > 0 Then $lbBold = True $lsValue = StringReplace($lsValue, "</b>", "", 0, 0) EndIf $liHeight = $lciCharHeight If $lbBold Then $liHeight = $lciBoldHeight $liStyle = -1 If BitAND($piFlag, 524288) == 524288 Then $liStyle = BitOr($liStyle, $SS_RIGHT) If StringInStr($lsValue, "<##>", 0, 1) > 0 And $gaMBEX_SecLines[0][0] < 5 Then ; Update Counter of Lines needing SECONDS update <##> $gaMBEX_SecLines[0][0] = $gaMBEX_SecLines[0][0] + 1 $gaMBEX_SecLines[$gaMBEX_SecLines[0][0]][1] = $lsValue $lsValue = StringReplace($lsValue, "<##>", $giMBEX_Secs, 0, 0) $gaMBEX_SecLines[$gaMBEX_SecLines[0][0]][0] = GUICtrlCreateLabel($lsValue, $liIconOffset, ((($li-1) * $lciLineHeight) + 10 + $liBoldVOffset), $liTextWidth, $liHeight, $liStyle) Else GUICtrlCreateLabel($lsValue, $liIconOffset, ((($li-1) * $lciLineHeight) + 10 + $liBoldVOffset), $liTextWidth, $liHeight, $liStyle) EndIf If $lbBold Then GUICtrlSetFont(-1, 11, 800) $liBoldVOffset = $liBoldVOffset + $lciBoldHeight - $lciLineHeight EndIf Next ; Set Button1 Text $lsValue = $lsButton1Text If $giMBEX_Secs > 0 AND $liDefButtonNum == 1 AND $gbMBEX_ButtonHasCD Then $lsValue = StringReplace($gsMBEX_ButtonText & $gsMBEX_Text, "<##>", $giMBEX_Secs, 0, 0) EndIf ; Get Button Width $liButtonWidth = StringLen($lsValue) * $lciBtnCharWidth If $liButtonWidth < $lciButtonWidth Then $liButtonWidth = $lciButtonWidth $liLeftGrow = $liButtonWidth - $lciButtonWidth ; Set Button1 Position If $lbButton1Centered Then $liXpos = Int(($liTextWidth + $liIconOffset + 10) / 2) - Int($liButtonWidth / 2) ; Centered Else $liXpos = 10 ; $liIconOffset EndIf ; Set Defult Button action If $liDefButtonNum == 1 Then $liStyle = $BS_DEFPUSHBUTTON Else $liStyle = -1 EndIf $ghMBEX_Button1 = GUICtrlCreateButton($lsValue, $liXpos, ($laText[0] * $lciLineHeight) + 25 + $liBoldVOffset, $liButtonWidth, $lciButtonHeight, $liStyle) GUICtrlSetOnEvent(-1, "_MBEX_Button1_Pressed") If $liDefButtonNum == 1 Then $ghMBEX_Button = $ghMBEX_Button1 If $liNumOfButtons > 1 Then ; Set Button2 Text $lsValue = $lsButton2Text If $giMBEX_Secs > 0 AND $liDefButtonNum == 2 AND $gbMBEX_ButtonHasCD Then $lsValue = StringReplace($gsMBEX_ButtonText & $gsMBEX_Text, "<##>", $giMBEX_Secs, 0, 0) EndIf ; Get Button Width $liButtonWidth = StringLen($lsValue) * $lciBtnCharWidth If $liButtonWidth < $lciButtonWidth Then $liButtonWidth = $lciButtonWidth $liRightGrow = $liButtonWidth - $lciButtonWidth ; Set Defult Button action If $liDefButtonNum == 2 Then $liStyle = $BS_DEFPUSHBUTTON Else $liStyle = -1 EndIf $ghMBEX_Button2 = GUICtrlCreateButton($lsValue, $liTextWidth + $liIconOffset - $liButtonWidth, ($laText[0] * $lciLineHeight) + 25 + $liBoldVOffset, $liButtonWidth, $lciButtonHeight, $liStyle) GUICtrlSetOnEvent(-1, "_MBEX_Button2_Pressed") If $liDefButtonNum == 2 Then $ghMBEX_Button = $ghMBEX_Button2 EndIf If $liNumOfButtons > 2 Then ; Set Button3 Text $lsValue = $lsButton3Text If $giMBEX_Secs > 0 AND $liDefButtonNum == 3 AND $gbMBEX_ButtonHasCD Then $lsValue = StringReplace($gsMBEX_ButtonText & $gsMBEX_Text, "<##>", $giMBEX_Secs, 0, 0) EndIf ; Get Button Width $liButtonWidth = StringLen($lsValue) * $lciBtnCharWidth If $liButtonWidth < $lciButtonWidth Then $liButtonWidth = $lciButtonWidth ; Set Defult Button action If $liDefButtonNum == 3 Then $liStyle = $BS_DEFPUSHBUTTON Else $liStyle = -1 EndIf $liXpos = Int(($liTextWidth + $liIconOffset + 10) / 2) - Int($liButtonWidth / 2) + Int($liLeftGrow / 2) - Int($liRightGrow / 2) ; Centered $ghMBEX_Button3 = GUICtrlCreateButton($lsValue, $liXpos, ($laText[0] * $lciLineHeight) + 25 + $liBoldVOffset, $liButtonWidth, $lciButtonHeight, $liStyle) GUICtrlSetOnEvent(-1, "_MBEX_Button3_Pressed") If $liDefButtonNum == 3 Then $ghMBEX_Button = $ghMBEX_Button3 EndIf ; GUI MESSAGE LOOP is performed by Main Dialog loop GuiSetState() Opt("GUICoordMode", $liPrevCoordMode) $giMBEX_RtnVal = 0 $giMBEX_TmrStart = TimerInit() $giMBEX_TmrEnd = ($giMBEX_Secs * 1000) ; Total Duration in millisecs GUICtrlSetState($ghMBEX_Button, $GUI_FOCUS) return $ghMBEX EndFunc ;==>_MsgBoxEx ;=============================================================================== ; Updates CountDown Text if second has changed. ; Returns CountDown Value in seconds ;=============================================================================== Func _MBEX_TickTock($pbUseInternalTimer = True) Local $li, $lsValue, $liTmrDiff, $liCountDownSecs, $lbSecChanged ; ConsoleWrite(@LF & "in _MBEX_TickTock() - $ghMBEX=" & $ghMBEX) If Not $ghMBEX Then Return 0 ; incase users leave this call permanently in their own EventLoop If $giMBEX_Secs > 0 Then If $pbUseInternalTimer Then $liTmrDiff = Int(TimerDiff($giMBEX_TmrStart)) ; Elapsed time in milliseconds ; $giMBEX_TmrEnd == Total Duration in millisecs $liCountDownSecs = Round(($giMBEX_TmrEnd - $liTmrDiff) / 1000, 0) If $liCountDownSecs < 0 Then $liCountDownSecs = 0 ; Only update display on second value change.. If $liCountDownSecs <> $giMBEX_Secs Then $giMBEX_Secs = $liCountDownSecs ; Decrament CountDown secs - $giMBEX_Secs -= 1 $lbSecChanged = True EndIf Else $giMBEX_Secs -= 1 $lbSecChanged = True EndIf If $lbSecChanged Then If $giMBEX_Secs < 0 Then $giMBEX_Secs = 0 If $ghMBEX Then If $gbMBEX_ButtonHasCD Then $lsValue = StringReplace($gsMBEX_ButtonText & $gsMBEX_Text, "<##>", $giMBEX_Secs, 0, 0) GUICtrlSetData($ghMBEX_Button, $lsValue) EndIf If $gaMBEX_SecLines[0][0] > 0 Then For $li = 1 To $gaMBEX_SecLines[0][0] $lsValue = StringReplace($gaMBEX_SecLines[$li][1], "<##>", $giMBEX_Secs, 0, 0) GUICtrlSetData($gaMBEX_SecLines[$li][0], $lsValue) Next EndIf EndIf If $giMBEX_Secs <= 0 Then If $ghMBEX Then GUIDelete($ghMBEX) $ghMBEX = 0 EndIf $giMBEX_Secs = 0 ; stop the clock! Call($gsMBEX_CallBack, -1) ; -1 == Timedout EndIf EndIf EndIf Return $giMBEX_Secs EndFunc ;=============================================================================== ;=============================================================================== Func _MBEX_Button1_Pressed() Local $liRtnVal ; @GUI_CTRLID contains $ghMBEX_Button1 when called directly by GUICtrlSetOnEvent() ; and @GUI_WINHANDLE would equal $ghMBEX $giMBEX_Secs = 0 ; stop the clock! If $ghMBEX Then GUIDelete($ghMBEX) $ghMBEX = 0 EndIf Switch $giMBEX_ButtonFlag Case 0 ; OK $liRtnVal = 1 Case 1 ; OK $liRtnVal = 1 Case 2 ; Abort $liRtnVal = 3 Case 3 ; Yes $liRtnVal = 6 Case 4 ; Yes $liRtnVal = 6 Case 5 ; Retry $liRtnVal = 4 Case 6 ; Cancel $liRtnVal = 2 Case 7 ; UserDef $liRtnVal = 1 ; Button Number Case 8 ; Lock PC $liRtnVal = 12 Case Else $liRtnVal = -1 EndSwitch Call($gsMBEX_CallBack, $liRtnVal) EndFunc ;==>_MBEX_Button1_Pressed ;=============================================================================== ;=============================================================================== Func _MBEX_Button2_Pressed() Local $liRtnVal ; @GUI_CTRLID contains $ghMBEX_Button2 when called directly by GUICtrlSetOnEvent() ; and @GUI_WINHANDLE would equal $ghMBEX $giMBEX_Secs = 0 ; stop the clock! If $ghMBEX Then GUIDelete($ghMBEX) $ghMBEX = 0 EndIf Switch $giMBEX_ButtonFlag Case 1 ; Cancel $liRtnVal = 2 Case 2 ; Ignore $liRtnVal = 5 Case 3 ; Cancel $liRtnVal = 2 Case 4 ; No $liRtnVal = 7 Case 5 ; Cancel $liRtnVal = 2 Case 6 ; Continue $liRtnVal = 11 Case 7 ; UserDef $liRtnVal = 2 ; Button Number Case 8 ; Cancel $liRtnVal = 2 Case Else $liRtnVal = -1 EndSwitch Call($gsMBEX_CallBack, $liRtnVal) EndFunc ;==>_MBEX_Button2_Pressed ;=============================================================================== ;=============================================================================== Func _MBEX_Button3_Pressed() Local $liRtnVal ; @GUI_CTRLID contains $ghMBEX_Button2 when called directly by GUICtrlSetOnEvent() ; and @GUI_WINHANDLE would equal $ghMBEX $giMBEX_Secs = 0 ; stop the clock! If $ghMBEX Then GUIDelete($ghMBEX) $ghMBEX = 0 EndIf Switch $giMBEX_ButtonFlag Case 2 ; Retry $liRtnVal = 4 Case 3 ; No $liRtnVal = 7 Case 6 ; Try Again $liRtnVal = 10 Case 7 ; UserDef $liRtnVal = 3 ; Button Number Case Else $liRtnVal = -1 EndSwitch Call($gsMBEX_CallBack, $liRtnVal) EndFunc ;==>_MBEX_Button3_Pressed ;=============================================================================== ;=============================================================================== Func _MBEX_DefaultReturnCallBack($piReturnVal) $giMBEX_RtnVal = $piReturnVal ; Breaks Local Event Loop when not Zero EndFunc ;=============================================================================== ;=============================================================================== Func _MBEX_SpecialEvents() Local $liRtnVal Select Case @GUI_CTRLID = $GUI_EVENT_CLOSE $giMBEX_Secs = 0 ; stop the clock! If $ghMBEX Then GUIDelete($ghMBEX) $ghMBEX = 0 EndIf Switch $giMBEX_ButtonFlag Case 1 ; Cancel $liRtnVal = 2 Case 2 ; Ignore $liRtnVal = 5 Case 3 ; Cancel $liRtnVal = 2 Case 4 ; No $liRtnVal = 7 Case 5 ; Cancel $liRtnVal = 2 Case 6 ; Continue $liRtnVal = 11 Case 7 ; UserDef $liRtnVal = 2 ; Button Number 2 Case 8 ; Cancel $liRtnVal = 2 Case Else $liRtnVal = -1 EndSwitch Call($gsMBEX_CallBack, 13) ; Hard Code Close == 13 Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE Return Case @GUI_CTRLID = $GUI_EVENT_RESTORE Return EndSelect EndFunc ;==>_MBEX_SpecialEvents
-
The only way I know is to use the SourceForge pGina Project. "pGina is a GPL'd replacement for the authentication portion of Windows 2000/XP. Why replace that portion of the OS? Because we hate not having choices. So pGina uses easy to write plugins to accomodate for authentication via limitless backends." It's on my thinks-to-do list. I want ot write a pGina Plugin that uses AutoItX v3 DLL version of AutoIt 3. This will allow an AutoIt Script to be run behind the Windows Logon screen. I want to use this to Poll for Returned Devices that have Locked the Windows session - See my UnAttended.au3 project in Scripts and Scraps. Devices are removable USB Key drives or Windows Mobile PDAs etc.
-
Here is a snapshot of my MsgBoxEx in action. The MsgBoxEx UDF and a simple Test example. MsgBoxEx.zip The Extentsion to the normal old MsgBox is that it:- Will add Count-down text to the default buttonWill replace the characters <##> with the current remaining number of seconds on upto 5 lines of textWill BOLD a while line of text if <b> or </B> tags are seen on any message line.Accepts optional Parent window parameter so when parent minimises, closes then so does MsgBoxEx dialog.Supports Minimize and Close SysMenu buutonsWorks as a drop-in Modal like replacement for MsgBox() but can also work modeless in your own EventLoop environment. Button action generate Callbacks to your event handler.The 1 to 3 buttons can be of ANY text by an optional Array of button text and button count values.Special Return Codes for Type 8 buttons - PC Lock/Cancel.Too much.. so here's the Function comment section... (Sorry about mangled formatting - Best Grab the zip file above) P.S. The best Parent Window examples of MsgBoxEx use is on the About Dialog Test Button actions in UnAttended Script at the beginning of this post.. ;=============================================================================== ; +++ This is to emulate a Modal MsgBox($iFlag, $sTitle, $sText [, $iTimeout]) +++ ; _MsgBoxEx($iFlag, $sTitle, $sText [, $iTimeout [, $sReturnCallBack [, $iLeft [, $iTop [, $hParent]]]]]) ; +++ This is the call to use if you have your own EventLoop where you call _MBEX_TickTock() +++ ; _MsgBoxExCreate($iFlag, $sTitle, $sText [, $iTimeout [, $sReturnCallBack [, $iLeft [, $iTop [, $hParent]]]]]) ; ____________________________________________________________________________________________________ ______________ ; $iFlag The flag indicates the type of message box and the possible button combinations. See remarks. ; $sTitle The title of the message box. ; $sText The text of the message box. "<b>" and/or "</b>" will Bold Text of whole Line only. ; Upto 5 lines may have <##> text replaced with the current second countdown value. ; $iTimeout [optional] Timeout in seconds. After the timeout has elapsed the message box will be closed. ; Default value of 0 will disable timeout. ; $sReturnCallBack [optional] The name of a function you provide that takes a single argument, the ReturnCode. ; Default value is Null String "" which is replaced with internal handler when ; _MsgBoxEx() funcion called. ; If using _MsgBoxExCreate(), ; you MUST register your own ReturnCallBack function here... ; And in your Event Loop, you need to call _MBEX_TickTock() to update timers. ; $iLeft [optional] X Position of Dialog, default of -1 centers dialog horizontally. ; $iTop [optional] Y Position of Dialog, default of -1 centers dialog vertically. ; $hParent [optional] Handle to a Parent Window, defaults to 0. ; ____________________________________________________________________________________________________ ______________ ; ; Note, as this is Modeless, this version does not support multiple instances which can be invoked. ; The code uses the Dialog handle of non-zero to test if another is running already. ; ; Failure: Returns -1 if the message box timed out. ; ; Button Pressed Return Value sent to $gsMBEX_CallBack function you provide ; OK 1 ; CANCEL 2 ; ABORT 3 ; RETRY 4 ; IGNORE 5 ; YES 6 ; NO 7 ; TRY AGAIN ** 10 ; CONTINUE ** 11 ; LOCK PC 12 - You have to do the locking... ; CLOSE 13 - New Return code ; _____________________________________________________________________ ; ; The flag parameter can be a combination of the following values: ; ; decimal flag Button-related Result hexadecimal flag ; 0 OK button 0x0 ; 1 OK and Cancel 0x1 ; 2 Abort, Retry, and Ignore 0x2 ; 3 Yes, No, and Cancel 0x3 ; 4 Yes and No 0x4 ; 5 Retry and Cancel 0x5 ; 6 ** Cancel, Try Again, Continue 0x6 ; 7 ++ +++ See Note7 +++ 0x7 ; 8 ++ Lock PC, Cancel 0x8 ; ; +++ Note7 +++ User sets the Global Array Variables Before Calling this Function ; $gaMBEX_BT[0] = 1, 2 or 3 ; $gaMBEX_BT[1] = "Left Button" ; $gaMBEX_BT[2] = "Right Button" ; $gaMBEX_BT[3] = "Middle Button" ; _____________________________________________________________________ ; decimal flag Icon-related Result hexadecimal flag ; 0 (No icon) 0x0 ; 16 Stop-sign icon 0x10 ; 32 Question-mark icon 0x20 ; 48 Exclamation-point icon 0x30 ; 64 Information-sign icon consisting of an 'i' in a circle 0x40 ; _____________________________________________________________________ ; decimal flag Default-related Result hexadecimal flag ; 0 First button is default button 0x0 ; 256 Second button is default button 0x100 ; 512 Third button is default button 0x200 ; 1024 +++ Default Button has CountDown text 0x400 ; _____________________________________________________________________ ; decimal flag Modality-related Result hexadecimal flag ; 0 Application 0x0 ; 4096 ++ System modal (dialog has an icon) 0x1000 ; 8192 -- Task modal - Not supported 0x2000 ; _____________________________________________________________________ ; decimal flag Miscellaneous-related Result hexadecimal flag ; 0 (nothing else special) 0x0 ; 262144 MsgBox has top-most attribute set 0x40000 ; 524288 -- title and text are right-justified 0x80000 ; ; ** was Only valid on Windows 2000/XP and above. ; ________________________________________________________________ ; ;=============================================================================== Here is the MsgBoxExTest.au3 Code: ; ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.1.1.131+ ; Language: English ; Description: Test Alternative to MsgBox() with extended functionality. ; Author(s): Foxnolds <foxnolds at ewise dot com> ; ------------------------------------------------------------------------------ ;=============================================================================== ; Test routine for MsgBoxEx_UDF.au3 ;=============================================================================== Global $gbDoEventLoop, $ghMsgDlg Local $ls, $liRtnVal Opt("MustDeclareVars", 1) ;0=no (default), 1=require pre-declare ; Include the Animated MsgBox Modeless code #include "MsgBoxEx.au3" ; Test Buttons $ls = "<b>Flag=0 + 1024" & @lf & "Test 1 - OK button" & @LF & "Default button wil be clicked in <##> seconds" $liRtnVal = _MsgBoxEx(0 + 1024, "Test Buttons 1", $ls, 30) $ls = "<b>Flag=1" & @lf & "Test 2 - OK and Cancel" & @LF & "Default button wil be clicked in <##> seconds" & @LF & "Test 1 result was " & $liRtnVal $ls &= @LF & @LF & "<b>Press Cancel to skip the rest of the display tests</b>" $liRtnVal = _MsgBoxEx(1, "Test Buttons 2", $ls, 30) IF $liRtnVal == 1 Then $ls = "<b>Flag=2 + 1024" & @lf & "Test 3 - Abort, Retry, and Ignore" & @LF & "Default button wil be clicked in <##> seconds" & @LF & "Test 2 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(2 + 1024, "Test Buttons 3", $ls, 30) $ls = "<b>Flag=3" & @lf & "Test 4 - Yes, No, and Cancel" & @LF & "Default button wil be clicked in <##> seconds" & @LF & "Test 3 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(3, "Test Buttons 4", $ls, 30) $ls = "<b>Flag=4" & @lf & "Test 5 - Yes and No" & @LF & "Default button wil be clicked in <##> seconds" & @LF & "Test 4 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(4, "Test Buttons 5", $ls, 30) $ls = "<b>Flag=5 + 1024" & @lf & "Test 6 - Retry and Cancel" & @LF & "Default button wil be clicked in <##> seconds" & @LF & "Test 5 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(5 + 1024, "Test Buttons 6", $ls, 30) $ls = "<b>Flag=6" & @lf & "Test 7 - Cancel, Try Again, Continue" & @LF & "Default button wil be clicked in <##> seconds" & @LF & "Test 6 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(6, "Test Buttons 7", $ls, 30) $gaMBEX_BT[0] = 3 $gaMBEX_BT[1] = "Button1" $gaMBEX_BT[2] = "Button2" $gaMBEX_BT[3] = "Middle" $ls = "<b>Flag=7 + 1024" & @lf & "Test 8 - Button1, Middle, Button2" & @LF & "Test 7 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(7 + 1024, "Test Buttons 7", $ls, 30) $gaMBEX_BT[0] = 2 $gaMBEX_BT[1] = "Button1" $gaMBEX_BT[2] = "Button2" $gaMBEX_BT[3] = "" $ls = "<b>Flag=7" & @lf & "Test 8 - Button 1 and 2 only" & @LF & "Test 7 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(7, "Test Buttons 7", $ls, 30) $gaMBEX_BT[0] = 1 $gaMBEX_BT[1] = "My Custom Button Text" $gaMBEX_BT[2] = "" $gaMBEX_BT[3] = "" $ls = "<b>Flag=7 + 1024" & @lf & "Test 8 - Custom Button Text" & @LF & "Test 7 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(7 + 1024, "Test Buttons 7", $ls, 30) $ls = "<b>Flag=8+256+1024" & @lf & "Test 9 - Lock PC, Cancel" & @LF & "Test 8 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(8+256+1024, "Test Buttons 8", $ls, 30) If $liRtnVal == 12 Then _LockWorkStation(); GotCha! Ha ha ; Test Icons $ls = "<b>Flag=16 Stop-sign" & @lf & "Test 9 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(1 + 16, "Test Icon 16", $ls, 30) $ls = "<b>Flag=32 Question-mark" & @lf & "Test Icon 16 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(1 + 32, "Test Icon 32", $ls, 30) $ls = "<b>Flag=48+4096 Exclamation-point" & @lf & "Test Icon 32 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(1 + 48+4096, "Test Icon 48", $ls, 30) $ls = "<b>Flag=64+1024+4096+524288 Information-sign" & @lf & "Test Icon 48 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(1+64+1024+4096+524288, "Test Icon 64", $ls, 30) ; Test Second Default 256 $ls = "<b>Flag=1 + 256" & @lf & "Test Def2 - OK and Cancel" & @LF & "Test Icon 64 result was " & $liRtnVal $liRtnVal = _MsgBoxEx(1 + 256, "Test Default 2", $ls, 30) $ls = "<b>Flag=2 + 256" & @lf & "Test Def2 - Abort, Retry, and Ignore" & @LF & "Previous Test result was " & $liRtnVal $liRtnVal = _MsgBoxEx(2 + 256, "Test Default 2", $ls, 30) $ls = "<b>Flag=0 + 256" & @lf & "Test Def2 - OK" & @LF & "Previous Test result was " & $liRtnVal $liRtnVal = _MsgBoxEx(0 + 256, "Test Default 2", $ls, 30) ; Test Third Default 512 $ls = "<b>Flag=2 + 512" & @lf & "Test Def3 - Abort, Retry, and Ignore" & @LF & "Previous Test result was " & $liRtnVal $liRtnVal = _MsgBoxEx(2 + 512, "Test Default 3", $ls, 30) $ls = "<b>Flag=1 + 512" & @lf & "Test Def3 - OK and Cancel" & @LF & "Previous Test result was " & $liRtnVal $liRtnVal = _MsgBoxEx(1 + 512, "Test Default 3", $ls, 30) $ls = "<b>Flag=0 + 512" & @lf & "Test Def3 - OK" & @LF & "Previous Test result was " & $liRtnVal $liRtnVal = _MsgBoxEx(0 + 512, "Test Default 3", $ls, 30) EndIf ; ; ; ; Now show Event Mode call $ls = "<b>Flag=8+1024+4096" & @LF & "Default button wil be clicked in <##> seconds" & @lf & "Last Test result was " & $liRtnVal $ls &= @LF & @LF & "Timeout OR Left Button will do stated action" & @LF & "Cancel will present another Dialog Before Exiting" $ls &= @LF & "<b>Close box will do immediate Exit<b>" ; _MsgBoxExCreate($iFlag, $sTitle, $sText [, $iTimeout [, $sReturnCallBack [, $iLeft [, $iTop [, $hParent]]]]]) _MsgBoxExCreate(8+1024+4096, "Tests Finished", $ls, 30, "_TestLocalCallBack") _MyLocalEventLoop() Exit ;=============================================================================== ;=============================================================================== Func _MyLocalEventLoop() Local $liValue $gbDoEventLoop = True While $gbDoEventLoop Sleep(1000); Use 1 second delay in Loop so set UseInternalTimer to False in _MBEX_TickTock _MBEX_TickTock(False); Internally, _MBEX_TickTock() tests existance of $ghMBEX anyway WEnd EndFunc;==>_MyLocalEventLoop ;=============================================================================== ;=============================================================================== Func _TestLocalCallBack($piReturnVal) ; Do what you need to do with result.. Switch $piReturnVal Case 12; Lock PC ContinueCase Case -1; Timeout _LockWorkStation() $gbDoEventLoop = False Case 13; Close - Exit your event loop with optional cleanup $gbDoEventLoop = False Case 2; Cancel MsgBox(0, "Result Dlg", "Canceled out within time", 10) $gbDoEventLoop = False EndSwitch EndFunc;==>_TestLocalCallBack ;=============================================================================== ;=============================================================================== Func _LockWorkStation() DllCall("user32.dll", "int", "LockWorkStation") _MonitorOff(True); 1=off, 0=On EndFunc;==>_LockWorkStation ;=============================================================================== ; Function to turn the Monitor on - off ;=============================================================================== Func _MonitorOff($piOff = True) Local $liPrevOpt, $lhWND Local Const $lciWM_SYSCommand = 274 Local Const $lciSC_MonitorPower = 61808 Local Const $lciPower_Off = 2 Local Const $lciPower_On = -1 $liPrevOpt = Opt("WinTitleMatchMode", 4) $lhWND = WinGetHandle("classname=Progman") If $piOff Then DllCall("user32.dll", "int", "SendMessage", "hwnd", $lhWND, "int", $lciWM_SYSCommand, _ "int", $lciSC_MonitorPower, "int", $lciPower_Off) Else DllCall("user32.dll", "int", "SendMessage", "hwnd", $lhWND, "int", $lciWM_SYSCommand, _ "int", $lciSC_MonitorPower, "int", $lciPower_On) EndIf Opt("WinTitleMatchMode", $liPrevOpt) EndFunc
-
Brilliant! flyingboz! I tried it on my PC and it works a treat. It's 3:50 AM so I must get 3 hours sleep B4 I go to work. I'll plug in the change tonight (Aussie Time) when I get home again...
-
Here is the Help.chm file I built - also trying to learn Vizacc HelpMaker.. UnAttended_Help_v0_1_1_0.zip
-
UnAttended Event Handler v0.1.2.0 UnAttended_v0_1_2_0.zip - Full kit including UDFs below. I've spent a couple of weeks now playing with AutoIt v3 Beta 3.1.1.127-132 and this was the first project I wrote for myself to learn the ropes. If you don't find the UnAttended application useful then you may like the couple of potential UDFs I had to write to do stuff I needed: MsgBoxEx.au3 MsgBoxEx.zipDriveGetDriveEx.au3 DriveGetDriveEx.zipSysTray.au3 - My fixed version for my needs SysTray.zipWhat is it? UnAttended is an AutoIt3 Script that watches for dialogs and fills them in or dismisses them automatically - particularly when you are away from your computer.It will fill in passwords for Jetico BestCrypt encrypted Volumes, PGP Disks and PGP Identities, Windows Network Mounted Shares mounted under different user Domain names and Launch Putty SSH sessions as well as a DOS Command Shell as required. It monitors Crashing Dialogs from Eudora Email Application (Usually due to some bad spam *.CRV file in the Spool directory, crashing dialogs from Microsoft ActiveSync 4.x and various other Windows Mobile Pocket PC Applications. It knows about a VPN connection from Home to Work and uses it to mount Work Network drives as required. UnAttended will also act as a PC Lock, Locking the Screen and turning off the monitor when a registered USB Device (USB Key Disk) or an ActiveSync USB/Bluetooth connection leaves. Known Problems: I have not had success in catching Windows Session Close. The problem this causes is that UnAttended may be closed too early, or it may try to restore a Closed Eudora Application if it has seen the Session Quit message before UnAttended.Not all error dialogs and conditions have been caught and identified. Hopefully this will improve over time. I may have addressed this issue with the User Dialogs Configuration Tab.Launching a VPN connection is clumsy. I need to find a better method than launching a .LNK file.Polling status of disconnected Network drives can be time consuming. It can take upto 25 seconds of a blocking call to determine that a Network drive is no longer available. VPN status is only polled once per minute now.Polling the status of a SysTrayIcon that is no longer present is also slow. Again, it can take a few seconds to realise that the Application is not running any more. For example the VPN connection status is read from its SysTrayIcon.I'm sure there's more....I whipped up the start of a help file that I'll post next. I still need to learn how to hook it into an AutoIt application.. Edit: 1st Aug 06 - Changed VPN detection to use "RASDial" technique. Thanks flyingboz. - Sped up disconnected Network drive handling by using "Net Use" command. Edit - Added some screen shots..
-
Here is the version I modified for my own use that uses the Mouse to switch desktops. pangaea_desktops.zip - includes Icon file. You can use a Bounce wall within 2 seconds as a trigger or you can hold the mouse on edge for more than 2 seconds as a trigger to change the desktop. Vertically the mouse will wrap the screen based upon trigger used. It's just a simple change. Edit: Added Opt("WinWaitDelay", 0) as suggested. #Region Compiler directives section ;** This is a list of compiler directives used by AutoIt3Wrapper.exe. ;** comment the lines you don't need or else it will override the default settings #Compiler_Prompt=y ;y=show compile menu ;** AUTOIT3 settings ;#Compiler_AUTOIT3= ;Override the default Interpreter version. ;** AUT2EXE settings #Compiler_AUT2EXE= ;Override the default compiler with this version. #Compiler_Icon=Pangaea_Desktops.ico ;Filename of the Ico file to use #Compiler_OutFile=Pangaea_Desktops ;Target exe/a3x filename. #Compiler_OutFile_Type=exe ;a3x=small AutoIt3 file; exe=Standalone executable(Default) #Compiler_Compression=4 ;Compression parameter 0-4 0=Low 2=normal 4=High #Compiler_Allow_Decompile=y ;y= allow decompile #Compiler_PassPhrase= ;Password to use for compilation #Compiler_UseUpx=y ;Compress output program works only for 3.1.1.110 and up. Default=Yes ;** Target program Resource info #Compiler_Res_Comment=Multiple Desktops for Windows ;Comment field #Compiler_Res_Description=Modified release with Mouse switching Support ;Description field #Compiler_Res_Fileversion=1.0.1.7 ;File Version #Compiler_Res_FileVersion_AutoIncrement=y ;AutoIncrement FileVersion After Aut2EXE is finished. #Compiler_Res_LegalCopyright=by Rakudave, Pangaea WorX 2006 ;Copyright field ; free form resource fields ... max 15 ; you can use the following variables: ; %AutoItVer% which will be replaced with the version of AutoIt3 ; %date% = PC date in short date format ; %longdate% = PC date in long date format ; %time% = PC timeformat #Compiler_Res_Field=AutoIt Version|%AutoItVer% ;#Compiler_Res_Field=Name|Value ;Free format fieldname|fieldvalue ;#Compiler_Res_Field=Name|Value ;Free format fieldname|fieldvalue ;#Compiler_Res_Field=Name|Value ;Free format fieldname|fieldvalue ;#Compiler_Res_Field=Name|Value ;Free format fieldname|fieldvalue ; AU3CHECK settings #Compiler_Run_AU3Check=Y ;(Y/N) Run au3check before compilation. Default=Y ;#Compiler_AU3Check_Parameters= ;Au3Check parameters ;#Compiler_AU3Check_Dat= ;Override the default au3check definition #Compiler_AU3Check_Stop_OnWarning=Y ;(Y/N) N=Continue on Warnings.(Default) Y=Always stop on Warnings #Compiler_AU3Check_Parameters= ;Au3Check parameters ;#Compiler_PlugIn_Funcs= ;Define PlugIn function names separated by a Comma to avoid AU3Check errors ; RUN BEFORE AND AFTER definitions ; The following directives can contain: ; %in% , %out%, %icon% which will be replaced by the fullpath ilename. ; %scriptdir% same as @ScriptDir and %scriptfile% = filename without extension. ; %fileversion% is the information from the #Compiler_Res_Fileversion directive ; %scitedir% will be replaced by the SciTE program directory ;#Compiler_Run_Before= ;process to run before compilation - you can have multiple records that will be processed in sequence ;#Compiler_Run_After= ;process to run After compilation - you can have multiple records that will be processed in sequence ;#Compiler_Run_cvsWrapper= ;(y/n) Run cvsWrapper to update the script source. Default=n #EndRegion #Include <Constants.au3> #include <GUIConstants.au3> #NoTrayIcon Opt("MustDeclareVars", 1) ; 0=no, 1=require pre-declare Opt("TrayMenuMode", 1) ; 0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return Opt("TrayOnEventMode", 1) ; 0=disable, 1=enable Opt("WinWaitDelay", 0) ; default is 250 milliseconds FileDelete(@tempdir & "pangaeadesktops.ini") HotKeySet("#{ESC}", "_panic") HotKeySet("#{LEFT}", "_prevdesk") HotKeySet("#{RIGHT}", "_nextdesk") HotKeySet("^#{LEFT}", "_movetoprev") HotKeySet("^#{RIGHT}", "_movetonext") Global $activedesk = 1, $winlist[500], $hwnd, $textwin, $texton = 0, $texttime, $desktopitem, $inaction = 0 Global $nextitem, $previtem, $tonextitem, $toprevitem, $aboutitem, $exititem Global $bInRange, $iMouseTime = 0, $iMouseBounce = 0, $bMouseBounce = True, $sLastTTMsg = "" Global $sRunDIR, $bAnimate = False, $ti_Animate, $ti_Bounce, $iCountdown = 0, $iCountTime = 0 Global $sTrayTip_MouseOverMsg Global Const $gcsTrayTip_BalloonTitle = "Pangaea Desktops" Global Const $gcsTrayTip_MouseOverPrefix = $gcsTrayTip_BalloonTitle & @CRLF _winget() $desktopitem = TrayCreateItem("Desktop " & $activedesk) TrayItemSetState(-1, $TRAY_DISABLE) ; $TRAY_DISABLE =128 $ti_Animate = TrayCreateItem("Animate moves") TrayItemSetOnEvent(-1, "_trayAnimate") $ti_Bounce = TrayCreateItem("Require Border Double Hit") TrayItemSetOnEvent(-1, "_trayBounce") TrayItemSetState(-1, $TRAY_CHECKED) TrayCreateItem("") $nextitem = TrayCreateItem("Next desktop win + right") TrayItemSetOnEvent(-1, "_nextdesk") $previtem = TrayCreateItem("Prev desktop win + left") TrayItemSetOnEvent(-1, "_prevdesk") TrayCreateItem("") $tonextitem = TrayCreateItem("Move to next desktop ctrl + win + right") TrayItemSetOnEvent(-1, "_movetonext") $toprevitem = TrayCreateItem("Move to prev desktop ctrl + win + left") TrayItemSetOnEvent(-1, "_movetoprev") TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayItemSetOnEvent(-1, "_About") $exititem = TrayCreateItem("Exit win + esc") TrayItemSetOnEvent(-1, "_panic") TraySetOnEvent($TRAY_EVENT_MOUSEOVER, "_TrayMouseOver") TraySetState() $sTrayTip_MouseOverMsg = $gcsTrayTip_MouseOverPrefix & "Desktop " & $activedesk If @Compiled Then $sRunDIR = @AutoItExe $sRunDIR = StringLeft($sRunDIR, StringInStr($sRunDIR, "", 0, -1) - 1) Else $sRunDIR = @ScriptDir ; TraySetIcon("shell32.dll", 94) TraySetIcon(@ScriptDir & "Pangaea_Desktops.ico") EndIf While 1 If $texton = 1 then If TimerDiff($texttime) > 3000 Then _text2() _TrayTipStatus("") EndIf Endif _warp() If $iCountdown > 0 Then If TimerDiff($iCountTime) > ($iCountdown * 1000) Then $iCountdown = 0 $sTrayTip_MouseOverMsg = $gcsTrayTip_MouseOverPrefix & "Desktop " & $activedesk TraySetState(17) ; Resets the icon to the defaults (no flashing, default tip text) ; Just incase icon disappeared... Opt("TrayIconHide", 0) ; 0=show (default), 1=hide tray icon TrayTip("", "", 0) ; Clears any TrayTip Balloon EndIf EndIf Sleep(100) WEnd ;=============================================================================== ; Poll this function from the main loop. ;=============================================================================== Func _warp() Local $aMousePos, $aSecondPos $aMousePos = MouseGetPos() $bInRange = False ; Mouse Horizontal Desktop swap tests If $aMousePos[0] <= 2 Then $bInRange = True If $iMouseTime == 0 Then $iMouseTime = TimerInit() ElseIf $aMousePos[0] >= @DeskTopWidth - 2 Then $bInRange = True If $iMouseTime == 0 Then $iMouseTime = TimerInit() EndIf ; Mouse Vertical Wrap tests If $bMouseBounce Then If $aMousePos[1] <= 2 Then $bInRange = True If $iMouseTime == 0 Then $iMouseTime = TimerInit() ElseIf $aMousePos[1] >= @DeskTopHeight - 2 Then $bInRange = True If $iMouseTime == 0 Then $iMouseTime = TimerInit() EndIf Else ; Immediate Warp mouse vertically if in zone... If $aMousePos[1] <= 2 Then _TrayTipStatus("Mouse Warped to Bottom") MouseMove($aMousePos[0], @DesktopHeight - 3, 1) _TrayTipStatus("") ElseIf $aMousePos[1] >= @DeskTopHeight - 2 Then _TrayTipStatus("Mouse Warped to Top") MouseMove($aMousePos[0], 3, 1) _TrayTipStatus("") EndIf EndIf If $bInRange Then If $bMouseBounce Then ; Mouse must be in-range, out-of-range then back in-range within 2 seconds ; $iMouseBounce = 0, 1, 2 If TimerDiff($iMouseTime) < 2000 Then If $iMouseBounce == 0 Then $iMouseBounce = 1 ; Mouse in-range noted for the First Time ElseIf $iMouseBounce == 2 Then ; In then out-of-range then now, in-range again... $aMousePos = MouseGetPos() ; Mouse Horizontal Desktop swap tests If $aMousePos[0] <= 2 Then _MousePrevDesk($aMousePos) ElseIf $aMousePos[0] >= @DeskTopWidth - 2 Then _MouseNextDesk($aMousePos) EndIf ; Mouse Vertical Wrap tests If $aMousePos[1] <= 2 Then _TrayTipStatus("Mouse Warped to Bottom") MouseMove($aMousePos[0], @DesktopHeight - 3, 1) _TrayTipStatus("") ElseIf $aMousePos[1] >= @DeskTopHeight - 2 Then _TrayTipStatus("Mouse Warped to Top") MouseMove($aMousePos[0], 3, 1) _TrayTipStatus("") EndIf $iMouseBounce = 0 $bInRange = False $iMouseTime = 0 EndIf Else ; Timer expired so reset bounce condition $iMouseBounce = 0 $bInRange = False $iMouseTime = 0 EndIf Else ; Mouse must linger in trigger zone for more than 2 seconds If TimerDiff($iMouseTime) > 2000 Then $aMousePos = MouseGetPos() If $aMousePos[0] <= 2 Then _MousePrevDesk($aMousePos) ElseIf $aMousePos[0] >= @DeskTopWidth - 2 Then _MouseNextDesk($aMousePos) EndIf $bInRange = False $iMouseTime = 0 EndIf EndIf Else If $bMouseBounce and $iMouseTime > 0 Then If TimerDiff($iMouseTime) < 2000 Then If $iMouseBounce == 1 Then $iMouseBounce = 2 ; In then out-of-range ElseIf $iMouseBounce == 2 Then ; Still out-of-range in time so OK... EndIf Else ; Time expired so reset timer $iMouseBounce = 0 ; Reset out of band condition $iMouseTime = 0 EndIf Else $iMouseTime = 0 EndIf EndIf EndFunc Func _showwins() Local $var, $x $var = IniReadSection(@tempdir & "pangaeadesktops.ini", $activedesk) If @error Then return Else For $x = 1 To $var[0][0] WinSetState($var[($var[0][0] +1) -$x][0],"",@SW_SHOW) Next EndIf EndFunc Func _hidewins() Local $var, $x $var = IniReadSection(@tempdir & "pangaeadesktops.ini", $activedesk) If @error Then return Else For $x = 1 To $var[0][0] WinSetState($var[($var[0][0] +1) -$x][0],"",@SW_HIDE) Next EndIf EndFunc Func _MouseNextDesk($aMousePos) BlockInput(1) MouseMove(5, $aMousePos[1], 1) _nextdesk() ; To the right BlockInput(0) EndFunc Func _MousePrevDesk($aMousePos) BlockInput(1) MouseMove(@DeskTopWidth - 5, $aMousePos[1], 1) _prevdesk() ; To the Left BlockInput(0) EndFunc Func _nextdesk() Local $iDeskNum If $inaction = 1 then return $inaction = 1 $iDeskNum = $activedesk + 1 If $iDeskNum = 5 Then $iDeskNum = 1 _TrayTipStatus("Desktop " & $iDeskNum) If $texton = 1 Then _text2() _winget() If $bAnimate Then _animate1() _hidewins() $activedesk = $iDeskNum _showwins() If $bAnimate Then _animate3() $inaction = 0 _text1() EndFunc Func _prevdesk() Local $iDeskNum If $inaction = 1 then return $inaction = 1 $iDeskNum = $activedesk - 1 If $iDeskNum == 0 Then $iDeskNum = 4 _TrayTipStatus("Desktop " & $iDeskNum) If $texton = 1 Then _text2() _winget() If $bAnimate Then _animate1() _hidewins() $activedesk = $iDeskNum _showwins() If $bAnimate Then _animate2() $inaction = 0 _text1() EndFunc Func _movetonext() If $inaction = 1 then return $inaction = 1 _winget() IniDelete (@tempdir & "pangaeadesktops.ini",$activedesk,$winlist[1]) $activedesk = $activedesk + 1 If $activedesk = 5 Then $activedesk = 1 Iniwrite(@tempdir & "pangaeadesktops.ini",$activedesk,$winlist[1],"moved") $activedesk = $activedesk - 1 If $activedesk = 0 Then $activedesk = 4 WinSetState($winlist[1],"",@SW_HIDE) $inaction = 0 _nextdesk() EndFunc Func _movetoprev() If $inaction = 1 then return $inaction = 1 _winget() IniDelete (@tempdir & "pangaeadesktops.ini",$activedesk,$winlist[1]) $activedesk = $activedesk - 1 If $activedesk = 0 Then $activedesk = 4 Iniwrite(@tempdir & "pangaeadesktops.ini",$activedesk,$winlist[1],"moved") $activedesk = $activedesk + 1 If $activedesk = 5 Then $activedesk = 1 WinSetState($winlist[1],"",@SW_HIDE) $inaction = 0 _prevdesk() EndFunc Func _winget() Local $x, $y, $var $y = 0 $var = WinList() IniDelete(@tempdir & "pangaeadesktops.ini",$activedesk) For $x = 1 to $var[0][0] If $var[$x][0] <> "" AND IsVisible($var[$x][1]) AND $var[$x][0] <> "Program Manager" AND $var[$x][0] <> "Desktop 1" AND $var[$x][0] <> "Desktop 2" AND $var[$x][0] <> "Desktop 3" AND $var[$x][0] <> "Desktop 4" Then Iniwrite(@tempdir & "pangaeadesktops.ini",$activedesk,$var[$x][0],$var[$x][1]) $y = $y + 1 $winlist[$y] = $var[$x][0] EndIf Next $winlist[0] = $y EndFunc Func _panic() Local $x, $y, $var _TrayTipStatus("Exiting Pangaea Desktops") for $y = 1 to 4 $var = IniReadSection(@tempdir & "pangaeadesktops.ini", $y) If @error = 0 then For $x = 1 To $var[0][0] WinSetState($var[($var[0][0] +1) -$x][0],"",@SW_SHOW) Next EndIf next FileDelete(@tempdir & "pangaeadesktops.ini") FileDelete(@tempdir & "pangaeaprtsc.jpg") Exit EndFunc Func _animate1() DllCall("captdll.dll", "int", "CaptureScreen", "str", @tempdir & "pangaeaprtsc.jpg", "int", 85) _TrayTipStatus($sLastTTMsg) $hwnd = GUICreate("AnimatedWindow", @desktopwidth, @desktopheight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUICtrlCreatePic(@tempdir & "pangaeaprtsc.jpg", 0, 0, @desktopwidth, @desktopheight) GUISetState() _TrayTipStatus($sLastTTMsg) EndFunc Func _animate2() DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050002) ; slide out to left _TrayTipStatus($sLastTTMsg) GUIDelete($hwnd) EndFunc Func _animate3() DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050001) ; slide out to right _TrayTipStatus($sLastTTMsg) GUIDelete($hwnd) EndFunc Func _text1() Local $text _TrayTipStatus($sLastTTMsg) $text = "Desktop " & $activedesk TrayItemSetText($desktopitem, $text) $textwin = TextWindow($text, 600, 40, "", -1, 10, 10, 0xFF0000) GUISetState() $texton = 1 $texttime = TimerInit() EndFunc Func _text2() GUIDelete($textwin) $texton = 0 EndFunc Func OnAutoItExit() _panic() EndFunc Func IsVisible($handle) If BitAnd(WinGetState($handle),2) Then Return 1 Else Return 0 EndIf EndFunc Func TextWindow($zText,$width,$height,$font="Microsoft Sans Serif",$weight=1000,$x=-1,$y=-1,$color=-1) Local Const $ANSI_CHARSET = 0 Local Const $OUT_CHARACTER_PRECIS = 2 Local Const $CLIP_DEFAULT_PRECIS = 0 Local Const $PROOF_QUALITY = 2 Local Const $FIXED_PITCH = 1 Local Const $RGN_XOR = 3 If $font = "" Then $font = "Microsoft Sans Serif" If $weight = -1 Then $weight = 1000 Local $gui = GUICreate("Text Window",$width,$height,$x,$y,$WS_POPUP,$WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) If $color <> -1 Then GUISetBkColor($color) Local $hDC= DLLCall("user32.dll","int","GetDC","hwnd",$gui) Local $hMyFont = DLLCall("gdi32.dll","hwnd","CreateFont","int",$height, _ "int",0,"int",0,"int",0,"int",1000,"int",0, _ "int",0,"int",0,"int",$ANSI_CHARSET, _ "int",$OUT_CHARACTER_PRECIS,"int",$CLIP_DEFAULT_PRECIS, _ "int",$PROOF_QUALITY,"int",$FIXED_PITCH,"str",$font ) Local $hOldFont = DLLCall("gdi32.dll","hwnd","SelectObject","int",$hDC[0], _ "hwnd",$hMyFont[0]) DLLCall("gdi32.dll","int","BeginPath","int",$hDC[0]) DLLCall("gdi32.dll","int","TextOut","int",$hDC[0],"int",0,"int",0, _ "str",$zText,"int",StringLen($zText)) DLLCall("gdi32.dll","int","EndPath","int",$hDC[0]) Local $hRgn1 = DLLCall("gdi32.dll","hwnd","PathToRegion","int",$hDC[0]) Local $rc = DLLStructCreate("int;int;int;int") DLLCall("gdi32.dll","int","GetRgnBox","hwnd",$hRgn1[0], _ "ptr",DllStructGetPtr($rc)) Local $hRgn2 = DLLCall("gdi32.dll","hwnd","CreateRectRgnIndirect", _ "ptr",DllStructGetPtr($rc)) DLLCall("gdi32.dll","int","CombineRgn","hwnd",$hRgn2[0],"hwnd",$hRgn2[0], _ "hwnd",$hRgn1[0],"int",$RGN_XOR) DLLCall("gdi32.dll","int","DeleteObject","hwnd",$hRgn1[0]) DLLCall("user32.dll","int","ReleaseDC","hwnd",$gui,"int",$hDC[0]) DLLCall("user32.dll","int","SetWindowRgn","hwnd",$gui,"hwnd",$hRgn2[0],"int",1) DLLCall("gdi32.dll","int","SelectObject","int",$hDC[0],"hwnd",$hOldFont[0]) Return $gui EndFunc Func _trayAnimate() If $bAnimate Then TrayItemSetState($ti_Animate, $TRAY_UNCHECKED) ; $TRAY_UNCHECKED = 4 $bAnimate = False Else TrayItemSetState($ti_Animate, $TRAY_CHECKED) ; $TRAY_CHECKED = 1 $bAnimate = True EndIf EndFunc Func _trayBounce() If $bMouseBounce Then TrayItemSetState($ti_Bounce, $TRAY_UNCHECKED) $bMouseBounce = False $iMouseBounce = 0 Else TrayItemSetState($ti_Bounce, $TRAY_CHECKED) $bMouseBounce = True $iMouseBounce = 0 EndIf EndFunc Func _About() Local $s $s = "Pangaea Desktops " If @Compiled Then $s &= FileGetVersion(@AutoItExe) $s &= @CRLF & "by Rakudave, Pangaea WorX 2006" & @CRLF & "Mouse modification by Foxnolds" $s &= @CRLF & @CRLF & "[url="[url="http://www.pangaeaworx.ch.vu"]http://www.pangaeaworx.ch.vu[/url]"]www.pangaeaworx.ch.vu[/url]" Msgbox(64,"about:", $s) EndFunc Func _TrayTipStatus($sTTMsg) If $sTTMsg == "" Then TraySetState(17) ; Resets the icon to the defaults (no flashing, default tip text) ; Just incase icon disappeared... Opt("TrayIconHide", 0) ; 0=show (default), 1=hide tray icon $iCountTime = TimerInit() $iCountdown = 2 ; Clear TrayTip after 2 seconds via Main Event Loop Return ; Leave old message to expire EndIf If $sLastTTMsg <> $sTTMsg Then $sLastTTMsg = $sTTMsg TrayTip("", "", 0) ; Clear and remove any previous TrayTip EndIf $sTrayTip_MouseOverMsg = $gcsTrayTip_MouseOverPrefix & $sTTMsg ; Just incase icon disappeared... Opt("TrayIconHide", 0) ; 0=show (default), 1=hide tray icon TraySetState(4) ; Flashes the tray icon ; TrayTip ( "title", "text", timeout [, option] ) ; title Text appears in bold at the top of the balloon tip. (63 characters maximum) ; text Message the balloon tip will display. (255 characters maximum) ; timeout A rough estimate of the time (in seconds) the balloon tip should be displayed. ; (Windows has a min and max of about 10-30 seconds but does not always honor a time in that range.) ; option [optional] See Remarks. 0=No icon (default), ; 1=Info icon, 2=Warning icon, 3=Error icon TrayTip($gcsTrayTip_BalloonTitle, $sTTMsg, 30, 1) EndFunc ;==>_TrayTipStatus Func _TrayMouseOver() TrayTip("", "", 0) ; clears any tray tip TraySetToolTip($sTrayTip_MouseOverMsg) EndFunc ;==>_TrayMouseOver
-
Well spotted rbhkamal! I use this Function to scan for open VPN connection status. I have not found any other way to quickly determine connection status other than by examining the SysTray ICON . My project I am writing to Learn this tool will be posted soon to this forum for interest sake. I have called it UnAttended.exe that launches from the Startup Folder and handles the MANY dialogs that popup as the PC boots then monitors events as applications crash arround me (mainly Eudora, MS ActiveSync).
-
I could not wait for fixes so I fixed this version for my own use. I had only one Icon on startup that produced errors. The fix looks like: Local $iMax = _SysTrayIconCount() If $iMax < 2 Then $iMax = 2 ; To fix Badly formatted Array Error Local $aInfo[$iMax] I also added OpenDLL stubs and close because I poll the Icons and I need it to be FAST.. ;=============================================================================== ; As we don't have a #ifndef $hDLL_User32 ; Do this step on your AU3 Script load ;=============================================================================== Global $hDLL_User32, $hDLL_Kernel32 Func _SysTrayDLL_Init() $hDLL_User32 = DllOpen('user32.dll') $hDLL_Kernel32 = DllOpen('kernel32.dll') EndFunc;==>_SysTrayDLL_Init ;=============================================================================== ; Do this step in your AU3 Script Exit ;=============================================================================== Func _SysTrayDLL_Close() DllClose($hDLL_User32) DllClose($hDLL_Kernel32) EndFunc;==>_SysTrayDLL_Close The GetIconPids was returning the wrong owners. Simpler code fixed that! Func _SysTrayIconPids() Local $i Local $iMax = _SysTrayIconCount() If $iMax < 2 Then $iMax = 2 ; To fix Badly formatted Array Error Local $aSysTrayIconPids[$iMax] Local $aRet Local $hWnd For $i=0 to $iMax-1 $aSysTrayIconPids[$i] = -1 $hWnd = _SysTrayIconHandle($i) If Not @error And $hWnd <> -1 Then $aSysTrayIconPids[$i] = WinGetProcess(HWnd($hWnd)) EndIf Next return $aSysTrayIconPids EndFunc I changed some of the variable names for readability and set scope of variables so they don't clash when combining multiple function results etc. I have not tried my mods on Win2K as I only run on XP and Vista. Edit: After applying follow post fixes, this is my working version. It is Opt("MustDeclareVars", 1) friendly. I will merge in enhancements from Post #1 then update this again - probably over the weekend. SysTray_UDF.au3