Jump to content

How to make Toast - New version 2 Aug 18


Melba23
 Share

Recommended Posts

  • Moderators

MilesAhead,

I am working on the AutoHide logic at the moment. The AH state at logon is stored in the registry, but it appears that it is not altered by any subsequent changes unless the change is still in force at logoff. ;)

So I may have to look at a double check: - Check the position of the taskbar and if it is hidden, use its position to locate the Toast; if it is not, then use the WorkArea. What happens to your RocketDock if the taskbar hides? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

It is a weird thing. I did some scripts to catch if the user changed the auto hide option while my script was running. It didn't do me any good. Seems like if AutoHide is on, all bets are off. I'll be interested to see how you implement it. I might pick up some tips on using more indicators than just work area. :)

Also your utility is different in that it doesn't necessarily care about users maximizing windows. You calculate for Toast so it may be moot in your implementation.

Edited by MilesAhead
Link to comment
Share on other sites

I don't know if this will help but I use this function >>

Func _TaskbarHidden() ; 0 = Shown Or 1 = Hidden
    Local Const $ABM_GETSTATE = 0x00000004
    Local $aReturn
    $aReturn = DllCall('shell32.dll', 'uint', 'SHAppBarMessage', 'dword', $ABM_GETSTATE, 'ptr*', 0)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    If BitAND($aReturn[0], 0x01) Then
        Return 1
    EndIf
EndFunc   ;==>_TaskbarHidden

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

MilesAhead,

I am working on the AutoHide logic at the moment. The AH state at logon is stored in the registry, but it appears that it is not altered by any subsequent changes unless the change is still in force at logoff. ;)

So I may have to look at a double check: - Check the position of the taskbar and if it is hidden, use its position to locate the Toast; if it is not, then use the WorkArea. What happens to your RocketDock if the taskbar hides? :)

M23

Sorry. I missed your question first time I read the post. RocketDock just sits where it is. I never set taskbar to autohide.

Link to comment
Share on other sites

  • Moderators

MilesAhead & anyone else reading,

Please try this beta code and see how the Toast placement works for you. It basically uses the set work area if the taskbar is visible (which should satisfy MilesAhead) but reverts to the Taskbar position if it is hidden (with some changes to original code to cater for Classic mode and its oversized taskbar). It has worked fine for me in Vista x32 - confirmation it works in other OSs would be helpful. :)

#region ; Header
    #include-once

    ; #INDEX# ============================================================================================================
    ; Title .........: Toast
    ; AutoIt Version : 3.3.2.0 - uses AdlibRegister/Unregister
    ; Language ......: English
    ; Description ...: Show and hides slice messages from the systray in user defined colours and fonts
    ; Author(s) .....: Melba23
    ; ====================================================================================================================

    ;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

    ; #INCLUDES# =========================================================================================================
    #include <StringSize.au3>

    ; #GLOBAL VARIABLES# =================================================================================================
    Global $iDef_Toast_Font_Size = _Toast_GetDefFont(0)
    Global $sDef_Toast_Font_Name = _Toast_GetDefFont(1)

    Global $hToast_Handle = 0
    Global $hToast_Close_X = 9999
    Global $iToast_Move = 0
    Global $iToast_Style = 1 ; $SS_CENTER
    Global $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
    Global $iToast_Header_BkCol = $aRet[0]
    $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
    Global $iToast_Header_Col = $aRet[0]
    Global $iToast_Header_Bold = 0
    Global $iToast_Message_BkCol = $iToast_Header_Col
    Global $iToast_Message_Col = $iToast_Header_BkCol
    Global $iToast_Font_Size = $iDef_Toast_Font_Size
    Global $sToast_Font_Name = $sDef_Toast_Font_Name
    Global $iToast_Timer = 0
    Global $iToast_Start = 0
    Global $fToast_Close = False

    ; #CURRENT# ==========================================================================================================
    ; _Toast_Set:  Sets text justification and optionally colours and font, for _Toast_Show function calls
    ; _Toast_Show: Shows a slice message from the systray
    ; _Toast_Hide: Hides a slice message from the systray
    ; ====================================================================================================================

    ; #INTERNAL_USE_ONLY#=================================================================================================
    ; _Toast_Locate:        Find Systray and determine Toast start position and movement direction
    ; _Toast_Timer_Check:   Checks whether Toast has timed out or closure [X] clicked
    ; _Toast_WM_EVENTS:     Message handler to check if closure [X] clicked
    ; _Toast_GetDefFont: Determine system default MsgBox font and size
    ; ====================================================================================================================
