|
|
本帖最后由 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[4], $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[0] = $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[1] = ($aiPos[3] - 8) / $asLines[0]
- $avSize_Info[2] = $aiPos[2]
- $avSize_Info[3] = $aiPos[3] - 4
- If $aiPos[2] > $iWidth And $iWidth > 0 Then
- $avSize_Info[0] = ""
- $avSize_Info[2] = $iWidth
- Local $iLine_Count = 0
- For $j = 1 To $asLines[0]
- $hText_Label = GUICtrlCreateLabel($asLines[$j], 10, 10)
- $aiPos = ControlGetPos($hGUI, "", $hText_Label)
- GUICtrlDelete($hText_Label)
- If $aiPos[2] < $iWidth Then
- $iLine_Count += 1
- $avSize_Info[0] &= $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[0]
- $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[0]
- $aRet = DllCall("GDI32.dll", "hwnd", "SelectObject", "hwnd", $hDC, "hwnd", $hFont)
- If @error Then _StringSize_Error(3, 3, $hLabel_Handle, $hDC, $hGUI)
- $oFont = $aRet[0]
- 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[0] &= $sTest_Line & @CRLF
- ExitLoop
- Else
- $iWrap_Count += 1
- If $iLast_Word = 0 Then
- _StringSize_Error(4, 0, $hLabel_Handle, $hDC, $hGUI)
- EndIf
- $avSize_Info[0] &= 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[3] = ($iLine_Count * $avSize_Info[1]) + 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[0]
- $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5)
- Global $iToast_Header_Col = $aRet[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
- 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[0]
- $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 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
- 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[0]
- 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[0]
- 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[0]
- 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[0]
- 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[0]
- Local $iLine_Height = $aLabel_Pos[1]
- Local $iLabelwidth = $aLabel_Pos[2]
- Local $iLabelheight = $aLabel_Pos[3]
- 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[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)
- 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[2])
- 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[3] = [$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[3]
- Local $iPrevMode = Opt("WinTitleMatchMode", 4)
- Local $aTray_Pos = WinGetPos("[CLASS:Shell_TrayWnd]")
- Opt("WinTitleMatchMode", $iPrevMode)
- If Not IsArray($aTray_Pos) Then Return SetError(2, 0, -1)
- If $aTray_Pos[1] > 0 Then
- $iToast_Move = 0x00050004
- $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
- $aToast_Data[1] = $aTray_Pos[1] - $iToast_Height
- $aToast_Data[2] = 0x00040008
- ElseIf $aTray_Pos[0] > 0 Then
- $iToast_Move = 0x00050001
- $aToast_Data[0] = $aTray_Pos[0] - $iToast_Width
- $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
- $aToast_Data[2] = 0x00040002
- ElseIf $aTray_Pos[2] = @DesktopWidth Then
- $iToast_Move = 0x00050008
- $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
- $aToast_Data[1] = $aTray_Pos[1] + $aTray_Pos[3]
- $aToast_Data[2] = 0x00040004
- ElseIf $aTray_Pos[3] = @DesktopHeight Then
- $iToast_Move = 0x00050002
- $aToast_Data[0] = $aTray_Pos[0] + $aTray_Pos[2]
- $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
- $aToast_Data[2] = 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[4] = $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[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)
- 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
- Return Int((Abs(DllStructGetData($tLOGFONT, 1)) + 1) * .75)
- Case 1
- Return DllStructGetData($tLOGFONT, 14)
- EndSwitch
- EndFunc ;==>_Toast_GetDefFont
- Local $sMsg, $hProgress, $aRet[3]
- $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[0] & " x " & $aRet[1] & " - " & "Line height: " & $aRet[2] & @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[0] & " x " & $aRet[1] & " - " & "Line height: " & $aRet[2] & @CRLF)
- _Toast_Hide()
- $aRet = _Toast_Show("", "Tiny", 2)
- ConsoleWrite("Toast size: " & $aRet[0] & " x " & $aRet[1] & " - " & "Line height: " & $aRet[2] & @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[0] & " x " & $aRet[1] & " - " & "Line height: " & $aRet[2] & @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 [X] on the title bar. This Toast will time out in 30 secs "
- $sMsg &= "but clicking the [X] 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[0] & " x " & $aRet[1] & " - " & "Line height: " & $aRet[2] & @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 [X] is clicked"
- _Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10, "Arial")
- $aRet = _Toast_Show("", $sMsg, -10)
- ConsoleWrite("Toast size: " & $aRet[0] & " x " & $aRet[1] & " - " & "Line height: " & $aRet[2] & @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[0] & " x " & $aRet[1] & " - " & "Line height: " & $aRet[2] & @CRLF)
- $hProgress = GUICtrlCreateProgress(10, $aRet[2] * 5.5, $aRet[0] - 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 [X] 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[0] & " x " & $aRet[1] & " - " & "Line height: " & $aRet[2] & @CRLF)
- $hLabel = GUICtrlCreateLabel("", ($aRet[0] - 20) / 2, $aRet[2] * 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[0] & " x " & $aRet[1] & " - " & "行高: " & $aRet[2] & @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[0] & " x " & $aRet[1] & " - " & "行高: " & $aRet[2] & @CRLF)
- _Toast_Hide()
- # ************************************* 第三界面 size: 150 x 40 - Line height: 16 150 x 40 - 行高: 16
- $aRet = _Toast_Show("", "小界面", 2)
- ConsoleWrite("界面尺寸: " & $aRet[0] & " x " & $aRet[1] & " - " & "行高: " & $aRet[2] & @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[0] & " x " & $aRet[1] & " - " & "行高: " & $aRet[2] & @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 &= "请注意在标题栏中的关闭 [X] 符号。这个界面将持续 30 秒时间 "
- $sMsg &= "但点击 [X] 脚本将立即继续下面的操作"
- _Toast_Set(0, -1, 0xFFFF00, 0x00FF00, 0x000000, 15, "Courier New")
- $aRet = _Toast_Show("最大宽度与正常头", $sMsg, -30)
- ConsoleWrite("界面尺寸: " & $aRet[0] & " x " & $aRet[1] & " - " & "行高: " & $aRet[2] & @CRLF)
- _Toast_Hide()
- # ************************************* 第六界面 size: 500 x 125 - Line height: 16 500 x 77 - 行高: 16
- $sMsg = "注意界面如何自动调整高度,以显示全部消息 "
- $sMsg &= "不论是否有标题栏显示, 使用的字体, "
- $sMsg &= "行数或是否出现环绕" & @CRLF & @CRLF
- $sMsg &= "当调用下一个界面时,这个界面将自动缩回 "
- $sMsg &= "或点击 [X] 按钮时"
- _Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10, "Arial")
- $aRet = _Toast_Show("", $sMsg, -10)
- ConsoleWrite("界面尺寸: " & $aRet[0] & " x " & $aRet[1] & " - " & "行高: " & $aRet[2] & @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[0] & " x " & $aRet[1] & " - " & "行高: " & $aRet[2] & @CRLF)
- $hProgress = GUICtrlCreateProgress(10, $aRet[2] * 5.5, $aRet[0] - 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 &= "计时装置完成前,单击 [X] 符号按钮,界面将立即关闭 "
- $sMsg &= "但无论怎样,20 秒计时完成之后,界面会自动关闭的"
- _Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 12)
- $aRet = _Toast_Show("脚本连续显示界面", $sMsg, -20, False)
- ConsoleWrite("界面尺寸: " & $aRet[0] & " x " & $aRet[1] & " - " & "行高: " & $aRet[2] & @CRLF)
- $hLabel = GUICtrlCreateLabel("", ($aRet[0] - 20) / 2, $aRet[2] * 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
复制代码 |
评分
-
查看全部评分
|