官网 GUI 脚本,应该可以作为托盘提示使用,但汉化后显示失常,有兴趣的看看!!
本帖最后由 131738 于 2010-8-14 21:16 编辑无任何包含文件,文件名:Toast_Example_Obfuscated.au3.au3
Toast 这个词词霸解释为 吐司、面包、祝酒;尽是吃的东西,真不知这个词是如何与这个脚本内容联系起来的!!!
继续往下看,超版 afan 以做了修改。Func _StringSize($sText, $iSize = Default, $iWeight = Default, $iAttrib = Default, $sName = Default, $iWidth = 0)
Local $avSize_Info, $aRet, $iLine_Width = 0, $iLast_Word, $iWrap_Count
Local $hLabel_Handle, $hFont, $hDC, $oFont, $tSize = DllStructCreate("int X;int Y")
If Not IsString($sText) Then Return SetError(1, 1, 0)
If Not IsNumber($iSize) And $iSize <> Default Then Return SetError(1, 2, 0)
If Not IsInt($iWeight) And $iWeight <> Default Then Return SetError(1, 3, 0)
If Not IsInt($iAttrib) And $iAttrib <> Default Then Return SetError(1, 4, 0)
If Not IsString($sName) And $sName <> Default Then Return SetError(1, 5, 0)
If Not IsNumber($iWidth) Then Return SetError(1, 6, 0)
Local $hGUI = GUICreate("", 1200, 500, 10, 10)
If $hGUI = 0 Then Return SetError(2, 0, 0)
GUISetFont($iSize, $iWeight, $iAttrib, $sName)
$avSize_Info = $sText
If StringInStr($sText, @CRLF) = 0 Then StringRegExpReplace($sText, "[\x0a|\x0d]", @CRLF)
Local $asLines = StringSplit($sText, @CRLF, 1)
Local $hText_Label = GUICtrlCreateLabel($sText, 10, 10)
Local $aiPos = ControlGetPos($hGUI, "", $hText_Label)
GUISetState(@SW_HIDE)
GUICtrlDelete($hText_Label)
$avSize_Info = ($aiPos - 8) / $asLines
$avSize_Info = $aiPos
$avSize_Info = $aiPos - 4
If $aiPos > $iWidth And $iWidth > 0 Then
$avSize_Info = ""
$avSize_Info = $iWidth
Local $iLine_Count = 0
For $j = 1 To $asLines
$hText_Label = GUICtrlCreateLabel($asLines[$j], 10, 10)
$aiPos = ControlGetPos($hGUI, "", $hText_Label)
GUICtrlDelete($hText_Label)
If $aiPos < $iWidth Then
$iLine_Count += 1
$avSize_Info &= $asLines[$j] & @CRLF
Else
$hText_Label = GUICtrlCreateLabel("", 0, 0)
$hLabel_Handle = ControlGetHandle($hGUI, "", $hText_Label)
$aRet = DllCall("User32.dll", "hwnd", "GetDC", "hwnd", $hLabel_Handle)
If @error Then _StringSize_Error(3, 1, $hLabel_Handle, 0, $hGUI)
$hDC = $aRet
$aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0)
If @error Then _StringSize_Error(3, 2, $hLabel_Handle, $hDC, $hGUI)
$hFont = $aRet
$aRet = DllCall("GDI32.dll", "hwnd", "SelectObject", "hwnd", $hDC, "hwnd", $hFont)
If @error Then _StringSize_Error(3, 3, $hLabel_Handle, $hDC, $hGUI)
$oFont = $aRet
If $oFont = 0 Then _StringSize_Error(3, 4, $hLabel_Handle, $hDC, $hGUI)
$iWrap_Count = 0
While 1
$iLine_Width = 0
$iLast_Word = 0
For $i = 1 To StringLen($asLines[$j])
If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1
Local $sTest_Line = StringMid($asLines[$j], 1, $i)
GUICtrlSetData($hText_Label, $sTest_Line)
$iSize = StringLen($sTest_Line)
DllCall("GDI32.dll", "int", "GetTextExtentPoint32", "hwnd", $hDC, "str", $sTest_Line, "int", $iSize, "ptr", DllStructGetPtr($tSize))
If @error Then _StringSize_Error(3, 5, $hLabel_Handle, $hDC, $hGUI)
$iLine_Width = DllStructGetData($tSize, "X")
If $iLine_Width >= $iWidth - Int($iSize / 2) Then ExitLoop
Next
If $i > StringLen($asLines[$j]) Then
$iWrap_Count += 1
$avSize_Info &= $sTest_Line & @CRLF
ExitLoop
Else
$iWrap_Count += 1
If $iLast_Word = 0 Then
_StringSize_Error(4, 0, $hLabel_Handle, $hDC, $hGUI)
EndIf
$avSize_Info &= StringLeft($sTest_Line, $iLast_Word) & @CRLF
$asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word)
$asLines[$j] = StringStripWS($asLines[$j], 1)
EndIf
WEnd
$iLine_Count += $iWrap_Count
DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hLabel_Handle, "hwnd", $hDC)
If @error Then _StringSize_Error(3, 6, $hLabel_Handle, $hDC, $hGUI)
GUICtrlDelete($hText_Label)
EndIf
Next
$avSize_Info = ($iLine_Count * $avSize_Info) + 4
EndIf
GUIDelete($hGUI)
Return $avSize_Info
EndFunc ;==>_StringSize
Func _StringSize_Error($iError, $iExtended, $hLabel_Handle, $hDC, $hGUI)
DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hLabel_Handle, "hwnd", $hDC)
GUIDelete($hGUI)
Return SetError($iError, $iExtended, 0)
EndFunc ;==>_StringSize_Error
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
Global $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8)
Global $iToast_Header_BkCol = $aRet
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5)
Global $iToast_Header_Col = $aRet
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
Func _Toast_Set($vJust, $iHdr_BkCol = -1, $iHdr_Col = -1, $iMsg_BkCol = -1, $iMsg_Col = -1, $iFont_Size = -1, $sFont_Name = "")
Switch $vJust
Case Default
$iToast_Style = 1
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8)
$iToast_Header_BkCol = $aRet
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5)
$iToast_Header_Col = $aRet
$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
Case Else
Return SetError(1, 1, 0)
EndSwitch
Switch $iHdr_BkCol
Case Default
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8)
$iToast_Header_BkCol = $aRet
Case 0 To 0xFFFFFF
$iToast_Header_BkCol = Int($iHdr_BkCol)
Case -1
Case Else
Return SetError(1, 2, 0)
EndSwitch
Switch $iHdr_Col
Case Default
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5)
$iToast_Header_Col = $aRet
Case 0 To 0xFFFFFF
$iToast_Header_Col = Int($iHdr_Col)
Case -1
Case Else
Return SetError(1, 3, 0)
EndSwitch
Switch $iMsg_BkCol
Case Default
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8)
$iToast_Message_BkCol = $aRet
Case 0 To 0xFFFFFF
$iToast_Message_BkCol = Int($iMsg_BkCol)
Case -1
Case Else
Return SetError(1, 4, 0)
EndSwitch
Switch $iMsg_Col
Case Default
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8)
$iToast_Message_Col = $aRet
Case 0 To 0xFFFFFF
$iToast_Message_Col = Int($iMsg_Col)
Case -1
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
Case Else
Return SetError(1, 6, 0)
EndSwitch
Switch $sFont_Name
Case Default
$sToast_Font_Name = $sDef_Toast_Font_Name
Case ""
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
Func _Toast_Show($sTitle, $sMessage, $iDelay = 0, $fWait = True)
Local $nOldOpt = Opt('GUIOnEventMode', 0)
If $hToast_Handle <> 0 Then _Toast_Hide()
$hToast_Close_X = 9999
Local $iToast_Width_max = 500
Local $iToast_Width_min = 150
Local $aLabel_Pos = _StringSize($sMessage, $iToast_Font_Size, Default, Default, $sToast_Font_Name, $iToast_Width_max - 20)
$sMessage = $aLabel_Pos
Local $iLine_Height = $aLabel_Pos
Local $iLabelwidth = $aLabel_Pos
Local $iLabelheight = $aLabel_Pos
Local $iToast_Width = $iLabelwidth + 20
If $iToast_Width < $iToast_Width_min Then
$iToast_Width = $iToast_Width_min
$iLabelwidth = $iToast_Width_min - 20
EndIf
Local $iTitle_Height = 0
If $sTitle = "" Then
If $iDelay < 0 Then $iTitle_Height = 5
Else
$iTitle_Height = $iLine_Height + 2
If $iDelay < 0 Then
If $iTitle_Height < 17 Then $iTitle_Height = 17
EndIf
EndIf
Local $iToast_Height = $iLabelheight + $iTitle_Height + 20
Local $aToast_Data = _Toast_Locate($iToast_Width, $iToast_Height)
$hToast_Handle = GUICreate("", $iToast_Width, $iToast_Height, $aToast_Data, $aToast_Data, 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)
Local $iLabel_Style = 0
If BitAND($iToast_Style, 1) = 1 Then
$iLabel_Style = 1
ElseIf BitAND($iToast_Style, 2) = 2 Then
$iLabel_Style = 2
EndIf
If $sTitle <> "" Then
GUICtrlCreateLabel("", 0, 0, $iToast_Width, $iTitle_Height)
GUICtrlSetBkColor(-1, $iToast_Header_BkCol)
GUICtrlSetState(-1, 128)
Local $iTitle_Width = $iToast_Width - 10
If $iDelay < 0 Then
Local $iX_YCoord = Int(($iTitle_Height - 17) / 2)
$hToast_Close_X = GUICtrlCreateLabel("T", $iToast_Width - 18, $iX_YCoord, 17, 17)
GUICtrlSetFont(-1, 14, Default, Default, "Wingdings 2")
GUICtrlSetBkColor(-1, -2)
GUICtrlSetColor(-1, $iToast_Header_Col)
$iTitle_Width -= 18
EndIf
GUICtrlCreateLabel($sTitle, 10, 0, $iTitle_Width, $iTitle_Height, 0x0200)
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
$hToast_Close_X = GUICtrlCreateLabel("T", $iToast_Width - 18, 0, 17, 17)
GUICtrlSetFont(-1, 14, Default, Default, "Wingdings 2")
GUICtrlSetBkColor(-1, -2)
GUICtrlSetColor(-1, $iToast_Message_Col)
EndIf
EndIf
GUICtrlCreateLabel($sMessage, 10, 10 + $iTitle_Height, $iLabelwidth, $iLabelheight)
GUICtrlSetStyle(-1, $iLabel_Style)
If $iToast_Message_Col <> Default Then GUICtrlSetColor(-1, $iToast_Message_Col)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hToast_Handle, "int", 1000, "long", $aToast_Data)
GUISetState(@SW_SHOWNOACTIVATE, $hToast_Handle)
If $fWait = True Then
Local $iTimeout_Begin = TimerInit()
While 1
If GUIGetMsg() = $hToast_Close_X Or TimerDiff($iTimeout_Begin) / 1000 >= Abs($iDelay) Then ExitLoop
WEnd
ElseIf Abs($iDelay) > 0 Then
$iToast_Timer = Abs($iDelay * 1000)
$iToast_Start = TimerInit()
AdlibRegister("_Toast_Timer_Check", 100)
GUIRegisterMsg(0x0021, "_Toast_WM_EVENTS")
EndIf
$nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
Local $aToast_Data = [$iToast_Width, $iToast_Height, $iLine_Height]
Return $aToast_Data
EndFunc ;==>_Toast_Show
Func _Toast_Hide()
If $hToast_Handle = 0 Then Return SetError(1, 0, -1)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hToast_Handle, "int", 500, "long", $iToast_Move)
GUIDelete($hToast_Handle)
$hToast_Handle = 0
EndFunc ;==>_Toast_Hide
Func _Toast_Locate($iToast_Width, $iToast_Height)
Local $aToast_Data
Local $iPrevMode = Opt("WinTitleMatchMode", 4)
Local $aTray_Pos = WinGetPos("")
Opt("WinTitleMatchMode", $iPrevMode)
If Not IsArray($aTray_Pos) Then Return SetError(2, 0, -1)
If $aTray_Pos > 0 Then
$iToast_Move = 0x00050004
$aToast_Data = @DesktopWidth - $iToast_Width - 10
$aToast_Data = $aTray_Pos - $iToast_Height
$aToast_Data = 0x00040008
ElseIf $aTray_Pos > 0 Then
$iToast_Move = 0x00050001
$aToast_Data = $aTray_Pos - $iToast_Width
$aToast_Data = @DesktopHeight - $iToast_Height - 10
$aToast_Data = 0x00040002
ElseIf $aTray_Pos = @DesktopWidth Then
$iToast_Move = 0x00050008
$aToast_Data = @DesktopWidth - $iToast_Width - 10
$aToast_Data = $aTray_Pos + $aTray_Pos
$aToast_Data = 0x00040004
ElseIf $aTray_Pos = @DesktopHeight Then
$iToast_Move = 0x00050002
$aToast_Data = $aTray_Pos + $aTray_Pos
$aToast_Data = @DesktopHeight - $iToast_Height - 10
$aToast_Data = 0x00040001
EndIf
Return $aToast_Data
EndFunc ;==>_Toast_Locate
Func _Toast_Timer_Check()
If TimerDiff($iToast_Start) < $iToast_Timer And $fToast_Close = False Then Return
GUIRegisterMsg(0x0021, "")
AdlibUnRegister("_Toast_Timer_Check")
$fToast_Close = False
_Toast_Hide()
EndFunc ;==>_Toast_Timer_Check
Func _Toast_WM_EVENTS($hWnd, $Msg, $wParam, $lParam)
#forceref $wParam, $lParam
If $hWnd = $hToast_Handle Then
If $Msg = 0x0021 Then
Local $aPos = GUIGetCursorInfo($hToast_Handle)
If $aPos = $hToast_Close_X Then $fToast_Close = True
EndIf
EndIf
Return 'GUI_RUNDEFMSG'
EndFunc ;==>_Toast_WM_EVENTS
Func _Toast_GetDefFont($iData)
Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte;int;int;byte;int;int;byte;byte;byte")
DllStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS))
DllCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0)
Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char", DllStructGetPtr($tNONCLIENTMETRICS, 15))
Switch $iData
Case 0
Return Int((Abs(DllStructGetData($tLOGFONT, 1)) + 1) * .75)
Case 1
Return DllStructGetData($tLOGFONT, 14)
EndSwitch
EndFunc ;==>_Toast_GetDefFont
Local $sMsg, $hProgress, $aRet
$sMsg = "The message text goes in this area" & @CRLF & @CRLF
$sMsg &= "This Toast uses the System colours and font"
$aRet = _Toast_Show("The Title text goes here", $sMsg, 5)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & " - " & "Line height: " & $aRet & @CRLF)
_Toast_Hide()
$sMsg = "This Toast uses colours and font defined in a _Toast_Set call." & @CRLF & @CRLF
$sMsg &= "Subsequent Toasts will use these values until they are reset by another _Toast_Set call" & @CRLF & @CRLF
$sMsg &= "The next Toast has a very small message to show the pre-set minimum size"
_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10, "Arial")
$aRet = _Toast_Show("User-defined Colours and Bold Header", $sMsg, 10)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & " - " & "Line height: " & $aRet & @CRLF)
_Toast_Hide()
$aRet = _Toast_Show("", "Tiny", 2)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & " - " & "Line height: " & $aRet & @CRLF)
_Toast_Hide()
$sMsg = "These lines are of medium length" & @CRLF & @CRLF
$sMsg &= "The width is set by the longest" & @CRLF & @CRLF
$sMsg &= "No wrapping occurs here" & @CRLF & @CRLF
$sMsg &= "Note increased font size"
_Toast_Set(-1, -1, -1, -1, -1, 15)
$aRet = _Toast_Show("Mid Width", $sMsg, 5)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & " - " & "Line height: " & $aRet & @CRLF)
_Toast_Hide()
$sMsg = "This is a long message set to left justified and a much larger font using _Toast_Set" & @CRLF & @CRLF
$sMsg &= "The Toast is automatically set to the maximum preset width and the message text "
$sMsg &= "is wrapped as necessary to fit within the margins of the Toast" & @CRLF & @CRLF
$sMsg &= "The Toast colours and weight have been changed by another _Toast_Set call" & @CRLF & @CRLF
$sMsg &= "Note the closure on the title bar.This Toast will time out in 30 secs "
$sMsg &= "but clicking the will resume the script immediately"
_Toast_Set(0, -1, 0xFFFF00, 0x00FF00, 0x000000, 15, "Courier New")
$aRet = _Toast_Show("Max Width and Normal Header", $sMsg, -30)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & " - " & "Line height: " & $aRet & @CRLF)
_Toast_Hide()
$sMsg = "Note how Toasts adjust automatically in height to display all of the message "
$sMsg &= "regardless of whether there is a title bar to display, the font used, "
$sMsg &= "the number of lines or whether wrapping occurs" & @CRLF & @CRLF
$sMsg &= "This Toast will retract automatically when the next Toast is called "
$sMsg &= "or when the is clicked"
_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10, "Arial")
$aRet = _Toast_Show("", $sMsg, -10)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & " - " & "Line height: " & $aRet & @CRLF)
$sMsg = "This Toast has several blank lines inserted. "
$sMsg &= "This can be useful if you want to leave space to add other controls, "
$sMsg &= "such as a progress bar, to the Toast once it is displayed" & @CRLF & @CRLF & @CRLF & @CRLF
$sMsg &= "The Toast size and line height are returned by the function so you can easily calculate "
$sMsg &= "where to place the other controls."
$sMsg &= "This example script writes the size in the SciTE console" & @CRLF & @CRLF
$sMsg &= "Note that Toast colours and font have been reset to Default"
_Toast_Set(Default)
$aRet = _Toast_Show("Progress Bar", $sMsg, 0)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & " - " & "Line height: " & $aRet & @CRLF)
$hProgress = GUICtrlCreateProgress(10, $aRet * 5.5, $aRet - 20, 20)
For $i = 1 To 100
GUICtrlSetData($hProgress, $i)
Sleep(50)
Next
Sleep(5000)
_Toast_Hide()
$sMsg = "This Toast has the 'Wait' flag set to False. " & @CRLF & @CRLF
$sMsg &= "That means that the script will continue while the Toast is displayed as "
$sMsg &= "as you can see from this counter." & @CRLF & @CRLF & @CRLF
$sMsg &= "Clicking the will retract the Toast immediately but it will "
$sMsg &= "automatically retract after 20 seconds in any event"
_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10)
$aRet = _Toast_Show("Script Continuing", $sMsg, -20, False)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & " - " & "Line height: " & $aRet & @CRLF)
$hLabel = GUICtrlCreateLabel("", ($aRet - 20) / 2, $aRet * 6, 20, 20)
GUICtrlSetBkColor(-1, -2)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetFont(-1, 12)
$iCount = 0
Do
$iCount += 1
GUICtrlSetData($hLabel, $iCount)
Sleep(1000)
Until $iCount = 60 Or $hToast_Handle = 0
Exit已汉化部分:# ************************************* 第一界面 size: 286 x 74 - Line height: 12 160 x 74 - 行高: 12
$sMsg = "信息本文在这个区域" & @CRLF & @CRLF
$sMsg &= "界面使用系统颜色和字型"
$aRet = _Toast_Show("这里是窗口标题", $sMsg, 5)
ConsoleWrite("界面尺寸: " & $aRet & " x " & $aRet & " - " & "行高: " & $aRet & @CRLF)
_Toast_Hide()
# ************************************* 第二界面 size: 500 x 138 - Line height: 16 486 x 122 - 行高: 16
$sMsg = "这个界面是调用 _Toast_Set 定义的颜色和字型." & @CRLF & @CRLF
$sMsg &= "后来界面将使用这些数值,直到调用另外一个 _Toast_Set 重新设定" & @CRLF & @CRLF
$sMsg &= "下一界面有一个非常小的信息表示前固定的最小尺寸"
_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10, "Arial")
$aRet = _Toast_Show("自定义颜色和粗体表头", $sMsg, 10)
ConsoleWrite("界面尺寸: " & $aRet & " x " & $aRet & " - " & "行高: " & $aRet & @CRLF)
_Toast_Hide()
# ************************************* 第三界面 size: 150 x 40 - Line height: 16 150 x 40 - 行高: 16
$aRet = _Toast_Show("", "小界面", 2)
ConsoleWrite("界面尺寸: " & $aRet & " x " & $aRet & " - " & "行高: " & $aRet & @CRLF)
_Toast_Hide()
# ************************************* 第四界面 size: 317 x 210 - Line height: 23 268 x 210 - 行高: 23
$sMsg = "这些行有不同的长度的" & @CRLF & @CRLF
$sMsg &= "宽度按照最长的文本行设定" & @CRLF & @CRLF
$sMsg &= "没有发生环绕" & @CRLF & @CRLF
$sMsg &= "注意增加的字型大小"
_Toast_Set(-1, -1, -1, -1, -1, 15)
$aRet = _Toast_Show("Mid Width", $sMsg, 5)
ConsoleWrite("界面尺寸: " & $aRet & " x " & $aRet & " - " & "行高: " & $aRet & @CRLF)
_Toast_Hide()
# ************************************* 第五界面 size: 500 x 400 - Line height: 22 500 x 224 - 行高: 22
$sMsg = "这是 _Toast_Set 设置的长文本信息,文本使用左对齐和大字体" & @CRLF & @CRLF
$sMsg &= "界面自动设定为预设的最大宽度和消息文本 "
$sMsg &= "是必要的,以适应包装内的界面边缘" & @CRLF & @CRLF
$sMsg &= "调用另一个 _Toast_Set 改变界面的颜色和深浅" & @CRLF & @CRLF
$sMsg &= "请注意在标题栏中的关闭 符号。这个界面将持续 30 秒时间 "
$sMsg &= "但点击 脚本将立即继续下面的操作"
_Toast_Set(0, -1, 0xFFFF00, 0x00FF00, 0x000000, 15, "Courier New")
$aRet = _Toast_Show("最大宽度与正常头", $sMsg, -30)
ConsoleWrite("界面尺寸: " & $aRet & " x " & $aRet & " - " & "行高: " & $aRet & @CRLF)
_Toast_Hide()
# ************************************* 第六界面 size: 500 x 125 - Line height: 16 500 x 77 - 行高: 16
$sMsg = "注意界面如何自动调整高度,以显示全部消息 "
$sMsg &= "不论是否有标题栏显示, 使用的字体, "
$sMsg &= "行数或是否出现环绕" & @CRLF & @CRLF
$sMsg &= "当调用下一个界面时,这个界面将自动缩回"
$sMsg &= "或点击 按钮时"
_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10, "Arial")
$aRet = _Toast_Show("", $sMsg, -10)
ConsoleWrite("界面尺寸: " & $aRet & " x " & $aRet & " - " & "行高: " & $aRet & @CRLF)
# ************************************* 第七界面 size: 500 x 170 - Line height: 12 500 x 170 - 行高: 12
$sMsg = "这个界面插入了几个空白行. "
$sMsg &= "这是必要的,预留空间以方便你添加一些控件,"
$sMsg &= "例如一个进度条。 一旦界面显示" & @CRLF & @CRLF & @CRLF & @CRLF
$sMsg &= "由函数返回的界面大小和行的高度, 你就可以很容易地计算出"; & @CRLF
$sMsg &= "在什么地方放置其他控件."
$sMsg &= "这个示例脚本将界面尺寸大小写入 SciTE 的控制台" & @CRLF & @CRLF
$sMsg &= "请注意,界面的颜色和字体都被重置为默认值"
_Toast_Set(Default)
$aRet = _Toast_Show("Progress Bar", $sMsg, 0)
ConsoleWrite("界面尺寸: " & $aRet & " x " & $aRet & " - " & "行高: " & $aRet & @CRLF)
$hProgress = GUICtrlCreateProgress(10, $aRet * 5.5, $aRet - 20, 20)
For $i = 1 To 100
GUICtrlSetData($hProgress, $i)
Sleep(50)
Next
Sleep(5000)
_Toast_Hide()
# ************************************* 第八界面 size: 500 x 145 - Line height: 13 500 x 119 - 行高: 13
$sMsg = "这个界面的 'Wait' 等待标志参数值被设为 False. " & @CRLF & @CRLF
$sMsg &= "脚本在计时设定的时间内会连续显示这个界面,在计时装置完成之前, "
$sMsg &= "你可以观察到计数装置从 1 增到 20." & @CRLF & @CRLF & @CRLF
$sMsg &= "计时装置完成前,单击 符号按钮,界面将立即关闭 "
$sMsg &= "但无论怎样,20 秒计时完成之后,界面会自动关闭的"
_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 12)
$aRet = _Toast_Show("脚本连续显示界面", $sMsg, -20, False)
ConsoleWrite("界面尺寸: " & $aRet & " x " & $aRet & " - " & "行高: " & $aRet & @CRLF)
$hLabel = GUICtrlCreateLabel("", ($aRet - 20) / 2, $aRet * 6, 20, 20)
GUICtrlSetBkColor(-1, -2)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetFont(-1, 12)
$iCount = 0
Do
$iCount += 1
GUICtrlSetData($hLabel, $iCount)
Sleep(1000)
Until $iCount = 60 Or $hToast_Handle = 0
Exit 很简约,漂亮啊~~ 回复 2# afan
能找到汉化异常的原因吗? 回复 3# 131738
初步认为他没有考虑双字节的情况,造成获取字符串的宽度有问题,继而造成高度的不足。
代码太长了,没时间研究哦…
简单解决方法: 在$sMsg最后补适量的 & @CRLF 即可,如:
========第六界面=========
最后的 $sMsg &= "或点击 按钮时" & @CRLF
========第八界面=========
最后的 $sMsg &= "但无论怎样,20 秒计时完成之后,界面会自动关闭的" & @CRLF & @CRLF
回复 4# afan
谢谢!!!!受教了。。。
另,谢谢加分。。。打扰了。。。。 忘了很重要的一点,字母语言环境和方块文字环境断行的方式是不同的。
字母语言环境会以单词和空格的方式来判断,且Label不会自动调整换行显示,如果强制在范围内显示它会裁剪字符,使部分字符不会显示,因此,此脚本是用的将超出长度的字符串另外组织成另外的行,以保证每行文字都能完整显示。而这样每行的字符串长度相差可能都很大,所以它很多情况下都使用了水平居中显示的样式(8个例子中有7个是如此),以免居左显示时,右边会参差不齐,影响美观。
而方块文字环境则无此困扰,超过水平范围会自动换行,只要Label控件足够高则可完全显示。此脚本是针对字母语言环境的,所以它调整起来非常繁琐,如果按我们的文字习惯会简单很多,当然也就无法满足字母环境了。 回复afan
其实这个脚本有点意思的, 创建窗口宽度为 1200, 够大的了
但实际并没有显示出这么大的窗口,而是根据字符串的多少,来确定显示窗口的大小,
你的“认为他没有考虑双字节的情况,造成获取字符串的宽度有问题,继而造成高度的不足”判断肯定是正确的
发的代码中,有进度条的窗口我没有汉化,结果汉化后,显示进度条压住了紧随进度条下方的文本,
这就不是添加 @CRLF 能解决的,摸索半天,用空格充足源代码的字节数,这才使进度条不压文本了,
但文本显示就不整齐了,创建进度条,位置参数使用的是变量,且变量又不是常数,我再好好看看它是如何计算的。。。。。
GUICtrlCreateProgress(10, $aRet * 5.5, $aRet - 20, 20)
131738 发表于 2010-8-13 01:09 http://www.autoitx.com/images/common/back.gif
在自动生成的界面中再添加控件,比如第七界面的进度条、第八界面的计时Label,其实并无自动的需求,它完全是根据已经规定的$sMsg字符串来定的,并非自动调整,比如原$sMsg英文字符串,你删除下面的行,仅保留两行,同样不会显示进度条。所以,这个是需要自行调整数值的,就像写Gui界面一样。比如我把进度条用在下面,同样可以#************************************* 第八界面 size: 500 x 145 - Line height: 13 500 x 119 - 行高: 13
$sMsg = "这个界面的 'Wait' 等待标志参数值被设为 False. " & @CRLF & @CRLF
$sMsg &= "脚本在计时设定的时间内会连续显示这个界面,在计时装置完成之前, "
$sMsg &= "你可以观察到计数装置从 1 增到 20." & @CRLF & @CRLF & @CRLF & @CRLF
$sMsg &= "计时装置完成前,单击 符号按钮,界面将立即关闭 "
$sMsg &= "但无论怎样,20 秒计时完成之后,界面会自动关闭的" & @CRLF & @CRLF
_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 12)
$aRet = _Toast_Show("脚本连续显示界面", $sMsg, -20, False)
ConsoleWrite("界面尺寸: " & $aRet & " x " & $aRet & " - " & "行高: " & $aRet & @CRLF)
$hLabel = GUICtrlCreateLabel("", ($aRet - 20) / 2, $aRet * 6, 20, 20)
GUICtrlSetBkColor(-1, -2)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetFont(-1, 12)
$iCount = 0
$hProgress = GUICtrlCreateProgress(10, 135, 480, 20)
Do
$iCount += 1
GUICtrlSetData($hLabel, $iCount)
GUICtrlSetData($hProgress, $iCount / 20 * 100)
Sleep(1000)
Until $hToast_Handle = 0
Exit 修改了半天此脚本,终于要搞定了 修改了半天此脚本,终于要搞定了
afan 发表于 2010-8-13 18:31 http://www.autoitx.com/images/common/back.gif
等待看你的修改结果,然后对照源码学习你的技巧!!! 本帖最后由 131738 于 2010-8-14 20:09 编辑
回复 8# afan
又搜到一套脚本,是 1 楼脚本的改良,包含文件独立在外,且有参数描述发布于今年7月初:
http://www.autoitscript.com/forum/index.php?showtopic=108445&st=0&p=764115&hl=Toastzip&fromsearch=1&#entry764115
作者曾经帮助过这里写电脑硬件测温工具的那位网友
包含文件:Toast.au3#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.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
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
Global $iToast_Header_Col = $aRet
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 clicked
; _Toast_WM_EVENTS: Message handler to check if closure 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 - The colour for the title bar background
; $iHdr_Col - The colour for the title bar text
; $iMsg_BkCol - The colour for the message background
; $iMsg_Col - 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 - The font size in points to use for the Toast
; $sFont_Name - 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
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
$iToast_Header_Col = $aRet
$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
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
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", 8) ; $COLOR_WINDOWTEXT = 8
$iToast_Message_BkCol= $aRet
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
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 is added to the title bar. Clicking 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:
; 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
; 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 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
;Set line height for this font
Local $iLine_Height = $aLabel_Pos
; Set label size
Local $iLabelwidth= $aLabel_Pos
Local $iLabelheight = $aLabel_Pos
; 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
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, $aToast_Data, 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_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", $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 if needed
If $iDelay < 0 Then
; Create
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 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
$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)
; 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 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 = [$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
; Find systray
Local $iPrevMode = Opt("WinTitleMatchMode", 4)
Local $aTray_Pos = WinGetPos("")
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 > 0 Then
$iToast_Move = 0x00050004 ; $AW_SLIDE_OUT_BOTTOM
$aToast_Data = @DesktopWidth - $iToast_Width - 10
$aToast_Data = $aTray_Pos - $iToast_Height
$aToast_Data = 0x00040008 ; $AW_SLIDE_IN_BOTTOM
Elseif $aTray_Pos > 0 Then
$iToast_Move = 0x00050001 ; $AW_SLIDE_OUT_RIGHT
$aToast_Data = $aTray_Pos - $iToast_Width
$aToast_Data = @DesktopHeight - $iToast_Height - 10
$aToast_Data = 0x00040002 ; $AW_SLIDE_IN_RIGHT
ElseIf $aTray_Pos = @DesktopWidth Then
$iToast_Move = 0x00050008 ; $AW_SLIDE_OUT_TOP
$aToast_Data = @DesktopWidth - $iToast_Width - 10
$aToast_Data = $aTray_Pos + $aTray_Pos
$aToast_Data = 0x00040004 ; $AW_SLIDE_IN_TOP
ElseIf $aTray_Pos = @DesktopHeight Then
$iToast_Move = 0x00050002 ; $AW_SLIDE_OUT_LEFT
$aToast_Data = $aTray_Pos + $aTray_Pos
$aToast_Data = @DesktopHeight - $iToast_Height - 10
$aToast_Data = 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 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 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 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 = $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;int;int;byte;int;int;byte;byte;byte")
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", 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 回复 10# 131738
StringSize.au3#include-once
; #INDEX# ============================================================================================================
; Title .........: _StringSize
; AutoIt Version : v3.2.12.1 or higher
; Language ......: English
; Description ...: Returns size of rectangle required to display string - width can be chosen
; Remarks .......:
; Note ..........:
; Author(s) .....: Melba23
; ====================================================================================================================
;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
; #CURRENT# ==========================================================================================================
; _StringSize: Returns size of rectangle required to display string - maximum permitted width can be chosen
; ====================================================================================================================
; #INTERNAL_USE_ONLY#=================================================================================================
; _StringSize_Error: Returns from error condition after DC and GUI clear up
; ====================================================================================================================
; #FUNCTION# =========================================================================================================
; Name...........: _StringSize
; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen
; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth]]]]])
; Parameters ....: $sText - String to display
; $iSize - Font size in points - default AutoIt GUI default
; $iWeight - Font weight (400 = normal) - default AutoIt GUI default
; $iAttrib - Font attribute (0-Normal, 2-Italic, 4-Underline, 8 Strike - default AutoIt
; $sName - Font name - default AutoIt GUI default
; $iWidth- Width of rectangle - default is unwrapped width of string
; Requirement(s) : v3.2.12.1 or higher
; Return values .: Success - Returns array with details of rectangle required for text:
; |$array = String formatted with @CRLF at required wrap points
; |$array = Height of single line in selected font
; |$array = Width of rectangle required to hold formatted string
; |$array = Height of rectangle required to hold formatted string
; Failure - Returns 0 and sets @error:
; |1 - Incorrect parameter type (@extended = parameter index)
; |2 - Failure to create GUI to test label size
; |3 - DLL call error - extended set to indicate which
; |4 - Font too large for chosen width - longest word will not fit
; Author ........: Melba23
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
;=====================================================================================================================
Func _StringSize($sText, $iSize = Default, $iWeight = Default, $iAttrib = Default, $sName = Default, $iWidth = 0)
Local $avSize_Info, $aRet, $iLine_Width = 0, $iLast_Word, $iWrap_Count
Local $hLabel_Handle, $hFont, $hDC, $oFont, $tSize = DllStructCreate("int X;int Y")
; Check parameters are correct type
If Not IsString($sText) Then Return SetError(1, 1, 0)
If Not IsNumber($iSize) And $iSize <> Default Then Return SetError(1, 2, 0)
If Not IsInt($iWeight)And $iWeight <> Default Then Return SetError(1, 3, 0)
If Not IsInt($iAttrib)And $iAttrib <> Default Then Return SetError(1, 4, 0)
If Not IsString($sName) And $sName <> Default Then Return SetError(1, 5, 0)
If Not IsNumber($iWidth) Then Return SetError(1, 6, 0)
; Create GUI to contain test labels, set to required font parameters
Local $hGUI = GUICreate("", 1200, 500, 10, 10)
If $hGUI = 0 Then Return SetError(2, 0, 0)
GUISetFont($iSize, $iWeight, $iAttrib, $sName)
; Store unwrapped text
$avSize_Info = $sText
; Ensure EoL is @CRLF and break text into lines
If StringInStr($sText, @CRLF) = 0 Then StringRegExpReplace($sText, "[\x0a|\x0d]", @CRLF)
Local $asLines = StringSplit($sText, @CRLF, 1)
; Draw label with unwrapped lines to check on max width
Local $hText_Label = GUICtrlCreateLabel($sText, 10, 10)
Local $aiPos = ControlGetPos($hGUI, "", $hText_Label)
GUISetState(@SW_HIDE)
GUICtrlDelete($hText_Label)
; Store line height for this font size after removing label padding (always 8)
$avSize_Info = ($aiPos - 8)/ $asLines
; Store width and height of this label
$avSize_Info = $aiPos
$avSize_Info = $aiPos - 4 ; Reduce margin
; Check if wrapping is required
If $aiPos > $iWidth And $iWidth > 0 Then
; Set returned text element to null
$avSize_Info = ""
; Set width element to max allowed
$avSize_Info = $iWidth
; Set line count to zero
Local $iLine_Count = 0
; Take each line in turn
For $j = 1 To $asLines
; Size this line unwrapped
$hText_Label = GUICtrlCreateLabel($asLines[$j], 10, 10)
$aiPos = ControlGetPos($hGUI, "", $hText_Label)
GUICtrlDelete($hText_Label)
; Check wrap status
If $aiPos < $iWidth Then
; No wrap needed so count line and store
$iLine_Count += 1
$avSize_Info &= $asLines[$j] & @CRLF
Else
; Wrap needed so need to count wrapped lines
; Create label to hold line as it grows
$hText_Label = GUICtrlCreateLabel("", 0, 0)
; Initialise Point32 method
$hLabel_Handle = ControlGetHandle($hGui, "", $hText_Label)
; Get DC with selected font
$aRet = DllCall("User32.dll", "hwnd", "GetDC", "hwnd", $hLabel_Handle)
If @error Then _StringSize_Error(3, 1, $hLabel_Handle, 0, $hGUI)
$hDC = $aRet
$aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont
If @error Then _StringSize_Error(3, 2, $hLabel_Handle, $hDC, $hGUI)
$hFont = $aRet
$aRet = DllCall("GDI32.dll", "hwnd", "SelectObject", "hwnd", $hDC, "hwnd", $hFont)
If @error Then _StringSize_Error(3, 3, $hLabel_Handle, $hDC, $hGUI)
$oFont = $aRet
If $oFont = 0 Then _StringSize_Error(3, 4, $hLabel_Handle, $hDC, $hGUI)
; Zero counter
$iWrap_Count = 0
While 1
; Set line width to 0
$iLine_Width = 0
; Initialise pointer for end of word
$iLast_Word = 0
For $i = 1 To StringLen($asLines[$j])
; Is this just past a word ending?
If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1
; Increase line by one character
Local $sTest_Line = StringMid($asLines[$j], 1, $i)
; Place line in label
GUICtrlSetData($hText_Label, $sTest_Line)
; Get line length into size structure
$iSize = StringLen($sTest_Line)
DllCall("GDI32.dll", "int", "GetTextExtentPoint32", "hwnd", $hDC, "str", $sTest_Line, "int", $iSize, "ptr", DllStructGetPtr($tSize))
If @error Then _StringSize_Error(3, 5, $hLabel_Handle, $hDC, $hGUI)
$iLine_Width = DllStructGetData($tSize, "X")
; If too long exit the loop
If $iLine_Width >= $iWidth - Int($iSize / 2) Then ExitLoop
Next
; End of the line of text?
If $i > StringLen($asLines[$j]) Then
; Yes, so add final line to count
$iWrap_Count += 1
; Store line
$avSize_Info &= $sTest_Line & @CRLF
ExitLoop
Else
; No, but add line just completed to count
$iWrap_Count += 1
; Check at least 1 word completed or return error
If $iLast_Word = 0 Then
_StringSize_Error(4, 0, $hLabel_Handle, $hDC, $hGUI)
EndIf
; Store line up to end of last word
$avSize_Info &= StringLeft($sTest_Line, $iLast_Word) & @CRLF
; Strip string to point reached
$asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word)
; Trim leading whitespace
$asLines[$j] = StringStripWS($asLines[$j], 1)
; Repeat with remaining characters in line
EndIf
WEnd
; Add the number of wrapped lines to the count
$iLine_Count += $iWrap_Count
; Clean up
DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hLabel_Handle, "hwnd", $hDC)
If @error Then _StringSize_Error(3, 6, $hLabel_Handle, $hDC, $hGUI)
GUICtrlDelete($hText_Label)
EndIf
Next
; Convert lines to pixels and add reduced margin
$avSize_Info = ($iLine_Count * $avSize_Info) + 4
EndIf
; Clean up
GUIDelete($hGUI)
; Return array
Return $avSize_Info
EndFunc ; => _StringSize
; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _StringSize_Error
; Description ...: Returns from error condition after DC and GUI clear up
; Syntax ........: _StringSize_Error($iError, $iExtended, $hLabel_Handle, $hDC, $hGUI)
; Parameters ....: $iError- required error value to return
; $iExtended - required extended value to return
; $hLabel_Handle, $hDC, $hGUI - variables as set in _StringSize function
; Author ........: Melba23
; Modified.......:
; Remarks .......: This function is used internally by _StringSize
; ===============================================================================================================================
Func _StringSize_Error($iError, $iExtended, $hLabel_Handle, $hDC, $hGUI)
; Release DC if created
DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hLabel_Handle, "hwnd", $hDC)
; Delete GUI
GUIDelete($hGUI)
; Return with extended set
Return SetError($iError, $iExtended, 0)
EndFunc ; => _StringSize_Error 本帖最后由 131738 于 2010-8-14 00:56 编辑
回复 11# 131738
示例文件:Toast_Example.au3;Example Toast
#include "Toast.au3"
Local $sMsg, $hProgress, $aRet
$sMsg= "The message text goes in this area" & @CRLF & @CRLF
$sMsg &= "This Toast uses the System colours and font"
$aRet = _Toast_Show(0, "The Title text goes here", $sMsg, 5)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & @CRLF)
_Toast_Hide()
$sMsg= "This Toast uses colours and font defined in a _Toast_Set call." & @CRLF & @CRLF
$sMsg &= "Subsequent Toasts will use these values until they are reset by another _Toast_Set call" & @CRLF & @CRLF
$sMsg &= "You can also display a standard icon - or one from an exe as here" & @CRLF & @CRLF
$sMsg &= "The next Toast has a very small message to show the pre-set minimum size"
_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10, "Arial")
$aRet = _Toast_Show(@AutoItExe, "User-defined Colours and Bold Header", $sMsg, 10)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & @CRLF)
_Toast_Hide()
$aRet = _Toast_Show(0, "", "Tiny", 2)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & @CRLF)
_Toast_Hide()
$sMsg= "These lines are of medium length" & @CRLF & @CRLF
$sMsg &= "The width is set by the longest" & @CRLF & @CRLF
$sMsg &= "No wrapping occurs here" & @CRLF & @CRLF
$sMsg &= "Note increased font size"
_Toast_Set(-1, -1, -1, -1, -1, 15)
$aRet = _Toast_Show(0, "Mid Width", $sMsg, 5)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & @CRLF)
_Toast_Hide()
$sMsg= "This is a long message set to left justified and a much larger font using _Toast_Set" & @CRLF & @CRLF
$sMsg &= "The Toast is automatically set to the maximum preset width and the message text "
$sMsg &= "is wrapped as necessary to fit within the margins of the Toast" & @CRLF & @CRLF
$sMsg &= "The Toast colours and weight have been changed by another _Toast_Set call" & @CRLF & @CRLF
$sMsg &= "Note the closure on the title bar.This Toast will time out in 30 secs "
$sMsg &= "but clicking the will resume the script immediately"
_Toast_Set(0, -1, 0xFFFF00, 0x00FF00, 0x000000, 15, "Courier New")
$aRet = _Toast_Show(64, "Max Width and Normal Header", $sMsg, -30)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & @CRLF)
_Toast_Hide()
$sMsg= "This line is very long to show that you can override the pre-set maximum width with the 'Raw' parameter. "
$sMsg &= "You have to add a few more parameters to the _Toast_Show call but that is a small price to pay"
$sMsg &= @CRLF & @CRLF & "However, the Toast will not display if it does not fit on the screen!"
_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10, "Arial")
$aRet = _Toast_Show(0, "Unwrapped Toast", $sMsg, -20, True, True)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & @CRLF)
_Toast_Hide()
$sMsg= "Note how Toasts adjust automatically in height to display all of the message "
$sMsg &= "regardless of whether there is a title bar to display, the font used, "
$sMsg &= "the number of lines or whether wrapping occurs" & @CRLF & @CRLF
$sMsg &= "This Toast will retract automatically when the next Toast is called "
$sMsg &= "or when the is clicked"
$aRet = _Toast_Show(0, "", $sMsg, -10)
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & @CRLF)
$sMsg= "This Toast has several blank lines inserted. "
$sMsg &= "This can be useful if you want to leave space to add other controls, "
$sMsg &= "such as a progress bar, to the Toast once it is displayed" & @CRLF & @CRLF & @CRLF & @CRLF
$sMsg &= "The Toast size is returned by the function so you can calculate "
$sMsg &= "where to place the other controls."
$sMsg &= "This example script writes the size in the SciTE console" & @CRLF & @CRLF
$sMsg &= "Note that Toast colours and font have been reset to Default"
_Toast_Set(Default)
$aRet = _Toast_Show(0, "Progress Bar", $sMsg, 0) ; No delay or progress bar will not display immediately
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & @CRLF)
$hProgress = GUICtrlCreateProgress(10, 65, $aRet - 20, 20)
For $i = 1 To 100
GUICtrlSetData($hProgress, $i)
Sleep(50)
Next
Sleep(5000)
_Toast_Hide()
$sMsg= "This Toast has the 'Wait' flag set to False. " & @CRLF & @CRLF
$sMsg &= "That means that the script will continue while the Toast is displayed as "
$sMsg &= "as you can see from this counter." & @CRLF & @CRLF
$sMsg &= "Clicking the will retract the Toast immediately but it will "
$sMsg &= "automatically retract after 20 seconds in any event"
_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10)
$aRet = _Toast_Show(32, "Script Continuing", $sMsg, -20, False) ; Delay can be set here because script continues
ConsoleWrite("Toast size: " & $aRet & " x " & $aRet & @CRLF)
$hLabel = GUICtrlCreateLabel("", 267, 98, 15, 15)
GUICtrlSetBkColor(-1, 0xFFFF00)
$iCount = 0
Do
$iCount += 1
GUICtrlSetData($hLabel, StringFormat("%2s", $iCount))
Sleep(1000)
Until $iCount = 60 Or $hToast_Handle = 0 ; Toast will retract automatically before $iCount = 60
Exit1 楼的可能是早期代码,这是本年7月的改良脚本。。。。 这是昨天修改的,也是将例子分开了。
修改了_StringSize() ,在其最后增加了一个参数 $Lang ,为1时使用汉字环境(默认),为0时使用英文环境。
同时 _Toast_Show() 也同时增加了此参数。因为_StringSize() 是使用 _Toast_Show() 调用的 谢谢各位大侠 回复 13# afan
幸苦了。。。。谢谢!!!!!!!!!!!
页:
[1]
2