#endregion ; Header
#region ; Functions
    ; #FUNCTION# =========================================================================================================
    ; Name...........: _Toast_Set
    ; Description ...: Sets text justification and optionally colours and font, for _Toast_Show function calls
    ; Syntax.........: _Toast_Set($vJust, [$iHdr_BkCol, [$iHdr_Col, [$iMsg_BkCol, [$iMsg_Col, [$sFont_Size, [$iFont_Name]]]]]])
    ; Parameters ....: $vJust     - 0 = Left justified, 1 = Centred (Default), 2 = Right justified
    ;                                Can use $SS_LEFT, $SS_CENTER, $SS_RIGHT
    ;                                + 4 = Header text in bold
    ;                       >>>>>    Setting this parameter to' Default' will reset ALL parameters to default values     <<<<<
    ;                       >>>>>    All optional parameters default to system MsgBox default values                     <<<<<
    ;                  $iHdr_BkCol - [Optional] The colour for the title bar background
    ;                  $iHdr_Col   - [Optional] The colour for the title bar text
    ;                  $iMsg_BkCol - [Optional] The colour for the message background
    ;                  $iMsg_Col   - [Optional] The colour for the message text
    ;                                Omitting a colour parameter or setting it to -1 leaves it unchanged
    ;                                Setting a colour parameter to Default resets the system colour
    ;                  $iFont_Size - [Optional] The font size in points to use for the Toast
    ;                  $sFont_Name - [Optional] The font to use for the Toast
    ;                       >>>>>    Omitting a font parameter, setting size to -1 or name to "" leaves it unchanged     <<<<<
    ;                       >>>>>    Setting a font parameter to Default resets the system message box font or size      <<<<<
    ; Requirement(s).: v3.3.2.0 or higher - AdlibRegister/Unregister used in _Toast_Show
    ; Return values .: Success - Returns 1
    ;                  Failure - Returns 0 and sets @error to 1 with @extended set to parameter index number
    ; Author ........: Melba23
    ; Example........; Yes
    ;=====================================================================================================================

    Func _Toast_Set($vJust, $iHdr_BkCol = -1, $iHdr_Col = -1, $iMsg_BkCol = -1, $iMsg_Col = -1, $iFont_Size = -1, $sFont_Name = "")

        ; Set parameters
        Switch $vJust
            Case Default
                $iToast_Style = 1; $SS_CENTER
                $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
                $iToast_Header_BkCol = $aRet[0]
                $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
                $iToast_Header_Col = $aRet[0]
                $iToast_Message_BkCol = $iToast_Header_Col
                $iToast_Message_Col = $iToast_Header_BkCol
                $sToast_Font_Name = $sDef_Toast_Font_Name
                $iToast_Font_Size = $iDef_Toast_Font_Size
                Return
            Case 0, 1, 2, 4, 5, 6
                $iToast_Style = $vJust
            Case -1
                ; Do nothing
            Case Else
                Return SetError(1, 1, 0)
        EndSwitch

        Switch $iHdr_BkCol
            Case Default
                $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
                $iToast_Header_BkCol = $aRet[0]
            Case 0 To 0xFFFFFF
                $iToast_Header_BkCol = Int($iHdr_BkCol)
            Case -1
                ; Do nothing
            Case Else
                Return SetError(1, 2, 0)
        EndSwitch

        Switch $iHdr_Col
            Case Default
                $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
                $iToast_Header_Col = $aRet[0]
            Case 0 To 0xFFFFFF
                $iToast_Header_Col = Int($iHdr_Col)
            Case -1
                ; Do nothing
            Case Else
                Return SetError(1, 3, 0)
        EndSwitch

        Switch $iMsg_BkCol
            Case Default
                $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
                $iToast_Message_BkCol = $aRet[0]
            Case 0 To 0xFFFFFF
                $iToast_Message_BkCol = Int($iMsg_BkCol)
            Case -1
                ; Do nothing
            Case Else
                Return SetError(1, 4, 0)
        EndSwitch

        Switch $iMsg_Col
            Case Default
                $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
                $iToast_Message_Col = $aRet[0]
            Case 0 To 0xFFFFFF
                $iToast_Message_Col = Int($iMsg_Col)
            Case -1
                ; Do nothing
            Case Else
                Return SetError(1, 5, 0)
        EndSwitch

        Switch $iFont_Size
            Case Default
                $iToast_Font_Size = $iDef_Toast_Font_Size
            Case 8 To 72
                $iToast_Font_Size = Int($iFont_Size)
            Case -1
                ; Do nothing
            Case Else
                Return SetError(1, 6, 0)
        EndSwitch

        Switch $sFont_Name
            Case Default
                $sToast_Font_Name = $sDef_Toast_Font_Name
            Case ""
                ; Do nothing
            Case Else
                If IsString($sFont_Name) Then
                    $sToast_Font_Name = $sFont_Name
                Else
                    Return SetError(1, 7, 0)
                EndIf
        EndSwitch

        Return 1

    EndFunc   ;==>_Toast_Set

    ; #FUNCTION# =========================================================================================================
    ; Name...........: _Toast_Show
    ; Description ...: Shows a slice message from the systray
    ; Syntax.........: _Toast_Show($vIcon, $sTitle, $sMessage, [$iDelay [, $fWait [, $fRaw]]])
    ; Parameters ....: $vIcon    - 0 - No icon, 8 - UAC, 16 - Stop, 32 - Query, 48 - Exclamation, 64 - Information
    ;                              The $MB_ICON constant can also be used for the last 4 above
    ;                              If set to the name of an exe, the main icon of that exe will be displayed
    ;                              Any other value returns -1, error 1
    ;                  $sTitle   - Text to display on Title bar
    ;                  $sMessage - Text to display in Toast body
    ;                  $iDelay   - The delay in seconds before the Toast retracts or script continues (Default = 0)
    ;                              If negative, an [X] is added to the title bar. Clicking [X] retracts/continues immediately
    ;                  $fWait    - True  - Script waits for delay time before continuing and Toast remains visible
    ;                              False - Script continues and Toast retracts automatically after delay time
    ;                  $fRaw     - True  - Message is not wrapped and Toast expands to show full width
    ;                            - False - Message is wrapped if over max preset Toast width
    ; Requirement(s).: v3.3.1.5 or higher - AdlibRegister/Unregister used in _Toast_Show
    ; Return values .: Success: Returns 2-element array: [Toast width, Toast height]
    ;                  Failure: Returns -1 and sets @error as follows:
    ;                           1 = Toast GUI creation failed
    ;                           2 = Taskbar not found
    ;                           4 = When using Raw, the Toast is too wide for the display
    ;                           3 = StringSize error
    ; Author ........: Melba23, based on some original code by GioVit for the Toast
    ; Notes .........; Any visible Toast is retracted by a subsequent _Toast_Hide or _Toast_Show, or clicking a visible [X]
    ; Example........; Yes
    ;=====================================================================================================================

    Func _Toast_Show($vIcon, $sTitle, $sMessage, $iDelay = 0, $fWait = True, $fRaw = False)

        ; Store current GUI mode and set Message mode
        Local $nOldOpt = Opt('GUIOnEventMode', 0)

        ; Retract any Toast already in place
        If $hToast_Handle <> 0 Then _Toast_Hide()

        ; Reset non-reacting Close [X] ControlID
        $hToast_Close_X = 9999

        ; Set default auto-sizing Toast widths
        Local $iToast_Width_max = 500
        Local $iToast_Width_min = 150

        ; Check for icon
        Local $iIcon_Style = 0
        Local $iIcon_Reduction = 50
        Local $sDLL = "user32.dll"
        If StringIsDigit($vIcon) Then
            Switch $vIcon
                Case 0
                    $iIcon_Reduction = 0
                Case 8
                    $sDLL = "imageres.dll"
                    $iIcon_Style = 78
                Case 16 ; Stop
                    $iIcon_Style = -4
                Case 32 ; Query
                    $iIcon_Style = -3
                Case 48 ; Exclam
                    $iIcon_Style = -2
                Case 64 ; Info
                    $iIcon_Style = -5
                Case Else
                    $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
                    Return SetError(1, 0, -1)
            EndSwitch
        Else
            $sDLL = $vIcon
            $iIcon_Style = 0
        EndIf

        ; Determine max message width
        Local $iMax_Label_Width = $iToast_Width_max - 20 - $iIcon_Reduction
        If $fRaw = True Then $iMax_Label_Width = 0

        ; Get message label size
        Local $aLabel_Pos = _StringSize($sMessage, $iToast_Font_Size, Default, Default, $sToast_Font_Name, $iMax_Label_Width)
        If @error Then
            $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
            Return SetError(3, 0, -1)
        EndIf

        ; Reset text to match rectangle
        $sMessage = $aLabel_Pos[0]

        ;Set line height for this font
        Local $iLine_Height = $aLabel_Pos[1]

        ; Set label size
        Local $iLabelwidth = $aLabel_Pos[2]
        Local $iLabelheight = $aLabel_Pos[3]

        ; Set Toast size
        Local $iToast_Width = $iLabelwidth + 20 + $iIcon_Reduction
        ; Check if Toast will fit on screen
        If $iToast_Width > @DesktopWidth - 20 Then
            $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
            Return SetError(4, 0, -1)
        EndIf
        ; Increase if below min size
        If $iToast_Width < $iToast_Width_min + $iIcon_Reduction Then
            $iToast_Width = $iToast_Width_min + $iIcon_Reduction
            $iLabelwidth = $iToast_Width_min - 20
        EndIf

        ; Set title bar height - with minimum for [X]
        Local $iTitle_Height = 0
        If $sTitle = "" Then
            If $iDelay < 0 Then $iTitle_Height = 6
        Else
            $iTitle_Height = $iLine_Height + 2
            If $iDelay < 0 Then
                If $iTitle_Height < 17 Then $iTitle_Height = 17
            EndIf
        EndIf

        ; Set Toast height as label height + title bar + bottom margin
        Local $iToast_Height = $iLabelheight + $iTitle_Height + 20
        ; Ensure enough room for icon if displayed
        If $iIcon_Reduction Then
            If $iToast_Height < $iTitle_Height + 42 Then $iToast_Height = $iTitle_Height + 47
        EndIf

        ; Get Toast starting position and direction
        Local $aToast_Data = _Toast_Locate($iToast_Width, $iToast_Height)

        ; Create Toast slice with $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW style and $WS_EX_TOPMOST extended style
        $hToast_Handle = GUICreate("", $iToast_Width, $iToast_Height, $aToast_Data[0], $aToast_Data[1], 0x80880000, BitOR(0x00000080, 0x00000008))
        If @error Then
            $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
            Return SetError(1, 0, -1)
        EndIf
        GUISetFont($iToast_Font_Size, Default, Default, $sToast_Font_Name)
        GUISetBkColor($iToast_Message_BkCol)

        ; Set centring parameter
        Local $iLabel_Style = 0 ; $SS_LEFT
        If BitAND($iToast_Style, 1) = 1 Then
            $iLabel_Style = 1 ; $SS_CENTER
        ElseIf BitAND($iToast_Style, 2) = 2 Then
            $iLabel_Style = 2 ; $SS_RIGHT
        EndIf

        ; Check installed fonts
        Local $sX_Font = "WingDings"
        Local $sX_Char = "x"
        Local $i = 1
        While 1
            Local $sInstalled_Font = RegEnumVal("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionFonts", $i)
            If @error Then ExitLoop
            If StringInStr($sInstalled_Font, "WingDings 2") Then
                $sX_Font = "WingDings 2"
                $sX_Char = "T"
            EndIf
            $i += 1
        WEnd

        ; Create title bar if required
        If $sTitle <> "" Then

            ; Create disabled background strip
            GUICtrlCreateLabel("", 0, 0, $iToast_Width, $iTitle_Height)
            GUICtrlSetBkColor(-1, $iToast_Header_BkCol)
            GUICtrlSetState(-1, 128) ; $GUI_DISABLE

            ; Set title bar width to offset text
            Local $iTitle_Width = $iToast_Width - 10

            ; Create closure [X] if needed
            If $iDelay < 0 Then
                ; Create [X]
                Local $iX_YCoord = Int(($iTitle_Height - 17) / 2)
                $hToast_Close_X = GUICtrlCreateLabel($sX_Char, $iToast_Width - 18, $iX_YCoord, 17, 17)
                GUICtrlSetFont(-1, 14, Default, Default, $sX_Font)
                GUICtrlSetBkColor(-1, -2) ; $GUI_BKCOLOR_TRANSPARENT
                GUICtrlSetColor(-1, $iToast_Header_Col)
                ; Reduce title bar width to allow [X] to activate
                $iTitle_Width -= 18
            EndIf

            ; Create Title label with bold text, centred vertically in case bar is higher than line
            GUICtrlCreateLabel($sTitle, 10, 0, $iTitle_Width, $iTitle_Height, 0x0200) ; $SS_CENTERIMAGE
            GUICtrlSetBkColor(-1, $iToast_Header_BkCol)
            GUICtrlSetColor(-1, $iToast_Header_Col)
            If BitAND($iToast_Style, 4) = 4 Then GUICtrlSetFont(-1, $iToast_Font_Size, 600)

        Else

            If $iDelay < 0 Then
                ; Only need [X]
                $hToast_Close_X = GUICtrlCreateLabel($sX_Char, $iToast_Width - 18, 0, 17, 17)
                GUICtrlSetFont(-1, 14, Default, Default, $sX_Font)
                GUICtrlSetBkColor(-1, -2) ; $GUI_BKCOLOR_TRANSPARENT
                GUICtrlSetColor(-1, $iToast_Message_Col)
            EndIf

        EndIf

        ; Create icon
        If $iIcon_Reduction Then GUICtrlCreateIcon($sDLL, $iIcon_Style, 10, 10 + $iTitle_Height)

        ; Create Message label
        GUICtrlCreateLabel($sMessage, 10 + $iIcon_Reduction, 10 + $iTitle_Height, $iLabelwidth, $iLabelheight)
        GUICtrlSetStyle(-1, $iLabel_Style)
        If $iToast_Message_Col <> Default Then GUICtrlSetColor(-1, $iToast_Message_Col)

        ; Slide Toast Slice into view from behind systray and activate
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hToast_Handle, "int", 1000, "long", $aToast_Data[2])

        ; Activate Toast without stealing focus
        GUISetState(@SW_SHOWNOACTIVATE, $hToast_Handle)

        ; If script is to pause
        If $fWait = True Then

            ; Begin timeout counter
            Local $iTimeout_Begin = TimerInit()

            ; Wait for timeout or closure
            While 1
                If GUIGetMsg() = $hToast_Close_X Or TimerDiff($iTimeout_Begin) / 1000 >= Abs($iDelay) Then ExitLoop
            WEnd

            ; If script is to continue and delay has been set
        ElseIf Abs($iDelay) > 0 Then

            ; Store timer info
            $iToast_Timer = Abs($iDelay * 1000)
            $iToast_Start = TimerInit()

            ; Register Adlib function to run timer
            AdlibRegister("_Toast_Timer_Check", 100)
            ; Register message handler to check for [X] click
            GUIRegisterMsg(0x0021, "_Toast_WM_EVENTS") ; $WM_MOUSEACTIVATE

        EndIf

        ; Reset original mode
        $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)

        ; Create array to return Toast dimensions
        Local $aToast_Data[3] = [$iToast_Width, $iToast_Height, $iLine_Height]

        Return $aToast_Data

    EndFunc   ;==>_Toast_Show

    ; #FUNCTION# ========================================================================================================
    ; Name...........: _Toast_Hide
    ; Description ...: Hides a slice message from the systray
    ; Syntax.........: _Toast_Hide()
    ; Requirement(s).: v3.3.1.5 or higher - AdlibRegister used in _Toast_Show
    ; Return values .: Success: Returns 0
    ;                  Failure: If Toast does not exist returns -1 and sets @error to 1
    ; Author ........: Melba23
    ; Example........; Yes
    ;=====================================================================================================================

    Func _Toast_Hide()

        ; If no Toast to hide, return
        If $hToast_Handle = 0 Then Return SetError(1, 0, -1)

        ; Slide Toast back behind systray
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hToast_Handle, "int", 500, "long", $iToast_Move)

        ; Delete Toast slice
        GUIDelete($hToast_Handle)

        ; Set flag for "no Toast"
        $hToast_Handle = 0

    EndFunc   ;==>_Toast_Hide
#endregion ; Functions
#region ; Internal
    ; #INTERNAL_USE_ONLY#============================================================================================================
    ; Name...........: _Toast_Locate
    ; Description ...: Find Systray and determine Toast start position and movement direction
    ; Syntax ........: _Toast_Locate($iToast_Width, $iToast_Height)
    ; Parameters ....: $iToast_Width  - required width of slice
    ;                  $iToast_Height - required height of slice
    ; Author ........: Melba23
    ; Modified.......:
    ; Remarks .......: This function is used internally by _Toast_Show
    ; ===============================================================================================================================
    Func _Toast_Locate($iToast_Width, $iToast_Height)

        ; Define return array
        Local $aToast_Data[3], $tWorkArea = DllStructCreate("struct;long Left;long Top;long Right;long Bottom;endstruct")

        ; Check if Taskbar is hidden
        Local $aRet = DllCall('shell32.dll', 'uint', 'SHAppBarMessage', 'dword', 0x00000004, 'ptr*', 0) ; $ABM_GETSTATE
        If BitAND($aRet[0], 0x01) Then

            ; Find hidden taskbar
            Local $iPrevMode = Opt("WinTitleMatchMode", 4)
            Local $aTray_Pos = WinGetPos("[CLASS:Shell_TrayWnd]")
            Opt("WinTitleMatchMode", $iPrevMode)
            ; If error in finding systray
            If Not IsArray($aTray_Pos) Then Return SetError(2, 0, -1)

            ; Determine direction of Toast motion and starting position
            If $aTray_Pos[1] > 0 Then
                $iToast_Move = 0x00050004 ; $AW_SLIDE_OUT_BOTTOM
                $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
                $aToast_Data[1] = $aTray_Pos[1] - $iToast_Height - 2
                $aToast_Data[2] = 0x00040008 ; $AW_SLIDE_IN_BOTTOM
            Elseif $aTray_Pos[0] > 0 Then
                $iToast_Move = 0x00050001 ; $AW_SLIDE_OUT_RIGHT
                $aToast_Data[0] = $aTray_Pos[0] - $iToast_Width -2
                $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
                $aToast_Data[2] = 0x00040002 ; $AW_SLIDE_IN_RIGHT
            ElseIf $aTray_Pos[2] > @DesktopWidth - 70 Then
                $iToast_Move = 0x00050008 ; $AW_SLIDE_OUT_TOP
                $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
                $aToast_Data[1] = $aTray_Pos[1] + $aTray_Pos[3]
                $aToast_Data[2] = 0x00040004 ; $AW_SLIDE_IN_TOP
            ElseIf $aTray_Pos[3] >= @DesktopHeight Then
                $iToast_Move = 0x00050002 ; $AW_SLIDE_OUT_LEFT
                $aToast_Data[0] = $aTray_Pos[0] + $aTray_Pos[2]
                $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
                $aToast_Data[2] = 0x00040001 ; $AW_SLIDE_IN_LEFT
            EndIf

        Else

            ; Determine available work area ; $SPI_GETWORKAREA = 48
            DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", 48, "uint", 0, "ptr", DllStructGetPtr($tWorkArea), "uint", 0)
            If @error Then Return SetError(2, 0, -1)
            Local $aWorkArea[4] = [DllStructGetData($tWorkArea, "Left"), DllStructGetData($tWorkArea, "Top"), _
                    DllStructGetData($tWorkArea, "Right"), DllStructGetData($tWorkArea, "Bottom")]

            ; Determine direction of Toast motion and starting position
            If $aWorkArea[3] <> @DesktopHeight Then
                $iToast_Move = 0x00050004 ; $AW_SLIDE_OUT_BOTTOM
                $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
                $aToast_Data[1] = $aWorkArea[3] - $iToast_Height - 2
                $aToast_Data[2] = 0x00040008 ; $AW_SLIDE_IN_BOTTOM
            ElseIf $aWorkArea[2] <> @DesktopWidth Then
                $iToast_Move = 0x00050001 ; $AW_SLIDE_OUT_RIGHT
                $aToast_Data[0] = $aWorkArea[2] - $iToast_Width - 2
                $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
                $aToast_Data[2] = 0x00040002 ; $AW_SLIDE_IN_RIGHT
            ElseIf $aWorkArea[1] <> 0 Then
                $iToast_Move = 0x00050008 ; $AW_SLIDE_OUT_TOP
                $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
                $aToast_Data[1] = $aWorkArea[1]
                $aToast_Data[2] = 0x00040004 ; $AW_SLIDE_IN_TOP
            ElseIf $aWorkArea[0] <> 0 Then
                $iToast_Move = 0x00050002 ; $AW_SLIDE_OUT_LEFT
                $aToast_Data[0] = $aWorkArea[0]
                $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
                $aToast_Data[2] = 0x00040001 ; $AW_SLIDE_IN_LEFT
            EndIf

        EndIf

        Return $aToast_Data

    EndFunc   ;==>_Toast_Locate

    ; #INTERNAL_USE_ONLY#============================================================================================================
    ; Name...........: _Toast_Timer_Check
    ; Description ...: Checks whether Toast has timed out or closure [X] clicked
    ; Syntax ........: _Toast_Locate($iToast_Width, $iToast_Height)
    ; Author ........: Melba23
    ; Modified.......:
    ; Remarks .......: This function is used internally by _Toast_Show if the Wait parameter is set to False
    ; ===============================================================================================================================
    Func _Toast_Timer_Check()

        ; Return if timeout not elapsed and [X] not clicked
        If TimerDiff($iToast_Start) < $iToast_Timer And $fToast_Close = False Then Return

        ; Unregister message handler
        GUIRegisterMsg(0x0021, "") ; $WM_MOUSEACTIVATE
        ; Unregister this function
        AdlibUnRegister("_Toast_Timer_Check")
        ; Reset flag
        $fToast_Close = False
        ; Retract slice
        _Toast_Hide()

    EndFunc   ;==>_Toast_Timer_Check

    ; #INTERNAL_USE_ONLY#============================================================================================================
    ; Name...........: _Toast_WM_EVENTS
    ; Description ...: Message handler to check if closure [X] clicked
    ; Author ........: Melba23
    ; Modified.......:
    ; Remarks .......: This function is used internally by _Toast_Show if the Wait parameter is set to False
    ; ===============================================================================================================================
    Func _Toast_WM_EVENTS($hWnd, $Msg, $wParam, $lParam)

        #forceref $wParam, $lParam
        If $hWnd = $hToast_Handle Then
            If $Msg = 0x0021 Then ; $WM_MOUSEACTIVATE
                ; Check mouse position
                Local $aPos = GUIGetCursorInfo($hToast_Handle)
                If $aPos[4] = $hToast_Close_X Then $fToast_Close = True
            EndIf
        EndIf
        Return 'GUI_RUNDEFMSG'

    EndFunc   ;==>_Toast_WM_EVENTS

    ; #INTERNAL_USE_ONLY#============================================================================================================
    ; Name...........: _Toast_GetDefFont
    ; Description ...: Determine system default MsgBox font and size
    ; Syntax ........: _Toast_GetDefFont($iData)
    ; Parameters ....: $iData - 0 = Font point size, 1 = Font name
    ; Author ........: Melba23
    ; Modified.......:
    ; Remarks .......: This function is used internally by _Toast functions
    ; ===============================================================================================================================
    Func _Toast_GetDefFont($iData)

        ; Get default system font data
        Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]")
        DllStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS))
        DllCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0)
        ; Read font data for MsgBox font
        Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DllStructGetPtr($tNONCLIENTMETRICS, 15))
        Switch $iData
            Case 0
                ; Font size as integer
                Return Int((Abs(DllStructGetData($tLOGFONT, 1)) + 1) * .75)
            Case 1
                ; Font name
                Return DllStructGetData($tLOGFONT, 14)
        EndSwitch

    EndFunc   ;==>_Toast_GetDefFont
