;#NoTrayIcon
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <winapiex.au3>
Opt("GUIOnEventMode", 1)
$hwnd = GUICreate("GDI+Example", 780, 40, -1, 1, $WS_POPUP, $WS_EX_LAYERED, WinGetHandle(AutoItWinGetTitle()))
GUISetBkColor(0xabcdef)
;创建窗口
$label = GUICtrlCreateLabel("", -1, -1, 780, 40, $WS_POPUP)
;创建静态标签(Label)控件
GUICtrlSetBkColor(-1,-2)
GUISetBkColor(0xabcdef)
;为GUI窗口设置背景颜色
_WinAPI_SetLayeredWindowAttributes($hwnd, 0xff010101, 255)
;设置分层窗口属性
GUISetState()
_GDIPlus_Startup()
;初始化微软 Windows GDI+
$graphics = _GDIPlus_GraphicsCreateFromHWND(ControlGetHandle($hwnd, "", $label))
;从窗口句柄创建图形对象
$bitmap = _GDIPlus_BitmapCreateFromGraphics(780, 40, $graphics)
;在一个图形对象上创建基于宽度和高度的位图对象
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
;获取图像的图形场景
$ffamily = _GDIPlus_FontFamilyCreate("Arial")
;字休
$arial = _GDIPlus_FontCreate($ffamily, 24, 1)
;字体大小
$sformat = _GDIPlus_StringFormatCreate(0x1000)
;滚动方式0x0001 - 阅读顺序从右到左
_GDIPlus_StringFormatSetAlign($sformat, 1)
;文本居中对齐
$blackbrush = _GDIPlus_BrushCreateSolid(0xFF9900ff)
;字体着色
$pos = 0
$speed = 1
$text = FileRead(@ScriptDir & "\bin.txt")
Do
_GDIPlus_GraphicsClear($backbuffer, 0xff010101)
$pos -= $speed
$rectf = _GDIPlus_RectFCreate($pos, 0, 0, 0)
$arr = _GDIPlus_GraphicsMeasureString($graphics, $text, $arial, $rectf, $sformat)
;测量字符串
$stringwidth = DllStructGetData($arr[0], "Width")
;返回数据结构
If $pos < -$stringwidth Then $pos = $stringwidth
_GDIPlus_GraphicsDrawStringEx($backbuffer, $text, $arial, $rectf, $sformat, $blackbrush)
;使用数据结构绘制字符串
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 780, 40)
;图像绘制到指定的位置
Sleep(1)
_ReduceMemory(@AutoItPID)
Until False
Func _ReduceMemory($i_PID = -1)
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