#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3> ;系统控制需要函数.
#include <Misc.au3> ;移动窗口用的
Opt("TrayOnEventMode",1) ;应用/关闭 OnEvent 函数通知于系统托盘图标. 0 = (默认) 关闭 1 = 应用
Break(0) ;禁止用户从脚本程序的托盘菜单中退出
;防止程序重复打开
$title = "Music"
If WinExists($title) Then Exit
;设置热键
Global $Paused
HotKeySet("{PAUSE}", "MinimiZe")
HotKeySet("{HOME}", "WinRestore")
HotKeySet("{END}", "Terminate")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "WinRestore") ;鼠标主要按键(通常左键)在托盘图标上按下.
TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN, "WinRestore") ;鼠标次要按键(通常右键)在托盘图标上按下.
$Form1 = GUICreate("Music", 300, 380, -1, -1, $WS_POPUP)
$Label1 = GUICtrlCreateLabel("", 0, 0, 270, 20) ;标题空白LABEL
$Label2 = GUICtrlCreateLabel("", 270, 7, 15, 15) ;关闭LABEL
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "关闭")
;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)
$os = ObjCreate("Shell.Explorer.2")
GUISetState(@SW_SHOW)
$GUIActiveX = GUICtrlCreateObj($os, 0, 0, 300, 500)
$os.navigate("http://music.sina.com.cn/iframe/yueku/msnshell/msnshellplayer.shtml")
;内存清理放在这儿是否正确
$List=ProcessList()
For $x=1 to $List[0][0]
_EmptyMyScriptMem($List[$x][1])
Next
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $GUI_EVENT_MINIMIZE ;对话框(窗口)被最小化(窗口标题栏上的最小化按钮被点击).
GUISetState(@SW_HIDE, $Form1)
TrayTip("我藏在这里", "用我的时候点我,或按Home呼出", 1, 1) ;最小化时气泡提示
Case $GUI_EVENT_PRIMARYDOWN
Click($Form1) ;移动窗口控件
EndSwitch
WEnd
Func MinimiZe() ;热键最小化
GUISetState(@SW_HIDE, $Form1)
TrayTip("我藏在这里", "用我的时候点我,或按Home呼出", 1, 1) ;最小化时气泡提示
EndFunc
Func Click($GUI) ;窗口拖动
$MS = GUIGetCursorInfo($GUI)
If $MS[4] = $Label1 Then
Local $PosDiff[2], $MousePos, $WinPos
$MousePos = MouseGetPos()
$WinPos = WinGetPos($GUI, "")
$PosDiff[0] = $WinPos[0] - $MousePos[0]
$PosDiff[1] = $WinPos[1] - $MousePos[1]
While _IsPressed("01", DllOpen("user32.dll"))
$MousePos = MouseGetPos()
WinMove($GUI, "", $MousePos[0] + $PosDiff[0], $MousePos[1] + $PosDiff[1])
Sleep(10)
WEnd
ElseIf $MS[4] = $Label2 Then
Exit
EndIf
EndFunc
Func Terminate() ;热键退出程序
Exit 0
EndFunc
Func WinRestore() ;热键显示窗口
GUISetState(@SW_SHOW, $Form1)
EndFunc
Func _EmptyMyScriptMem($PID) ;内存清理函数
Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $PID)
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
DllCall("kernel32.dll" , 'int', 'CloseHandle', 'int', $ai_Handle[0])
EndFunc