#endregion ; Internal

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I didn't think that function I posted would be any use to you.

Edit: I'll try and test tomorrow.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

guinness,

On the contrary. I had been searching for something like that and only found the registry key. Thanks - and I will add you into the credits when I release it. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

OK, thanks.

I edited my last post by the way, if I get time tonight I will test otherwise it will be tomorrow morning.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Melba23,

I've found no problems on Windows 7 x64 and I did the exact same tests.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

With my program using Toast beta it didn't show toast at all. It must have positioned off screen.

This mod of Toast_Locate works for me. I move task bar to top left bottom right and it seemed to accommodate it. For making space for RocketDock I set the work area manually.

It uses _GetDesktopWorkArea as shown here:

;AutoIt3 Forum code to get Desktop WorkArea
Func _GetDesktopWorkArea(ByRef $left, ByRef $top, ByRef $right, ByRef $bottom)
Local Const $SPI_SETWORKAREA = 47
Local Const $SPI_GETWORKAREA = 48
Local $tRcWA = DllStructCreate($tagRECT)
If _WinAPI_SystemParametersInfo($SPI_GETWORKAREA, 0, DllStructGetPtr($tRcWA)) Then
$left = DllStructGetData($tRcWA, "Left")
$right = DllStructGetData($tRcWA, "Right")
$top = DllStructGetData($tRcWA, "Top")
$bottom = DllStructGetData($tRcWA, "Bottom")
Return True
EndIf
Return False
EndFunc   ;==>_GetDesktopWorkArea

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Toast_Locate
; Description ...: Find Systray and determine Toast start position and movement direction
; Syntax ........: _Toast_Locate($iToast_Width, $iToast_Height)
; Parameters ....: $iToast_Width  - required width of slice
;                 $iToast_Height - required height of slice
; Author ........: Melba23, based on some original code by GioVit
; Modified.......:
; Remarks .......: This function is used internally by _Toast_Show
; ===============================================================================================================================
Func _Toast_Locate($iToast_Width, $iToast_Height)
; Define return array
Local $aToast_Data[3]
; Find systray
Local $iPrevMode = Opt("WinTitleMatchMode", 4)
    Local $aTray_Pos = WinGetPos("[CLASS:Shell_TrayWnd]")
    Opt("WinTitleMatchMode", $iPrevMode)

; If error in finding systray
If Not IsArray($aTray_Pos) Then Return SetError(2, 0, -1)
; Begin MilesAhead Mod
Local $l, $t, $r, $b
    _GetDesktopWorkArea($l,$t,$r,$b)
; End MilesAhead Mod
; Determine direction of Toast motion and starting position
If $aTray_Pos[1] > 0 Then
        $iToast_Move = 0x00050004 ; $AW_SLIDE_OUT_BOTTOM
        $aToast_Data[0] = @DesktopWidth - $iToast_Width
        ;$aToast_Data[1] = $aTray_Pos[1] - $iToast_Height
$aToast_Data[1] = $b - $iToast_Height   ; MilesAhead Mod
$aToast_Data[2] = 0x00040008 ; $AW_SLIDE_IN_BOTTOM
    Elseif $aTray_Pos[0] > 0 Then
        $iToast_Move = 0x00050001 ; $AW_SLIDE_OUT_RIGHT
        ;$aToast_Data[0] = $aTray_Pos[0] - $iToast_Width
$aToast_Data[0] = $r - $iToast_Width ; MilesAhead Mod
        $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
$aToast_Data[2] = 0x00040002 ; $AW_SLIDE_IN_RIGHT
    ElseIf $aTray_Pos[2] = @DesktopWidth Then
        $iToast_Move = 0x00050008 ; $AW_SLIDE_OUT_TOP
        $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
        $aToast_Data[1] = $t  ; MilesAhead Mod
$aToast_Data[2] = 0x00040004 ; $AW_SLIDE_IN_TOP
    ElseIf $aTray_Pos[3] = @DesktopHeight Then
        $iToast_Move = 0x00050002 ; $AW_SLIDE_OUT_LEFT
        ;$aToast_Data[0] = $aTray_Pos[0] + $aTray_Pos[2]
$aToast_Data[0] = $l  ; MilesAhead Mod
        $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
$aToast_Data[2] = 0x00040001 ; $AW_SLIDE_IN_LEFT
    EndIf
Return $aToast_Data
EndFunc ; => _Toast_Locate
[/code]
Edited by MilesAhead
Link to comment
Share on other sites

  • Moderators

MilesAhead,

Thanks for the code. I will compare it with mine and see what is different (and therefore what I messed up!). :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

MilesAhead,

Thanks for the code. I will compare it with mine and see what is different (and therefore what I messed up!). :)

M23

Sure thing. Also I hope you are prepared to take responsibility because seeing how you animate windows I've been compelled to go back and add fades and slides to some of my old programs. ;)

Link to comment
Share on other sites

  • Moderators

MilesAhead,

Our respective codes give identical results (other than some minor adjustments I have introduced to cope with Classic mode) for the positioning of the Toast when the TaskBar is visible - which you say yours is. So I am very surprised by the fact that you say that the Toasts do not appear when you run my beta code above. The only explanation I can come up with is that the _Toast_Show fuction is returning an error and so not creating the Toast - could you please check if that is the case. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I've done a bit more testing since the last time and still can't replicate any problem(s), so I don't believe it's your code.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I checked for error returns before going to the trouble of adding my code. It returned no errors.

I just did this:

;#include <Toast.au3>

#include <Toast_Beta.au3>

recompiled and ran it. It did not show the toast.

I always have AutoHide disabled. Maybe that's the difference?

edit: just uncommented <Toast.au3> with my changes and recompiled. It shows. Don't know what else to tell you.

edit2: It's been my experience that it doesn't matter if Taskbar is showing or not showing. If AutoHide is enabled, the system ignores the Work Area. That's why on all my utilities that place Explorer windows leaving a gap for the taskbar, rocketdock, whatever, I note that AutoHide must be disabled. I tried getting change notifications etc.. Just doesn't work. The only change notification you can count on is screen res change.

I'm using Windows Seven. Perhaps you are on XP?

Edited by MilesAhead
Link to comment
Share on other sites

  • Moderators

MilesAhead,

I always have AutoHide disabled

Clutching at straws here, but....

Do you mean that you have the "Auto-hide the taskbar" checkbox in the Taskbar properties dialog unchecked - or do you do something more complex? :)

