回复 11# tisiem
#NoTrayIcon
#AutoIt3Wrapper_Res_LegalCopyright=Any
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <Timers.au3>
#include <Date.au3>
Global $timer, $Secs, $Mins, $Hour
Dim $IniPath
Dim $G3name, $G3F5, $G3F6, $G3F7, $G3RF5, $G3RF6, $G3RF7, $GameVisibel
Dim $TransType, $Trans, $Side, $letop
$IniPath = StringMid(@ScriptFullPath, 1, StringLen(@ScriptFullPath) - 3) & "ini"
$G3name = IniRead($IniPath, "Game", "GameName", "休闲游戏")
$G3F5 = IniRead($IniPath, "Game", "GameName1", "扫雷")
$G3F6 = IniRead($IniPath, "Game", "GameName2", "纸牌")
$G3F7 = IniRead($IniPath, "Game", "GameName3", "空当接龙")
$G3RF5 = IniRead($IniPath, "Game", "GamePath1", "C:\Windows\system32\winmine.exe")
$G3RF6 = IniRead($IniPath, "Game", "GamePath2", "C:\Windows\system32\sol.exe")
$G3RF7 = IniRead($IniPath, "Game", "GamePath3", "C:\Windows\system32\freecell.exe")
$GameVisibel = IniRead($IniPath, "Game", "GameVisibel", "1")
$TransType = IniRead($IniPath, "Other", "TransType", "1")
$Side = IniRead($IniPath, "Other", "Side", "Right")
If $Side = "Right" Then
$letop = @DesktopWidth - 167
Else
$letop = 0
EndIf
$Form1 = GUICreate("Anycrane", 167, @DesktopHeight, $letop, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW))
GUISetBkColor(0xFFFBF0)
If $TransType = 1 Then
$Trans = 255
_API_SetLayeredWindowAttributes($Form1, 0xFFFBF0)
Else
$Trans = IniRead($IniPath, "Other", "Trans", "150")
_API_SetLayeredWindowAttributes($Form1, 0xFFFFFF)
EndIf
$Group1 = GUICtrlCreateGroup("时间", 0, 0, 165, 121, $BS_CENTER, $WS_EX_TRANSPARENT)
GUICtrlSetBkColor($Group1, $GUI_BKCOLOR_TRANSPARENT)
$Label1 = GUICtrlCreateLabel("系统日期:", 8, 23, 64, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label2 = GUICtrlCreateLabel("系统时间:", 8, 55, 64, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label3 = GUICtrlCreateLabel("已用时间:", 8, 87, 64, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label4 = GUICtrlCreateLabel(@YEAR & "-" & @MON & "-" & @MDAY, 72, 23, 80, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label5 = GUICtrlCreateLabel(StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 73, 55, 80, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label6 = GUICtrlCreateLabel("00 分 00 秒", 72, 87, 80, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xff0000)
GUICtrlSetFont(-1, 9, 600)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("系统资源", 0, 128, 165, 137, $BS_CENTER, $WS_EX_TRANSPARENT)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label7 = GUICtrlCreateLabel("CPU使用率:", 8, 160, 74, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label8 = GUICtrlCreateLabel("内存使用率:", 8, 208, 76, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Progress1 = GUICtrlCreateProgress(8, 184, 145, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Progress2 = GUICtrlCreateProgress(8, 232, 145, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label9 = GUICtrlCreateLabel("", 112, 160, 36, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label10 = GUICtrlCreateLabel("", 112, 208, 42, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateGroup("", -99, -99, 1, 1)
If $GameVisibel = 1 Then
$Group3 = GUICtrlCreateGroup($G3name, 0, 272, 165, 100, $BS_CENTER, $WS_EX_TRANSPARENT)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label11 = GUICtrlCreateLabel("F5:" & $G3F5, 16, 298, 76, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label12 = GUICtrlCreateLabel("F6:" & $G3F6, 16, 323, 76, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label13 = GUICtrlCreateLabel("F7:" & $G3F7, 16, 347, 76, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateGroup("", -99, -99, 1, 1)
EndIf
GUISetState()
WinSetOnTop("Anycrane", "", 1)
$timer = TimerInit()
AdlibRegister("CpuRamRate", 500)
_Timer_SetTimer($Form1, 100, "_UpdateClock")
HotKeySet("{Esc}", "quit")
HotKeySet("{F5}", "game1")
HotKeySet("{F6}", "game2")
HotKeySet("{F7}", "game3")
While 1
Sleep(100)
WEnd
Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = $Trans, $isColorRef = False)
Local Const $AC_SRC_ALPHA = 1
Local Const $ULW_ALPHA = 2
Local Const $LWA_ALPHA = 0x2
Local Const $LWA_COLORKEY = 0x1
If Not $isColorRef Then
$i_transcolor = Hex(String($i_transcolor), 6)
$i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
EndIf
Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
Select
Case @error
Return SetError(@error, 0, 0)
Case $Ret[0] = 0
Return SetError(4, 0, 0)
Case Else
Return 1
EndSelect
EndFunc ;==>_API_SetLayeredWindowAttributes
Func _UpdateClock($hwnd, $Msg, $iIDTimer, $dwTime)
_TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs)
GUICtrlSetData($Label5, StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC))
GUICtrlSetData($Label6, StringFormat("%02i 分 %02i 秒", $Mins, $Secs))
GUICtrlSetData($Label4, @YEAR & "-" & @MON & "-" & @MDAY)
EndFunc ;==>_UpdateClock
Func CpuRamRate()
Local $rCPU, $rRAM
$rCPU = CurrentCPURate()
$rRAM = CurrentRAMRate()
GUICtrlSetData($Progress1, $rCPU)
GUICtrlSetData($Label9, $rCPU & "%")
GUICtrlSetData($Progress2, $rRAM)
GUICtrlSetData($Label10, $rRAM & "%")
EndFunc ;==>CpuRamRate
Func CurrentCPURate()
$wbemServices = ObjGet("winmgmts:\\.\root\cimv2")
$wbemObjectSet = $wbemServices.ExecQuery("Select * from Win32_Processor")
For $wbemObject In $wbemObjectSet
$dd = $wbemObject.LoadPercentage
Next
Return $dd
EndFunc ;==>CurrentCPURate
Func CurrentRAMRate()
Local $Array[7]
$Array = MemGetStats()
Return $Array[0]
EndFunc ;==>CurrentRAMRate
Func game1()
Run($G3RF5)
EndFunc ;==>game1
Func game2()
Run($G3RF6)
EndFunc ;==>game2
Func game3()
Run($G3RF7)
EndFunc ;==>game3
Func quit()
Exit 0
EndFunc ;==>quit
|