一个悬浮窗的代码 怎么能让窗口上的按钮起作用[已解决]
本帖最后由 pyj521 于 2012-10-7 22:52 编辑下面是一个悬浮窗的代码 怎么能让窗口上的按钮起作用请大大们帮忙加上一段代码号码 也可以有偿帮助 小弟穷 多了给不起!谢谢各位了。拜托!!!!!!!!!在线等待
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=D:\autoit3\Aut2Exe\Icons\OhMy! Cyclop Icon 173.ico
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Global $start
Global $n = 0
Global $pos
Global $clickspeed = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "DoubleClickSpeed")
$title2 = "双击了"
$AForm1 = GUICreate("", 38, 38, 600, 60, BitOR($WS_SYSMENU, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER), $WS_EX_TOOLWINDOW)
GUISetBkColor(0xBFDBFF)
$icon = GUICtrlCreateIcon(@ScriptDir & "\Canon.ani", -1, 3, 3)
GUICtrlSetState(-1, $GUI_DISABLE)
$ContextMenu = GUICtrlCreateContextMenu()
Dim $JiaNMC, $i
$JiaNMC = IniReadSection(@ScriptDir & "\Canon.ini", "Name")
Dim $RunProAr[$JiaNMC + 1]
For $i = 1 To $JiaNMC
$RunProAr[$i] = GUICtrlCreateMenuItem($JiaNMC[$i], $ContextMenu)
Next
GUICtrlCreateMenuItem("", $ContextMenu)
$Help = GUICtrlCreateMenuItem("关于", $ContextMenu)
GUICtrlCreateMenuItem("", $ContextMenu)
$exit = GUICtrlCreateMenuItem("退出", $ContextMenu)
$AForm2 = GUICreate($title2, 390, 230, 213, 133)
$Button1 = GUICtrlCreateButton("服务器①", 24, 40, 145, 33)
$Button2 = GUICtrlCreateButton("服务器②", 24, 88, 145, 33)
$Button3 = GUICtrlCreateButton("服务器③", 24, 136, 145, 33)
$Button4 = GUICtrlCreateButton("服务器④", 24, 184, 145, 33)
$Label1 = GUICtrlCreateLabel("机房Ⅰ", 56, 0, 79, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Button5 = GUICtrlCreateButton("服务器①", 216, 40, 145, 33)
$Button6 = GUICtrlCreateButton("服务器②", 216, 88, 145, 33)
$Button7 = GUICtrlCreateButton("服务器③", 216, 136, 145, 33)
$Button8 = GUICtrlCreateButton("服务器③", 216, 184, 145, 33)
$Label2 = GUICtrlCreateLabel("机房Ⅱ", 248, 0, 79, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUISetState(@SW_SHOW, $AForm1)
WinSetOnTop($AForm1, "", 1)
WinSetTrans($AForm1, "", 200)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $RunProAr To $RunProAr[$JiaNMC]
_RunPro()
Case $GUI_EVENT_PRIMARYDOWN
_PRIMARYdown()
Case $Help
about()
Case $GUI_EVENT_CLOSE
GUISetState(@SW_HIDE, $AForm2)
Case $exit
Exit
EndSwitch
WEnd
Func about()
MsgBox(262144, "关于:", "这是一个关于悬浮窗的演示程序。" & @CRLF & @CRLF _
& " By Pcbar 2007.09.21" & @CRLF & " Modify By 顽固不化 2009.11.3")
EndFunc ;==>about
Func _RunPro()
For $i = 1 To $JiaNMC
If $RunProAr[$i] = $nMsg Then
ShellExecute($JiaNMC[$i])
ExitLoop
EndIf
Next
EndFunc ;==>_RunPro
Func Move()
Dim $PosDiff, $MousePos, $WinPos
$MousePos = MouseGetPos()
$WinPos = WinGetPos($AForm1)
$PosDiff = $WinPos - $MousePos
$PosDiff = $WinPos - $MousePos
While _IsPressed("01", DllOpen("user32.dll"))
$MousePos = MouseGetPos()
WinMove($AForm1, "", $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
$n = 0
ShowHidemain()
Else
$start = TimerInit()
$n = 1
EndIf
EndIf
EndFunc ;==>_PRIMARYdown
Func ShowHidemain()
If _WinIsVisible($AForm2) Then
If BitAND(WinGetState($title2, ""), 16) Then WinSetState($title2, "", @SW_RESTORE)
WinActivate($AForm2)
Return
Else
GUISetState(@SW_SHOW, $AForm2)
EndIf
EndFunc ;==>ShowHidemain
Func _WinIsVisible($hWnd, $Text = "")
Return BitAND(WinGetState($hWnd, $Text), 2)
EndFunc ;==>_WinIsVisible
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $RunProAr To $RunProAr[$JiaNMC]
_RunPro()
Case $GUI_EVENT_PRIMARYDOWN
_PRIMARYdown()
Case $Help
about()
Case $GUI_EVENT_CLOSE
GUISetState(@SW_HIDE, $AForm2)
Case $exit
Exit
case $button1
msgbox(0,"","1")
case $button2
msgbox(0,"","2")
EndSwitch
WEnd 或者用GUICtrlSetOnEven也可以
Azura 发表于 2012-10-5 20:24 http://www.autoitx.com/images/common/back.gif
可行 万分感激!谢谢我的朋友! 注册windows消息是肯定可以处理的,也好判断。
页:
[1]