And could you please post the complete script you are using. Rest assured I do not disbelieve your results at all, but perhaps I can see something there that might give me a clue. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I just mean the AutoHide the Taskbar is never checked. Also I use a double height Taskbar if that makes a difference. (As I mentioned before, I use a program to set the work area to make room for RocketDock, but I didn't employ that when testing moving the taskbar to top, left, right, bottom. I just let the system set the work area.)

btw when I do my delay routine, I check that the Toast handle is created. If not, I just show a tooltip delay for the tray icon. It's not showing the tooltip delay. So that makes me think the window is off screen. But here's Toast with my mods:

#include-once
; Begin MilesAhead Mod
#include <MilesAheadMisc.au3>
; End MilesAhead Mod
; #INDEX# ============================================================================================================
; Title .........: Toast
; AutoIt Version : 3.3.2.0 - uses AdlibRegister/Unregister
; Language ......: English
; Description ...: Show and hides slice messages from the systray in user defined colours and fonts
; Author(s) .....: Melba23.  Credit to GioVit (tray location)
; ====================================================================================================================
;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
; #INCLUDES# =========================================================================================================
#include <StringSize.au3>
; #GLOBAL VARIABLES# =================================================================================================
Global $iDef_Toast_Font_Size   = _Toast_GetDefFont(0)
Global $sDef_Toast_Font_Name   = _Toast_GetDefFont(1)
Global $hToast_Handle       = 0
Global $hToast_Close_X     = 9999
Global $iToast_Move       = 0
Global $iToast_Style         = 1 ; $SS_CENTER
Global $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
Global $iToast_Header_BkCol  = $aRet[0]
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
Global $iToast_Header_Col   = $aRet[0]
Global $iToast_Header_Bold   = 0
Global $iToast_Message_BkCol = $iToast_Header_Col
Global $iToast_Message_Col   = $iToast_Header_BkCol
Global $iToast_Font_Size     = $iDef_Toast_Font_Size
Global $sToast_Font_Name     = $sDef_Toast_Font_Name
Global $iToast_Timer         = 0
Global $iToast_Start         = 0
Global $fToast_Close         = False
; #CURRENT# ==========================================================================================================
; _Toast_Set:  Sets text justification and optionally colours and font, for _Toast_Show function calls
; _Toast_Show: Shows a slice message from the systray
; _Toast_Hide: Hides a slice message from the systray
; ====================================================================================================================
; #INTERNAL_USE_ONLY#=================================================================================================
; _Toast_Locate:        Find Systray and determine Toast start position and movement direction
; _Toast_Timer_Check:   Checks whether Toast has timed out or closure [X] clicked
; _Toast_WM_EVENTS:  Message handler to check if closure [X] clicked
; _Toast_GetDefFont: Determine system default MsgBox font and size
; ====================================================================================================================
; #FUNCTION# =========================================================================================================
; Name...........: _Toast_Set
; Description ...: Sets text justification and optionally colours and font, for _Toast_Show function calls
; Syntax.........: _Toast_Set($vJust, [$iHdr_BkCol, [$iHdr_Col, [$iMsg_BkCol, [$iMsg_Col, [$sFont_Size, [$iFont_Name]]]]]])
; Parameters ....: $vJust    - 0 = Left justified, 1 = Centred (Default), 2 = Right justified
;                               Can use $SS_LEFT, $SS_CENTER, $SS_RIGHT
;                               + 4 = Header text in bold
;                      >>>>>    Setting this parameter to' Default' will reset ALL parameters to default values  <<<<<
;                      >>>>>    All optional parameters default to system MsgBox default values                  <<<<<
;                 $iHdr_BkCol - [Optional] The colour for the title bar background
;                 $iHdr_Col   - [Optional] The colour for the title bar text
;                 $iMsg_BkCol - [Optional] The colour for the message background
;                 $iMsg_Col   - [Optional] The colour for the message text
;                               Omitting a colour parameter or setting it to -1 leaves it unchanged
;                               Setting a colour parameter to Default resets the system colour
;                 $iFont_Size - [Optional] The font size in points to use for the Toast
;                 $sFont_Name - [Optional] The font to use for the Toast
;                      >>>>>    Omitting a font parameter, setting size to -1 or name to "" leaves it unchanged  <<<<<
;                      >>>>>    Setting a font parameter to Default resets the system message box font or size    <<<<<
; Requirement(s).: v3.3.2.0 or higher - AdlibRegister/Unregister used in _Toast_Show
; Return values .: Success - Returns 1
;                 Failure - Returns 0 and sets @error to 1 with @extended set to parameter index number
; Author ........: Melba23
; Example........; Yes
;=====================================================================================================================
Func _Toast_Set($vJust, $iHdr_BkCol = -1, $iHdr_Col = -1, $iMsg_BkCol = -1, $iMsg_Col = -1, $iFont_Size = -1, $sFont_Name = "")
; Set parameters
Switch $vJust
  Case Default
   $iToast_Style         = 1; $SS_CENTER
   $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
   $iToast_Header_BkCol  = $aRet[0]
   $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
   $iToast_Header_Col   = $aRet[0]
   $iToast_Message_BkCol = $iToast_Header_Col
   $iToast_Message_Col   = $iToast_Header_BkCol
   $sToast_Font_Name     = $sDef_Toast_Font_Name
   $iToast_Font_Size     = $iDef_Toast_Font_Size
   Return
  Case 0, 1, 2, 4, 5, 6
   $iToast_Style = $vJust
  Case -1
   ; Do nothing
  Case Else
   Return SetError(1, 1, 0)
EndSwitch
Switch $iHdr_BkCol
  Case Default
   $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
   $iToast_Header_BkCol  = $aRet[0]
  Case 0 To 0xFFFFFF
   $iToast_Header_BkCol = Int($iHdr_BkCol)
        Case -1
   ; Do nothing
  Case Else
   Return SetError(1, 2, 0)
EndSwitch
Switch $iHdr_Col
  Case Default
   $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
   $iToast_Header_Col  = $aRet[0]
  Case 0 To 0xFFFFFF
   $iToast_Header_Col = Int($iHdr_Col)
        Case -1
   ; Do nothing
  Case Else
   Return SetError(1, 3, 0)
EndSwitch
Switch $iMsg_BkCol
  Case Default
   $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
   $iToast_Message_BkCol  = $aRet[0]
  Case 0 To 0xFFFFFF
   $iToast_Message_BkCol = Int($iMsg_BkCol)
        Case -1
   ; Do nothing
  Case Else
   Return SetError(1, 4, 0)
EndSwitch
Switch $iMsg_Col
  Case Default
   $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
   $iToast_Message_Col  = $aRet[0]
  Case 0 To 0xFFFFFF
   $iToast_Message_Col = Int($iMsg_Col)
        Case -1
   ; Do nothing
  Case Else
   Return SetError(1, 5, 0)
EndSwitch
Switch $iFont_Size
  Case Default
   $iToast_Font_Size = $iDef_Toast_Font_Size
  Case 8 To 72
   $iToast_Font_Size = Int($iFont_Size)
        Case -1
   ; Do nothing
  Case Else
   Return SetError(1, 6, 0)
EndSwitch
Switch $sFont_Name
  Case Default
   $sToast_Font_Name = $sDef_Toast_Font_Name
  Case ""
   ; Do nothing
  Case Else
   If IsString($sFont_Name) Then
    $sToast_Font_Name = $sFont_Name
   Else
    Return SetError(1, 7, 0)
   EndIf
EndSwitch
Return 1
EndFunc ; => _Toast_Set
; #FUNCTION# =========================================================================================================
; Name...........: _Toast_Show
; Description ...: Shows a slice message from the systray
; Syntax.........: _Toast_Show($vIcon, $sTitle, $sMessage, [$iDelay [, $fWait [, $fRaw]]])
; Parameters ....: $vIcon   - 0 - No icon, 8 - UAC, 16 - Stop, 32 - Query, 48 - Exclamation, 64 - Information
;                             The $MB_ICON constant can also be used for the last 4 above
;                             If set to the name of an exe, the main icon of that exe will be displayed
;                             Any other value returns -1, error 1
;                 $sTitle   - Text to display on Title bar
;                 $sMessage - Text to display in Toast body
;                 $iDelay   - The delay in seconds before the Toast retracts or script continues (Default = 0)
;                             If negative, an [X] is added to the title bar. Clicking [X] retracts/continues immediately
;                 $fWait    - True  - Script waits for delay time before continuing and Toast remains visible
;                             False - Script continues and Toast retracts automatically after delay time
;                 $fRaw  - True  - Message is not wrapped and Toast expands to show full width
;                           - False - Message is wrapped if over max preset Toast width
; Requirement(s).: v3.3.1.5 or higher - AdlibRegister/Unregister used in _Toast_Show
; Return values .: Success: Returns 2-element array: [Toast width, Toast height]
;                 Failure: Returns -1 and sets @error as follows:
;                          1 = Toast GUI creation failed
;                          2 = Taskbar not found
;                          4 = When using Raw, the Toast is too wide for the display
;                          3 = StringSize error
; Author ........: Melba23, based on some original code by GioVit for the Toast
; Notes .........; Any visible Toast is retracted by a subsequent _Toast_Hide or _Toast_Show, or clicking a visible [X]
; Example........; Yes
;=====================================================================================================================
Func _Toast_Show($vIcon, $sTitle, $sMessage, $iDelay = 0, $fWait = True, $fRaw = False)
; Store current GUI mode and set Message mode
Local $nOldOpt = Opt('GUIOnEventMode', 0)
; Retract any Toast already in place
If $hToast_Handle <> 0 Then _Toast_Hide()
; Reset non-reacting Close [X] ControlID
$hToast_Close_X = 9999
; Set default auto-sizing Toast widths
Local $iToast_Width_max = 500
Local $iToast_Width_min = 150
; Check for icon
Local $iIcon_Style = 0
Local $iIcon_Reduction = 50
Local $sDLL = "user32.dll"
If StringIsDigit($vIcon) Then
  Switch $vIcon
   Case 0
    $iIcon_Reduction = 0
   Case 8
    $sDLL = "imageres.dll"
    $iIcon_Style = 78
   Case 16 ; Stop
    $iIcon_Style = -4
   Case 32 ; Query
    $iIcon_Style = -3
   Case 48 ; Exclam
    $iIcon_Style = -2
   Case 64 ; Info
    $iIcon_Style = -5
   Case Else
    $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
    Return SetError(1, 0, -1)
  EndSwitch
Else
  $sDLL = $vIcon
  $iIcon_Style = 0
EndIf
; Determine max message width
Local $iMax_Label_Width = $iToast_Width_max - 20 - $iIcon_Reduction
If $fRaw = True Then $iMax_Label_Width = 0
; Get message label size
Local $aLabel_Pos = _StringSize($sMessage, $iToast_Font_Size, Default, Default, $sToast_Font_Name, $iMax_Label_Width)
If @error Then
  $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
  Return SetError(3, 0, -1)
EndIf
; Reset text to match rectangle
$sMessage = $aLabel_Pos[0]
;Set line height for this font
Local $iLine_Height = $aLabel_Pos[1]
; Set label size
Local $iLabelwidth  = $aLabel_Pos[2]
Local $iLabelheight = $aLabel_Pos[3]
; Set Toast size
Local $iToast_Width = $iLabelwidth + 20 + $iIcon_Reduction
; Check if Toast will fit on screen
If $iToast_Width > @DesktopWidth - 20 Then
  $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
  Return SetError(4, 0, -1)
EndIf
; Increase if below min size
If $iToast_Width < $iToast_Width_min + $iIcon_Reduction Then
  $iToast_Width = $iToast_Width_min + $iIcon_Reduction
  $iLabelwidth  = $iToast_Width_min - 20
EndIf
; Set title bar height - with minimum for [X]
Local $iTitle_Height = 0
If $sTitle = "" Then
  If $iDelay < 0 Then $iTitle_Height = 6
Else
  $iTitle_Height = $iLine_Height + 2
  If $iDelay < 0 Then
   If $iTitle_Height < 17 Then $iTitle_Height = 17
  EndIf
EndIf
; Set Toast height as label height + title bar + bottom margin
Local $iToast_Height = $iLabelheight + $iTitle_Height + 20
; Ensure enough room for icon if displayed
If $iIcon_Reduction Then
  If $iToast_Height < $iTitle_Height + 42 Then $iToast_Height = $iTitle_Height + 47
EndIf
; Get Toast starting position and direction
Local $aToast_Data = _Toast_Locate($iToast_Width, $iToast_Height)
; Create Toast slice with $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW style and $WS_EX_TOPMOST extended style
$hToast_Handle = GUICreate("", $iToast_Width, $iToast_Height, $aToast_Data[0], $aToast_Data[1], 0x80880000, BitOr(0x00000080, 0x00000008))
If @error Then
  $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
  Return SetError(1, 0, -1)
EndIf
  GUISetFont($iToast_Font_Size, Default, Default, $sToast_Font_Name)
  GUISetBkColor($iToast_Message_BkCol)
; Set centring parameter
Local $iLabel_Style = 0 ; $SS_LEFT
If BitAND($iToast_Style, 1) = 1 Then
  $iLabel_Style = 1 ; $SS_CENTER
ElseIf BitAND($iToast_Style, 2) = 2 Then
  $iLabel_Style = 2 ; $SS_RIGHT
EndIf
; Check installed fonts
Local $sX_Font = "WingDings"
Local $sX_Char = "x"
Local $i = 1
While 1
  Local $sInstalled_Font = RegEnumVal("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionFonts", $i)
  If @error Then ExitLoop
  If StringInStr($sInstalled_Font, "WingDings 2") Then
   $sX_Font = "WingDings 2"
   $sX_Char = "T"
  EndIf
  $i += 1
WEnd
; Create title bar if required
If $sTitle <> "" Then
  ; Create disabled background strip
  GUICtrlCreateLabel("", 0, 0, $iToast_Width, $iTitle_Height)
   GUICtrlSetBkColor(-1, $iToast_Header_BkCol)
   GUICtrlSetState(-1, 128) ; $GUI_DISABLE
  ; Set title bar width to offset text
  Local $iTitle_Width = $iToast_Width - 10
  ; Create closure [X] if needed
  If $iDelay < 0 Then
   ; Create [X]
   Local $iX_YCoord = Int(($iTitle_Height - 17) / 2)
   $hToast_Close_X = GUICtrlCreateLabel($sX_Char, $iToast_Width - 18, $iX_YCoord, 17, 17)
    GUICtrlSetFont(-1, 14, Default, Default, $sX_Font)
    GUICtrlSetBkColor(-1, -2) ; $GUI_BKCOLOR_TRANSPARENT
    GUICtrlSetColor(-1, $iToast_Header_Col)
   ; Reduce title bar width to allow [X] to activate
   $iTitle_Width -= 18
  EndIf
  ; Create Title label with bold text, centred vertically in case bar is higher than line
  GUICtrlCreateLabel($sTitle, 10, 0, $iTitle_Width, $iTitle_Height, 0x0200) ; $SS_CENTERIMAGE
   GUICtrlSetBkColor(-1,$iToast_Header_BkCol)
   GUICtrlSetColor(-1, $iToast_Header_Col)
   If BitAND($iToast_Style, 4) = 4 Then GUICtrlSetFont(-1, $iToast_Font_Size, 600)
Else
  If $iDelay < 0 Then
   ; Only need [X]
   $hToast_Close_X = GUICtrlCreateLabel($sX_Char, $iToast_Width - 18, 0, 17, 17)
    GUICtrlSetFont(-1, 14, Default, Default, $sX_Font)
    GUICtrlSetBkColor(-1, -2) ; $GUI_BKCOLOR_TRANSPARENT
    GUICtrlSetColor(-1, $iToast_Message_Col)
  EndIf
EndIf
; Create icon
If $iIcon_Reduction Then GUICtrlCreateIcon($sDLL, $iIcon_Style, 10, 10 + $iTitle_Height)
; Create Message label
GUICtrlCreateLabel($sMessage, 10 + $iIcon_Reduction, 10 + $iTitle_Height, $iLabelwidth, $iLabelheight)
  GUICtrlSetStyle(-1, $iLabel_Style)
  If $iToast_Message_Col <> Default Then GUICtrlSetColor(-1, $iToast_Message_Col)
; Slide Toast Slice into view from behind systray and activate
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hToast_Handle, "int", 1000, "long", $aToast_Data[2])
; Activate Toast without stealing focus
GUISetState(@SW_SHOWNOACTIVATE, $hToast_Handle)
; If script is to pause
If $fWait = True Then
  ; Begin timeout counter
  Local $iTimeout_Begin = TimerInit()
  ; Wait for timeout or closure
  While 1
   If GUIGetMsg() = $hToast_Close_X Or TimerDiff($iTimeout_Begin) / 1000 >= Abs($iDelay) Then ExitLoop
  WEnd
