lele9013 发表于 2008-12-23 10:14:37

以前有人发布的 类似迅雷的 悬浮窗 代码谁还有??

如题。。

一下子找不到饿 郁闷

范统.贾 发表于 2008-12-23 13:34:30

我想,大概是这个吧。。。


#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $start
Global $n = 0
Global $pos
Global $clickspeed = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "DoubleClickSpeed")
Opt("GUIOnEventMode", 1)
$title = "mygui"
$title2="悬浮窗演示"
$AForm1 = GUICreate($title, 38, 38, 750, 100, BitOR($WS_SYSMENU, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER), $WS_EX_TOOLWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit", $AForm1)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, '_PRIMARYdown', $AForm1)
GUISetOnEvent($GUI_EVENT_PRIMARYUP, '_PRIMARYup', $AForm1)
GUISetBkColor(0xBFDBFF)
$icon = GUICtrlCreateIcon(@WindowsDir & "\cursors\horse.ani", -1, 3, 3)
GUICtrlSetState(-1, $GUI_DISABLE)

$Rm = GUICtrlCreateContextMenu()
$title3 = GUICtrlCreateMenuItem("打开/隐藏主窗口", $Rm)
GUICtrlSetOnEvent(-1, "showhidemain")
GUICtrlCreateMenuItem("", $Rm)
$Help = GUICtrlCreateMenuItem("关于", $Rm)
GUICtrlSetOnEvent(-1, "about")
GUICtrlCreateMenuItem("", $Rm)
$exit = GUICtrlCreateMenuItem("退出", $Rm)
GUICtrlSetOnEvent(-1, "_exit")

$AForm2 = GUICreate($title2, 400, 300, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "showhidemain", $AForm2)
$label1 = GUICtrlCreateLabel("这是主程序窗口", 50, 100)
GUISetState(@SW_SHOW, $AForm1)

WinSetOnTop($AForm1, "", 1)
WinSetTrans($AForm1, "", 200)
While 1
        Sleep(100)
WEnd

Func _exit()
        GUIDelete()
        Exit
EndFunc   ;==>_exit

Func about()
        MsgBox(262144, "关于:", "这是一个关于悬浮窗的演示程序。" & @CRLF & @CRLF & "   By Pcbar 2007.09.21")
EndFunc   ;==>about

Func Move()
        Dim $PosDiff, $MousePos, $WinPos
        $MousePos = MouseGetPos()
        $WinPos = WinGetPos($title, "")
        $PosDiff = $WinPos - $MousePos
        $PosDiff = $WinPos - $MousePos
        While _IsPressed("01", DllOpen("user32.dll"))
                $MousePos = MouseGetPos()
                WinMove($title, "", $MousePos + $PosDiff, $MousePos + $PosDiff)
                Sleep(10)
        WEnd
EndFunc   ;==>Move
Func _PRIMARYdown()
        Move()
        $pos = MouseGetPos()
        $guiPos = WinGetPos($AForm1, '')
        If ($pos >= $guiPos And $pos <= $guiPos + $guiPos) And _
                        ($pos >= $guiPos And $pos <= $guiPos + $guiPos) Then
                $n += 1
                If $n = 2 And (TimerDiff($start) < $clickspeed) Then
                        ShowHidemain()
                Else
                        $start = TimerInit()
                        $n = 1
                EndIf
        EndIf
EndFunc   ;==>_PRIMARYdown
Func _PRIMARYup()
        If $n = 2 Then
                $n = 0
        Else
                $start = TimerInit()
        EndIf
EndFunc   ;==>_PRIMARYup

Func ShowHidemain()
    If _WinIsVisible($AForm2) Then
      GUISetState(@SW_HIDE,$AForm2)
    Else
      GUISetState(@SW_SHOW,$AForm2)
                if BitAND(WinGetState($title2,""),16) then WinSetState($title2,"",@SW_RESTORE)
      WinActivate($AForm2)
    EndIf
EndFunc

Func _WinIsVisible($hWnd, $Text="")
    Return BitAND(WinGetState($hWnd, $Text), 2)
EndFunc

yellow881 发表于 2008-12-24 09:29:33

脚本里这一行有错:
_IsPressed("01", DllOpen("user32.dll"))

大绯狼 发表于 2008-12-24 14:14:31

#Include <Misc.au3>

UID 发表于 2008-12-24 16:21:25

收下了:face (31):

menfan 发表于 2009-10-29 20:49:40

温习一下,呵呵

We! 发表于 2009-11-3 03:51:13

哈~這個好玩,我也收下了...。
页: [1]
查看完整版本: 以前有人发布的 类似迅雷的 悬浮窗 代码谁还有??