; If script is to continue and delay has been set
ElseIf Abs($iDelay) > 0 Then
  ; Store timer info
  $iToast_Timer = Abs($iDelay * 1000)
  $iToast_Start = TimerInit()
  ; Register Adlib function to run timer
  AdlibRegister("_Toast_Timer_Check", 100)
  ; Register message handler to check for [X] click
  GUIRegisterMsg(0x0021, "_Toast_WM_EVENTS") ; $WM_MOUSEACTIVATE
EndIf
; Reset original mode
$nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
; Create array to return Toast dimensions
Local $aToast_Data[3] = [$iToast_Width, $iToast_Height, $iLine_Height]
Return $aToast_Data
EndFunc ; => _Toast_Show
; #FUNCTION# ========================================================================================================
; Name...........: _Toast_Hide
; Description ...: Hides a slice message from the systray
; Syntax.........: _Toast_Hide()
; Requirement(s).: v3.3.1.5 or higher - AdlibRegister used in _Toast_Show
; Return values .: Success: Returns 0
;                 Failure: If Toast does not exist returns -1 and sets @error to 1
; Author ........: Melba23
; Example........; Yes
;=====================================================================================================================
Func _Toast_Hide()
; If no Toast to hide, return
If $hToast_Handle = 0 Then Return SetError(1, 0, -1)
; Slide Toast back behind systray
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hToast_Handle, "int", 500, "long", $iToast_Move)
; Delete Toast slice
GUIDelete($hToast_Handle)
; Set flag for "no Toast"
$hToast_Handle = 0
EndFunc ; => _Toast_Hide
; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Toast_Locate
; Description ...: Find Systray and determine Toast start position and movement direction
; Syntax ........: _Toast_Locate($iToast_Width, $iToast_Height)
; Parameters ....: $iToast_Width  - required width of slice
;                 $iToast_Height - required height of slice
; Author ........: Melba23, based on some original code by GioVit
; Modified.......:
; Remarks .......: This function is used internally by _Toast_Show
; ===============================================================================================================================
Func _Toast_Locate($iToast_Width, $iToast_Height)
; Define return array
Local $aToast_Data[3]
; Find systray
Local $iPrevMode = Opt("WinTitleMatchMode", 4)
    Local $aTray_Pos = WinGetPos("[CLASS:Shell_TrayWnd]")
    Opt("WinTitleMatchMode", $iPrevMode)

; If error in finding systray
If Not IsArray($aTray_Pos) Then Return SetError(2, 0, -1)
; Begin MilesAhead Mod
Local $l, $t, $r, $b
    _GetDesktopWorkArea($l,$t,$r,$b)
; End MilesAhead Mod
; Determine direction of Toast motion and starting position
If $aTray_Pos[1] > 0 Then
        $iToast_Move = 0x00050004 ; $AW_SLIDE_OUT_BOTTOM
        $aToast_Data[0] = @DesktopWidth - $iToast_Width
        ;$aToast_Data[1] = $aTray_Pos[1] - $iToast_Height
  $aToast_Data[1] = $b - $iToast_Height   ; MilesAhead Mod
  $aToast_Data[2] = 0x00040008 ; $AW_SLIDE_IN_BOTTOM
    Elseif $aTray_Pos[0] > 0 Then
        $iToast_Move = 0x00050001 ; $AW_SLIDE_OUT_RIGHT
        ;$aToast_Data[0] = $aTray_Pos[0] - $iToast_Width
  $aToast_Data[0] = $r - $iToast_Width ; MilesAhead Mod
        $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
  $aToast_Data[2] = 0x00040002 ; $AW_SLIDE_IN_RIGHT
    ElseIf $aTray_Pos[2] = @DesktopWidth Then
        $iToast_Move = 0x00050008 ; $AW_SLIDE_OUT_TOP
        $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
        $aToast_Data[1] = $t  ; MilesAhead Mod
  $aToast_Data[2] = 0x00040004 ; $AW_SLIDE_IN_TOP
    ElseIf $aTray_Pos[3] = @DesktopHeight Then
        $iToast_Move = 0x00050002 ; $AW_SLIDE_OUT_LEFT
        ;$aToast_Data[0] = $aTray_Pos[0] + $aTray_Pos[2]
  $aToast_Data[0] = $l  ; MilesAhead Mod
        $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
  $aToast_Data[2] = 0x00040001 ; $AW_SLIDE_IN_LEFT
    EndIf
Return $aToast_Data
EndFunc ; => _Toast_Locate
; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Toast_Timer_Check
; Description ...: Checks whether Toast has timed out or closure [X] clicked
; Syntax ........: _Toast_Locate($iToast_Width, $iToast_Height)
; Author ........: Melba23
; Modified.......:
; Remarks .......: This function is used internally by _Toast_Show if the Wait parameter is set to False
; ===============================================================================================================================
Func _Toast_Timer_Check()
; Return if timeout not elapsed and [X] not clicked
If TimerDiff($iToast_Start) < $iToast_Timer And $fToast_Close = False Then Return
; Unregister message handler
GUIRegisterMsg(0x0021, "") ; $WM_MOUSEACTIVATE
; Unregister this function
AdlibUnRegister("_Toast_Timer_Check")
; Reset flag
$fToast_Close = False
; Retract slice
_Toast_Hide()
EndFunc; => _Toast_Timer_Check
; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Toast_WM_EVENTS
; Description ...: Message handler to check if closure [X] clicked
; Author ........: Melba23
; Modified.......:
; Remarks .......: This function is used internally by _Toast_Show if the Wait parameter is set to False
; ===============================================================================================================================
Func _Toast_WM_EVENTS($hWnd, $Msg, $wParam, $lParam)
#forceref $wParam, $lParam
    If $hWnd = $hToast_Handle Then
  If $Msg = 0x0021 Then ; $WM_MOUSEACTIVATE
   ; Check mouse position
            Local $aPos = GUIGetCursorInfo($hToast_Handle)
            If $aPos[4] = $hToast_Close_X Then $fToast_Close = True
  EndIf
    EndIf
    Return 'GUI_RUNDEFMSG'
EndFunc; => _Toast_WM_EVENTS
; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Toast_GetDefFont
; Description ...: Determine system default MsgBox font and size
; Syntax ........: _Toast_GetDefFont($iData)
; Parameters ....: $iData - 0 = Font point size, 1 = Font name
; Author ........: Melba23
; Modified.......:
; Remarks .......: This function is used internally by _Toast functions
; ===============================================================================================================================
Func _Toast_GetDefFont($iData)
; Get default system font data
Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]")
DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS))
DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0)
; Read font data for MsgBox font
Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 15))
Switch $iData
  Case 0
   ; Font size as integer
   Return Int((Abs(DllStructGetData($tLOGFONT, 1)) + 1) * .75)
  Case 1
   ; Font name
   Return DllStructGetData($tLOGFONT, 14)
EndSwitch
EndFunc ;=>_Toast_GetDefFont

Here's my RunInTrayMod

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Fileversion=1.3.1.0
#AutoIt3Wrapper_Res_Language=1033
://////=__=
://////=__=.
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; RunInTrayMod - modified version of RunInTray utility found here:
; http://www.cellsworth.com/news/computer-related/35-uncategorizied/96-runintray.html
;
; The main modification to RunInTray is on detection of the window.
; A handle is obtained and used in Hide Show and Close operations.
; This way the client may change window caption and still respond
; to Hide, Show, and Close commands.
;
; Also Close is used instead of Kill to close the client app.
;
#include <Constants.au3>
#include <MilesAheadMisc.au3>
#include <Toast.au3>
;== Main Script Start ==
AutoItSetOption("WinTitleMatchMode", -3)
AutoItSetOption("TrayOnEventMode", 1) ; Use event trapping for tray menu
AutoItSetOption("TrayMenuMode", 3) ; Default tray menu items will not be shown.
Const $delayMin = 1, $delayMax = 60
; call EmptyWorkingSet once a minute
Const $MemCountMax = 60
Global $Dir = "", $App = "", $handle = 0, $title = "", $memCount = 0, $delay = 0, $hasDelay = False
$iMsg = "Usage: " & @CRLF & @CRLF & "RunInTrayMod [ -d=n ] ProgramPath WorkingDir [ WindowTitle ]" & @CRLF
$iMsg &= "  (  -d=n is seconds delay : Valid range for n is " & $delayMin & " to " & $delayMax & "  )" & @CRLF & @CRLF
$iMsg &= "If any params contain space(s) wrap them in double quotes" & @CRLF & @CRLF
$iMsg &= "If App will not go to Tray specify exact Window Title as last param" & @CRLF & @CRLF
$iMsg &= "( If App leaves Icon in Taskbar when Trayed, it is not compatible )"
Switch $CmdLine[0]
Case 4
  If Not StringInStr($CmdLine[1], "-d=") Then _ShowUsage($iMsg)
  $delay = Int(StringMid($CmdLine[1], 4))
  If $delay < $delayMin Or $delay > $delayMax Then $delay = 0
  $App = $CmdLine[2]
  $Dir = $CmdLine[3]
  $title = $CmdLine[4]
Case 3
  If StringInStr($CmdLine[1], "-d=") Then
   $delay = Number(StringMid($CmdLine[1], 4))
   If $delay < $delayMin Or $delay > $delayMax Then $delay = 0
   $App = $CmdLine[2]
   $Dir = $CmdLine[3]
  Else
   $App = $CmdLine[1]
   $Dir = $CmdLine[2]
   $title = $CmdLine[3]
  EndIf
Case 2
  If StringInStr($CmdLine[1], "-d=") Then _ShowUsage($iMsg)
  $App = $CmdLine[1]
  $Dir = $CmdLine[2]
Case Else
  _ShowUsage($iMsg)
EndSwitch
$proc_Name = _FileNoPath($App)
$do_Kill = True
If $delay Then
_Toast_Set(5, Default, Default, 0xFAEBD7, 0x1E90FF, 15)
$aRet = _Toast_Show($App, "RunInTrayMod", _FileBaseName($App) & " Starts in:" & @CRLF & @CRLF & @CRLF, $delay * -1, False)
$hLabel = GUICtrlCreateLabel("", 100, 80, 24, 24)
GUICtrlSetBkColor(-1, 0xFFFF00)
EndIf
While $delay
If $hToast_Handle Then
  GUICtrlSetData($hLabel, StringFormat("%2s", $delay))
Else
  TraySetToolTip(String($delay) & " Sec. to Launch " & _FileBaseName($App))
EndIf
Sleep(1000)
$delay -= 1
WEnd
ShellExecute($App, "", $Dir)
Sleep(1000)
If $title <> "" Then
$handle = WinWait($title, "", 4)
If $handle = 0 Then
  _ShowError("Could not get Handle for Window:" & @CRLF & @CRLF & $title)
EndIf
EndIf
If $handle = 0 Then
$handle = WinGetHandle(_WinGetByPID($proc_Name))
If $handle = "" Then
  $iMsg = "Could Not Get Handle To: " & $proc_Name & @CRLF & @CRLF
  $iMsg &= "Try adding Window Title to Command Line or Shortcut Target line"
  _ShowError($iMsg)
EndIf
EndIf
TraySetIcon($App)
TraySetClick(8)
$hTray_Show_Item = TrayCreateItem("Hide")
$hTray_Donate_Item = TrayCreateItem("Donate")
TrayCreateItem("")
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "On_Exit")
TrayItemSetOnEvent($hTray_Show_Item, "To_Tray")
TrayItemSetOnEvent($hTray_Donate_Item, "Donate")
TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "To_Tray")
TraySetToolTip(_FileBaseName($App))
To_Tray()
While 1
Sleep(1000)
If Not ProcessExists($proc_Name) Then
  $do_Kill = False
  Exit
EndIf
$memCount += 1
If $memCount >= $MemCountMax Then
  _EmptyWorkingSet()
  $memCount = 0
EndIf
WEnd
Func On_Exit()
If $do_Kill Then WinClose(_WinAPI_GetWindowText($handle))
Exit
EndFunc   ;==>On_Exit
Func To_Tray()
If TrayItemGetText($hTray_Show_Item) = "Hide" Then
  _WinAPI_ShowWindow($handle, @SW_HIDE)
  TrayItemSetText($hTray_Show_Item, "Show")
Else
  _WinAPI_ShowWindow($handle, @SW_SHOW)
  TrayItemSetText($hTray_Show_Item, "Hide")
EndIf
EndFunc   ;==>To_Tray
Func Donate()
ShellExecute("http://www.favessoft.com/donate.html")
EndFunc   ;==>Donate

Here's MilesAheadMisc where I have some MsgBox and file path functions used

;
;MilesAheadMisc.au3
;
;misc useful functions for
;inclusion in scripts.
;
;some functions are totatlly original.
;where adapted or used directly I give
;attribution when possible.
;
;MilesAhead
;
#include-once
#include <Array.au3>
#include <File.au3>
#include <WinAPI.au3>
#Include <APIConstants.au3>
#include <WinAPIEx.au3>
; Empty Tray Icon Queue of events
Func _EmptyTrayQ()
Local $m = 0
Do
  $m = TrayGetMsg()
Until $m = 0
EndFunc   ;==>_EmptyTrayQ
;use Scripting.Dictionary object for simple associative arrays
Func _AssocArray()
Local $aArray = ObjCreate("Scripting.Dictionary")
If @error Then
  Return SetError(1, 0, 0)
EndIf
$aArray.CompareMode = 1
Return $aArray
EndFunc   ;==>_AssocArray
Func _AssocArrayDestroy(ByRef $aArray)
If Not IsObj($aArray) Then
  Return False
EndIf
$aArray.RemoveAll()
$aArray = 0
Return True
EndFunc   ;==>_AssocArrayDestroy
;filter out empty array strings ("")
Func _ArrayDelBlanks(ByRef $someArray)
Local $index = -1
While UBound($someArray) > 0
  $index = _ArraySearch($someArray, "")
  If $index > -1 Then
   _ArrayDelete($someArray, $index)
  Else
   ExitLoop
  EndIf
WEnd
EndFunc   ;==>_ArrayDelBlanks
; $val is a string read by IniRead that
; should indicate if an option is
; enabled or disabled. The user can
; set it to True or 1 for enabled.
; (e.g. UseMiddleMouseClick=True)
;
; returns True if $val is "True" or "1"
; otherwise returns False
;
Func _IniBool($val)
If $val = "True" Or $val = "1" Then Return True
Return False
EndFunc   ;==>_IniBool
; When this is called the Active Window should be
; an Explorer Folder Window
;
; Success: Returns path of current folder
;
; Fail: Returns "" and sets @error
; @error = 1 if window is not an Explorer Window
; otherwise @error is set to 2
;
Func _ActiveFolderPath()
Local $oldOption = AutoItSetOption("WinTitleMatchMode", 4)
Local $handle = WinGetHandle("[Active]")
Local $className = _WinAPI_GetClassName($handle)
AutoItSetOption("WinTitleMatchMode", $oldOption)
If $className <> "ExploreWClass" And $className <> "CabinetWClass" Then
  Return SetError(1, 0, "")
EndIf
Local $urlPath = _ExplorerURL($handle)
If $urlPath <> "" Then
  Return _WinAPI_PathCreateFromUrl($urlPath)
EndIf
Return SetError(2, 0, "")
EndFunc   ;==>_ActiveFolderPath
; Gets URL path of window that matches $handle
; or "" if no match
;
Func _ExplorerURL($handle)
Local $shApp = ObjCreate("Shell.Application")
Local $windows = $shApp.Windows
For $item In $windows
  ;If Not $item Then ContinueLoop
  If ($item.hwnd = $handle) Then
   Return $item.LocationURL
  EndIf
Next
Return ""
EndFunc   ;==>_ExplorerURL

; _PassKey() : Temporarily disables a hotkey, sends
; the key, then enables again.
;
; Returns 0 if either param is blank.
;
; Otherwise Returns the result of the HotKeySet()
; attempt to reset the hotkey.
;
; Not ready for Prime Time due to AutoIt saving state
; of modifier keys
;
;~ Func _PassKey($funcName, $hKey = @HotKeyPressed)
;~  If $funcName = "" Or $hKey = "" Then
;~   Return 0
;~  EndIf
;~  HotKeySet($hKey)
;~  Send($hKey)
;~  Return HotKeySet($hKey, $funcName)
;~ EndFunc   ;==>_PassKey

;confirms that input consists only of valid chars
Func _ValidateInput($inputStr, $validChars)
For $x = 1 To StringLen($inputStr)
  If Not StringInStr($validChars, StringMid($inputStr, $x, 1)) Then
   Return False
  EndIf
Next
Return True
EndFunc   ;==>_ValidateInput
;InputBox to allow user to change hotkey modifier key
;ModKey chars must all be in $validChars string
;Returns $curModKey if user aborts entry
Func _EditHotkeyModifier($curModKey, $validChars)
Local $newModKey = ""
$prompt = "Usable Modifiers include:" & @CRLF
$prompt &= "#   for Win Key" & @CRLF
$prompt &= "!   for Alt Key" & @CRLF
$prompt &= "^   for Control Key" & @CRLF
$prompt &= "^!  for Control-Alt etc.." & @CRLF
$newModKey = InputBox("Enter HotKey Modifier", $prompt, $curModKey)
If $newModKey = "" Or $newModKey = $curModKey Then Return $curModKey
If Not _ValidateInput($newModKey, $validChars) Then
  _ShowError("Invalid Hotkey Modiifer Specified : Keeping Current!", "", False)
  Return $curModKey
EndIf
Return $newModKey
EndFunc   ;==>_EditHotkeyModifier
;return the Windows version as a number or string
;according to $retAsString param.
;example 6.1 for Windows7, 6 for Vista,
;5.1 for XP etc.. as number, as string the
;minor version will be preserved even if .0
;(Vista returns "6.0" etc.)
;
Func _WinVersion($retAsString = 0)
Local $dwVersion = DllCall("kernel32.dll", "dword", "GetVersion")
Local $versionStr = String(BitAND($dwVersion[0], 0x00FF))
$versionStr &= "." & String(BitShift(BitAND($dwVersion[0], 0xFF00), 8))
If $retAsString Then Return $versionStr
Return Number($versionStr)
EndFunc   ;==>_WinVersion
;_GetVersionEx()
;
;It calls the Ansi version of GetVersionEx() WinAPI
;
;On success returns zero based 5 element array of strings
;element 0 = OS Major;1 = OS Minor; 2 = build; 3 = platform; 4 = Version String
;note Version String may be an empty string or something like "Service Pack 1"
;
;On error returns 0 and sets @error to the value contained in @error macro.
;Sets @extended to 1 if error occurred in DllStructCreate(), 2 if error
;occurred in DllStructSetData(), or 3 if error occurred in DllCall()
;
Func _GetVersionEx()
Local $OsArray[5] = [""]
Local $osvi = DllStructCreate("dword size;dword OsMajor;dword OsMinor;dword build;dword platform;char verString[128]")
If @error Then
  Return SetError(@error, 1, 0)
EndIf
DllStructSetData($osvi, "size", 148)
If @error Then
  $osvi = 0
  Return SetError(@error, 2, 0)
EndIf
Local $retVal = DllCall("Kernel32.dll", "int", "GetVersionExA", "ptr", DllStructGetPtr($osvi))
If @error Then
  $osvi = 0
  Return SetError(@error, 3, 0)
EndIf
$OsArray[0] = String(DllStructGetData($osvi, "OsMajor"))
$OsArray[1] = String(DllStructGetData($osvi, "OsMinor"))
$OsArray[2] = String(DllStructGetData($osvi, "build"))
$OsArray[3] = String(DllStructGetData($osvi, "platform"))
$OsArray[4] = DllStructGetData($osvi, "verString")
$osvi = 0
Return $OsArray
EndFunc   ;==>_GetVersionEx
; Call EmptyWorkingSet() API
; Returns
Func _EmptyWorkingSet()
Local $result = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
Return $result[1]
EndFunc   ;==>_EmptyWorkingSet
; Reduce memory usage via EmptyWorkingSet()
; Author wOuter ( mostly ) on AutoIt3 forum
Func _ReduceMemory($i_PID = -1)
If _WinVersion() < 5 Then Return False
If $i_PID <> -1 Then
  Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
  Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
  DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
Else
  Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndIf
Return $ai_Return[0]
EndFunc   ;==>_ReduceMemory
;returns non 0 if Glass is enabled on Vista/W7
Func _GlassEnabled()
$retValue = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "int*", "")
If @error Then Return 0
Return $retValue[1]
EndFunc   ;==>_GlassEnabled
;from Michael Michta on AutoIt3 forum
Func EnableBlurBehind($hWnd)
Const $DWM_BB_ENABLE = 0x00000001
$Struct = DllStructCreate("dword;int;ptr;int")
DllStructSetData($Struct, 1, $DWM_BB_ENABLE)
DllStructSetData($Struct, 2, "1")
DllStructSetData($Struct, 4, "1")
DllCall("dwmapi.dll", "int", "DwmEnableBlurBehindWindow", "hwnd", $hWnd, "ptr", DllStructGetPtr($Struct))
EndFunc   ;==>EnableBlurBehind
;if $Str contains a space wrap in double quotes
;
;useful for command line params of files that have
;a space in the file path
;
Func _QuoteStr($str)
If StringInStr($str, " ") Then
  Return '"' & $str & '"'
EndIf
Return $str
EndFunc   ;==>_QuoteStr
;returns True if $path is a directory
Func _DirectoryExists($path)
If Not FileExists($path) Then Return False
If StringInStr(FileGetAttrib($path), "D") > 0 Then Return True
Return False
EndFunc   ;==>_DirectoryExists
;return True if $path exists and contains "D" directory attribute
Func _IsFolder($path)
Local $attr = FileGetAttrib($path)
If $attr = "" Then
  Return SetError(1, 0, False)
ElseIf StringInStr($attr, "D") Then
  Return True
Else
  Return False
EndIf
EndFunc   ;==>_IsFolder
;returns False if no media in drive or file/folder doesn't exist
;
;for use with complete paths, not for file named 'x'
;in working dir.  Seems to work ok with network paths
;(NAMEfolderfilename) as well as those starting with
;a drive letter. The idea is to avoid the long time-out
;if FileExists was used by itself on empty drive etc..
;
Func _ValidPath($path)
;filter out obvious junk
If StringLen($path) < 2 Then Return False
Local $sysDrive = StringLeft(@WindowsDir, 2)
Local $drive = StringLeft($path, 2)
If $sysDrive = $drive Then
  Return FileExists($path)
EndIf
Local $driveType = DriveGetType($drive)
If @error Then Return False
Switch $driveType
  Case "Unknown"
   Return False
  Case "Network"
   If DriveStatus($drive) = "Invalid" Then Return False
  Case "CDROM", "Removable"
   If DriveStatus($drive) = "NotReady" Then Return False
EndSwitch
Return FileExists($path)
EndFunc   ;==>_ValidPath
; A drive passed in that consists of a letter and colon
; ( x: ) will be set to Upper Case and a slash appened ( X: )
;
; A drive passed in as x: will be set to Upper Case.
;
; The Function returns nothing.  Any changes are made to the
; input param.
;
Func _DriveUpSlash(ByRef $drive)
If StringLen($drive) = 2 And StringRight($drive, 1) = ":" Then
  $drive = StringUpper($drive) & ""
ElseIf StringRight($drive, 2) = ":" Then
  $drive = StringUpper($drive)
EndIf
EndFunc   ;==>_DriveUpSlash
; return the basename part of a file path
; works only for files with extension
; e.g. returns "test" for c:foldertest.exe path
;
Func _FileBaseName($path)
If $path = "" Then Return ""
If StringLen($path) < 3 Then Return ""
Local $pos = StringInStr($path, "", 0, -1)
$pos += 1
Local $tmp = StringMid($path, $pos)
Return StringLeft($tmp, StringInStr($tmp, ".", 0, -1) - 1)
EndFunc   ;==>_FileBaseName
; Return Directory part of path with trailing slash
Func _FileDirWSlash($path)
Return StringLeft($path, StringInStr($path, "", 0, -1))
EndFunc   ;==>_FileDirWSlash
; Return Directory part of path without trailing slash
Func _FileDirNoSlash($path)
Return StringLeft($path, StringInStr($path, "", 0, -1) - 1)
EndFunc   ;==>_FileDirNoSlash
; return _FileBaseName with hash appended instead of using full path
;
Func _BaseFileStr($path)
Return _FileBaseName($path) & _HashString32($path)
EndFunc   ;==>_BaseFileStr
; return the '.ext' part of path no matter how long the ext
; as in image.jpg returns '.jpg' or image.jpeg returns '.jpeg'
;
Func _FileExt($path)
If $path = "" Then Return ""
Local $pos = StringInStr($path, ".", 0, -1)
If $pos = 0 Then Return ""
Return StringMid($path, $pos)
EndFunc   ;==>_FileExt
; return entire path without last extension
; (e.g. c:FolderText.txt returns c:FolderText)
;
Func _PathNoExt($path)
Return StringLeft($path, StringInStr($path, ".", 0, -1) - 1)
EndFunc   ;==>_PathNoExt

;returns filename without drive or path
Func _FileNoPath($path)
Return StringMid($path, StringInStr($path, "", 0, -1) + 1)
EndFunc   ;==>_FileNoPath
;filter out percent signs, spaces, and illegal filename chars
;and substitute underscores. Optionally chop off return str
;at $maxLen chars.
;
;
Func _NormalizeFilename($inFilename, $maxLen = 0)
Local Const $illegalFilenameChars = "?[]/=+<>:;"",* %"
Local $c = ""
Local $fixedFilename = ""
For $x = 1 To StringLen($inFilename)
  $c = StringMid($inFilename, $x, 1)
  If StringInStr($illegalFilenameChars, $c) Then
   $c = "_"
  EndIf
  $fixedFilename &= $c
Next
If $maxLen Then
  Return StringLeft($fixedFilename, $maxLen)
EndIf
Return $fixedFilename
EndFunc   ;==>_NormalizeFilename
;return @ScriptName without extension
;useful for MsgBox titles or path
;building
;
Func _ScriptBaseName()
Return StringLeft(@ScriptName, (StringInStr(@ScriptName, ".") - 1))
EndFunc   ;==>_ScriptBaseName
;a one-liner but saves thinking about it :)
;
Func _ScriptIniFileName()
Return @ScriptDir & "" & _ScriptBaseName() & ".ini"
EndFunc   ;==>_ScriptIniFileName
; #FUNCTION# ====================================================================================================================
; Name...........: _FileInPath
; Description ...: Returns the location in the PATH environment variable containing a file
; Syntax.........: _FileInPath( $sFilename )
; Parameters ....: $sFilename - The file to search for (filename only, no folders)
; Return values .: Success - Returns the path to the file and set @error=0 (@extended=1 a specified path and the file is there)
;                 Failure - Returns "" and sets @error:
;                 |1 - File not found in @WorkingDir or the PATH (@extended=1 if PATH is blank)
;                 |2 - Could not StringSplit the PATH
; Author ........: Gigglestick (c0deWorm)
; Modified.......: Comments added and logic modified
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _FileInPath($asFilename)
If StringInStr($asFilename, "") Then
  If FileExists($asFilename) Then
   ; if a full or relative path was specified and the file exists then return the path
   Return SetError(0, 1, $asFilename)
  Else
   ; if a path was specified and the file does not exist then return "file not found" error
   Return SetError(1, 0, "")
  EndIf
EndIf
; if the file is found in the current working directory then return the absolute file path
If FileExists(@WorkingDir & "" & $asFilename) Then Return SetError(0, 0, @WorkingDir & "" & $asFilename)
Local $i, $lasPath, $lsPath = EnvGet("PATH")
; if variable containing PATH is empty then return "file not found" error and @extended=2
If StringLen($lsPath) = 0 Then Return SetError(1, 1, "")
; if PATH is set but only has one entry then check it
If StringLen($lsPath) > 0 And Not StringInStr($lsPath, ";") Then
  If FileExists($lsPath & "" & $asFilename) Then
   ; if the filename is found in the single PATH entry then return the file path
   Return SetError(0, 0, $lsPath & "" & $asFilename)
  Else
   ; if PATH is a single entry and does not contain the filename then return "file not found" error
   Return SetError(1, 0, "")
  EndIf
EndIf
; remove any blank entries (double semicolons)
While StringInStr($lsPath, ";;")
  $lsPath = StringReplace($lsPath, ";;", ";")
WEnd
; split variable containing PATH into an array of single paths
$lasPath = StringSplit($lsPath, ";")
; if ";" not found in split then return error
If @error Then Return SetError(2, 0, "")
; loop through array of single paths, searching for absolute file path and return absolute file path if found
For $i = 1 To $lasPath[0]
  If FileExists($lasPath[$i] & "" & $asFilename) Then Return SetError(0, 0, $lasPath[$i] & "" & $asFilename)
Next
; unable to find filename in current working directory or PATH so return error
Return SetError(1, 0, "")
EndFunc   ;==>_FileInPath
; Ascend4nt on AutoIt3 forum
; Open Property Page to specified Tab
; e.g. _FileOpenPropertiesDialog("notepad.exe","Details")
;
; http://www.autoitscript.com/forum/topic/118673-open-a-files-properties-window/page__view__findpost__p__825420
;
Func _FILEPropertiesDialog($sObjName, $sPropPage = "", $iObjType = 0x02, $hWnd = 0)
Local $sPropPageType = "ptr"
If IsString($sPropPage) And $sPropPage <> "" Then
  $sPropPageType = "wstr"
Else
  $sPropPage = 0
EndIf
Local $aRet = DllCall("shell32.dll", "bool", "SHObjectProperties", "hwnd", $hWnd, "dword", $iObjType, "wstr", $sObjName, $sPropPageType, $sPropPage)
If @error Then Return SetError(2, @error, False)
If Not $aRet[0] Then Return SetError(3, 0, False)
Return True
EndFunc   ;==>_FILEPropertiesDialog
;Check FavesSoft Server for newer version with optional download
;If user downloads, the script directory and zip file will be
;opened, and the calling program exited.
;
Func _Check4Update($verIniFile = "FavesVersions.ini", $url = "http://www.favessoft.com/", $maxCount = 10)
Local $count = 0
Local $iniFile = @ScriptDir & "" & $verIniFile
Local $hDownload = InetGet($url & $verIniFile, $iniFile, 1, 1)
Local $localFile = ""
Do
  $count += 1
  If $count > $maxCount Then ExitLoop
  Sleep(250)
Until InetGetInfo($hDownload, 2)
InetClose($hDownload)
If $count > $maxCount Then
  _ShowError("Server Access Failed!", "", False)
  Return False
EndIf
Local $v = IniRead($iniFile, "Versions", _ScriptBaseName(), "")
If $v = "" Then
  _ShowError("Version Info Not Found!", "", False)
  If FileExists($iniFile) Then
   FileDelete($iniFile)
  EndIf
  Return False
EndIf
Local $t = FileGetVersion(@ScriptFullPath)
If $v > $t Then
  If MsgBox(0x1044, _ScriptBaseName(), "Current Version is " & $t & " Online Version is " & $v & " : Download?") = 6 Then
   $d = IniRead($iniFile, "Downloads", _ScriptBaseName(), "")
   If $d <> "" Then
    $localFile = @ScriptDir & "" & $d
    $hDownload = InetGet($url & $d, $localFile, 1, 1)
    $count = 0
    Do
     $count += 1
     If $count > $maxCount Then ExitLoop
     Sleep(250)
    Until InetGetInfo($hDownload, 2)
    InetClose($hDownload)
    If $count <= $maxCount Then
     ShellExecute($localFile)
     ShellExecute(@ScriptDir)
     If FileExists($iniFile) Then
      FileDelete($iniFile)
     EndIf
     Exit
    Else
     _ShowError("Download Attempt Failed!", "", False)
     If FileExists($iniFile) Then
      FileDelete($iniFile)
     EndIf
     Return False
    EndIf
   Else
    _ShowError("Download Info Not Found!", "", False)
    If FileExists($iniFile) Then
     FileDelete($iniFile)
    EndIf
    Return False
   EndIf
  Else
   If FileExists($iniFile) Then
    FileDelete($iniFile)
   EndIf
   Return True
  EndIf
Else
  MsgBox(0x1040, _ScriptBaseName(), $t & " is the latest version")
EndIf
If FileExists($iniFile) Then
  FileDelete($iniFile)
EndIf
EndFunc   ;==>_Check4Update
;show an error msg and optionally quit, with optional timeout
Func _ShowError($errorMsg, $title = "", $quit = True, $timeOut = 0)
If $title = "" Then $title = _ScriptBaseName()
MsgBox(0x1010, $title, $errorMsg, $timeOut)
If $quit Then Exit
EndFunc   ;==>_ShowError
;show usage msg and optionally quit with optional timeout
Func _ShowUsage($usageMsg, $title = "", $quit = True, $timeOut = 0)
If $title = "" Then $title = _ScriptBaseName()
MsgBox(0x1040, $title, $usageMsg, $timeOut)
If $quit Then Exit
EndFunc   ;==>_ShowUsage
;write AssocArray to IniFile Section
;returns 1 on success - sets @error on failure
Func _WriteAssocToIni($myAssoc, $myIni, $mySection)
$retVal = 0
If $myAssoc.Count() < 1 Then
  Return SetError(1, 0, 0)
EndIf
Local $iArray[$myAssoc.Count()][2]
Local $aArray = $myAssoc.Keys()
For $x = 0 To UBound($aArray) - 1
  $iArray[$x][0] = $aArray[$x]
  $iArray[$x][1] = _MakePosString($myAssoc($aArray[$x]))
Next
$retVal = IniWriteSection($myIni, $mySection, $iArray, 0)
Return SetError(@error, 0, $retVal)
EndFunc   ;==>_WriteAssocToIni
;read AssocArray from IniFile Section
;returns number of items read - sets @error on failure
Func _ReadAssocFromIni(ByRef $myAssoc, $myIni, $mySection)
Local $sectionArray = IniReadSection($myIni, $mySection)
If @error Then Return SetError(1, 0, 0)
Local $posA[9]
Local $posS
For $x = 1 To $sectionArray[0][0]
  $posS = _MakePosArray($sectionArray[$x][1])
  For $y = 0 To UBound($posS) - 1
   $posA[$y] = Number($posS[$y])
   If $posA[$y] < 0 Then ContinueLoop 2
  Next
  $myAssoc($sectionArray[$x][0]) = $posA
Next
Return $sectionArray[0][0]
EndFunc   ;==>_ReadAssocFromIni
;from _SDBM32 by trancexx on AutoIt3 forum
Func _HashString32($sString)
Local $aArray = StringToASCIIArray($sString)
Local $iHash = 0
For $i = 0 To UBound($aArray) - 1
  $iHash = $aArray[$i] + BitShift($iHash, -6) + BitShift($iHash, -16) - $iHash
Next
Return Hex($iHash)
EndFunc   ;==>_HashString32
;makes a Position string using '#' number separator
Func _MakePosString($posArray)
Local $str = ""
For $x = 0 To UBound($posArray) - 2
  $str &= String($posArray[$x]) & "#"
Next
$str &= String($posArray[UBound($posArray) - 1])
Return $str
EndFunc   ;==>_MakePosString
;makes a Position array from a Position string
Func _MakePosArray($posString)
Return StringSplit($posString, "#", 2)
EndFunc   ;==>_MakePosArray
;show msgbox without sound and optionally quit with optional timeout
Func _ShowSilent($usageMsg, $title = "", $quit = True, $timeOut = 0)
If $title = "" Then $title = _ScriptBaseName()
MsgBox(0xA0, $title, $usageMsg, $timeOut)
If $quit Then Exit
EndFunc   ;==>_ShowSilent
; Get the execuatble path of a window
; Author gafrost on AutoIt3 forum
Func _WinGetPath($title = "", $strComputer = 'localhost')
Local $win = WinGetTitle($title)
Local $pid = WinGetProcess($win)
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $colItems = ""
Local $objWMIService = ObjGet("winmgmts:" & $strComputer & "rootCIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", _
   $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
  For $objItem In $colItems
   If $objItem.ExecutablePath Then Return $objItem.ExecutablePath
  Next
EndIf
Return ""
EndFunc   ;==>_WinGetPath
; _GetWindowExePath($WindowTitle = "[ACTIVE]")
;
; Returns complete path to Exe that owns window
; on error sets @error and returns ""
;
Func _GetWindowExePath($WindowTitle = "[ACTIVE]")
Local $pid = WinGetProcess($WindowTitle)
If $pid = -1 Then Return SetError(1, 0, "")
Local $pHandle = _WinAPI_OpenProcess(0x410, False, $pid)
If @error Then Return SetError(1, 1, "")
Local $result = _WinAPI_GetModuleFileNameEx($pHandle)
If $result = "" Then Return SetError(@error, 2, "")
Return $result
EndFunc   ;==>_GetWindowExePath
;AutoIt3 Forum code to get Desktop WorkArea
Func _GetDesktopWorkArea(ByRef $left, ByRef $top, ByRef $right, ByRef $bottom)
Local Const $SPI_SETWORKAREA = 47
Local Const $SPI_GETWORKAREA = 48
Local $tRcWA = DllStructCreate($tagRECT)
If _WinAPI_SystemParametersInfo($SPI_GETWORKAREA, 0, DllStructGetPtr($tRcWA)) Then
  $left = DllStructGetData($tRcWA, "Left")
  $right = DllStructGetData($tRcWA, "Right")
  $top = DllStructGetData($tRcWA, "Top")
  $bottom = DllStructGetData($tRcWA, "Bottom")
  Return True
EndIf
Return False
EndFunc   ;==>_GetDesktopWorkArea
Func _SetDesktopWorkArea($left, $top, $right, $bottom)
Local Const $SPI_SETWORKAREA = 47
Local Const $SPI_GETWORKAREA = 48
Local $tRcWA = DllStructCreate($tagRECT)
DllStructSetData($tRcWA, "Left", $left)
DllStructSetData($tRcWA, "Top", $top)
DllStructSetData($tRcWA, "Right", $right)
DllStructSetData($tRcWA, "Bottom", $bottom)
Return _WinAPI_SystemParametersInfo($SPI_SETWORKAREA, 0, DllStructGetPtr($tRcWA))
EndFunc   ;==>_SetDesktopWorkArea
Func _DesktopMarginArea(ByRef $left, ByRef $top, ByRef $right, ByRef $bottom, $margin = 4)
Local $l, $t, $r, $b
Local $m = Int($margin)
If $m < 0 Or $m > 12 Then $m = 4
If $m = 0 Then
  _GetDesktopWorkArea($left, $top, $right, $bottom)
Else
  _GetDesktopWorkArea($l, $t, $r, $b)
  $left = $l + $m
  $top = $t + $m
  $right = $r - $m
  $bottom = $b - $m
EndIf
EndFunc   ;==>_DesktopMarginArea
Func _DesktopTaskbarGap(ByRef $left, ByRef $top, ByRef $right, ByRef $bottom, $percentMargin = 5)
_GetDesktopWorkArea($left, $top, $right, $bottom)
If $right - $left = @DesktopWidth And $bottom - $top = @DesktopHeight Then
  Return
EndIf
If $bottom < @DesktopHeight Then
  $bottom -= Int($bottom / 100 * $percentMargin)
ElseIf $top > 0 Then
  $top += Int(($bottom - $top) / 100 * $percentMargin)
ElseIf $left > 0 Then
  $left += Int(($right - $left) / 100 * $percentMargin)
Else
  $right -= Int(($right - $left) / 100 * $percentMargin)
EndIf
EndFunc   ;==>_DesktopTaskbarGap
; Set Desktop Work Area with percent gap next to Taskbar
Func _DesktopSetTaskbarGap($percentMargin = 5)
Local $l, $t, $r, $b
_DesktopTaskbarGap($l, $t, $r, $b, $percentMargin)
Return _SetDesktopWorkArea($l, $t, $r, $b)
EndFunc   ;==>_DesktopSetTaskbarGap
; _ShowFolders($folders, $percentGap = 5)
;
; Show folders leaving TaskBar Gap
; ---------------------------------
; $folders[0] must have the folder count
; $percentGap is the percent of screen width
; or height to leave next to the Taskbar.
; If TaskbarGap.exe is running, $percentGap
; is set to 0 since it is assumed TaskbarGap
; has set the work area to allow for the gap.
;
; Does not Return a value
;
Func _ShowFolders($folders, $percentGap = 5, $moveOnly = False)
If Not IsArray($folders) Then Return
Local $l = -1, $t = -1, $r = -1, $b = -1
Local $oldMatchMode = AutoItSetOption("WinTitleMatchMode", -3)
If ProcessExists("TaskbarGap.exe") Then
  $percentGap = 0
EndIf
_DesktopTaskbarGap($l, $t, $r, $b, $percentGap)
Local $sleepVal = 2500
Local $s = $folders[0]
Local $h = $b - $t
Local $w = ($r - $l) / $s
Local $w3 = 0, $w4 = 0
$w3 = ($r - $l) / 3
$w4 = ($r - $l) / 4
If $s > 4 Then $sleepVal = 4000
If $s > 6 Then $sleepVal = 4500
If $s >= 4 Then
  $h = ($b - $t) / 2
EndIf
If $s > 8 Then
  WinMinimizeAll()
  Sleep(50)
EndIf
If Not $moveOnly Then
  For $x = 1 To $s
   ShellExecute("explorer.exe", "/e," & $folders[$x], "", "open")
  Next
  Sleep($sleepVal)
  WinWait($folders[$s], "", 8)
EndIf
If $s > 8 Then
  _TileHorizontal()
ElseIf $s = 8 Then
  $w *= 2
  WinMove($folders[1], "", $l, $t, $w - 1, $h - 2)
  WinMove($folders[2], "", $l + $w, $t, $w - 1, $h - 2)
  WinMove($folders[3], "", $l + 2 * $w, $t, $w - 1, $h - 2)
  WinMove($folders[4], "", $l + 3 * $w, $t, $w - 1, $h - 2)
  WinMove($folders[5], "", $l, $t + $h, $w - 1, $h - 2)
  WinMove($folders[6], "", $l + $w, $t + $h, $w - 1, $h - 2)
  WinMove($folders[7], "", $l + 2 * $w, $t + $h, $w - 1, $h - 2)
  WinMove($folders[8], "", $l + 3 * $w, $t + $h, $w - 1, $h - 2)
ElseIf $s = 7 Then
  WinMove($folders[1], "", $l, $t, $w3 - 1, $h - 2)
  WinMove($folders[2], "", $l + $w3, $t, $w3 - 1, $h - 2)
  WinMove($folders[3], "", $l + 2 * $w3, $t, $w3 - 1, $h - 2)
  WinMove($folders[4], "", $l, $t + $h, $w4 - 1, $h - 2)
  WinMove($folders[5], "", $l + $w4, $t + $h, $w4 - 1, $h - 2)
  WinMove($folders[6], "", $l + 2 * $w4, $t + $h, $w4 - 1, $h - 2)
  WinMove($folders[7], "", $l + 3 * $w4, $t + $h, $w4 - 1, $h - 2)
ElseIf $s = 6 Then
  $w *= 2
  WinMove($folders[1], "", $l, $t, $w - 1, $h - 2)
  WinMove($folders[2], "", $l + $w, $t, $w - 1, $h - 2)
  WinMove($folders[3], "", $l + 2 * $w, $t, $w - 1, $h - 2)
  WinMove($folders[4], "", $l, $t + $h, $w - 1, $h - 2)
  WinMove($folders[5], "", $l + $w, $t + $h, $w - 1, $h - 2)
  WinMove($folders[6], "", $l + 2 * $w, $t + $h, $w - 1, $h - 2)
ElseIf $s = 5 Then
  WinMove($folders[1], "", $l, $t, $w3 - 1, $h - 2)
  WinMove($folders[2], "", $l + $w3, $t, $w3 - 1, $h - 2)
  WinMove($folders[3], "", $l + 2 * $w3, $t, $w3 - 1, $h - 2)
  WinMove($folders[4], "", $l, $t + $h, (($r - $l) / 2) - 1, $h - 2)
  WinMove($folders[5], "", $l + ($r - $l) / 2, $t + $h, (($r - $l) / 2) - 1, $h - 2)
ElseIf $s = 4 Then
  $w *= 2
  WinMove($folders[1], "", $l, $t, $w - 1, $h - 2)
  WinMove($folders[2], "", $l + $w, $t, $w - 1, $h - 2)
  WinMove($folders[3], "", $l, $t + $h, $w - 1, $h - 2)
  WinMove($folders[4], "", $l + $w, $t + $h, $w - 1, $h - 2)
Else
  For $x = 1 To $s
   WinMove($folders[$x], "", $l, $t, $w - 1, $h - 2)
   $l += $w
  Next
EndIf
AutoItSetOption("WinTitleMatchMode", $oldMatchMode)
EndFunc   ;==>_ShowFolders
;tile windows horizontally
Func _TileHorizontal()
DllCall("user32.dll", "int", "TileWindows", "int", 0, "int", 1, "int", 0, "int", 0, "int", 0)
EndFunc   ;==>_TileHorizontal
Func _TileVertical()
DllCall("user32.dll", "int", "TileWindows", "int", 0, "int", 0, "int", 0, "int", 0, "int", 0)
EndFunc   ;==>_TileVertical
;AutoIt3 Forum code to get multiple monitor metrics
Func _GetVirtualMetrics(ByRef $vWidth, ByRef $vHeight)
Local Const $SM_VIRTUALWIDTH = 78
Local Const $SM_VIRTUALHEIGHT = 79
Local $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
Local $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
$vWidth = $VirtualDesktopWidth[0]
$vHeight = $VirtualDesktopHeight[0]
EndFunc   ;==>_GetVirtualMetrics
; by SmOke_N on AutoIt3 Forum
; http://www.autoitscript.com/forum/topic/41639-windows-from-process/page__view__findpost__p__310089
; set $iPID to program name such as "notepad.exe"
; $nArray = 0 will return 1 base array; leaving it 1 will return the first visible window it finds
Func _WinGetByPID($iPID, $nArray = 1)
If IsString($iPID) Then $iPID = ProcessExists($iPID)
Local $aWList = WinList(), $sHold
For $iCC = 1 To $aWList[0][0]
  If WinGetProcess($aWList[$iCC][1]) = $iPID And _
    BitAND(WinGetState($aWList[$iCC][1]), 2) Then
   If $nArray Then Return $aWList[$iCC][0]
   $sHold &= $aWList[$iCC][0] & Chr(1)
  EndIf
Next
If $sHold Then Return StringSplit(StringTrimRight($sHold, 1), Chr(1))
Return SetError(1, 0, 0)
EndFunc   ;==>_WinGetByPID

Unfortunately it starts getting like C with all the includes. :)

Edited by MilesAhead
Link to comment
Share on other sites

  • Moderators

MilesAhead,

Thanks for all that - I will have a play with it and see what I get. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

MilesAhead,

Thanks for all that - I will have a play with it and see what I get. :)

M23

Ok. I tried to attach a shortcut for notepad to start with 5 second delay to make it easy to test RunInTrayMod but it wants to upload the exe file pointed to instead. Grrr!!

Anyway, Notepad may be easiest to try with delay.

Edited by MilesAhead
Link to comment
Share on other sites

  • Moderators

MilesAhead,

I have compiled and run the code you posted using the original Toast UDF, my beta code from above and the modded code you posted - adjusting the work area from time to time with the code you posted earlier to simulate the presence of your RocketDock toolbar. In all cases the Toast was visible - and when I used your modded code or my beta with a reset work area, the Toast appeared some distance above the Taskbar respecting the new work area settings. :)

So I am now completely at a loss as to why my beta code does not work for you. As far as I can tell the location coordinates are the same (other than minor adjustments made in the different versions - e.g. you keep the Toast on the screen edge while I place it 10 pixels in) and we both respect the work area settings. I will have another look later today after I have had a chance to think about the problem while driving to and from the airport with my daughter - but do not hold your breath! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...