#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Misc.au3>
#include <WinAPI.au3>
Opt("GUICoordMode", 2)
Opt("GUIOnEventMode", 1)
Global $menu, $menu2, $menu3, $A1, $A2, $B1, $C1, $C2, $menushow = 0, $i = 1
Global $url, $Gui_h, $Gui_w, $Form1, $1, $2, $Form2, $Form3, $Label1
Global $PosDiff[2], $MousePos, $WinPos
$url = "http://WWW.HAO123.COM"
Global $Title = "HAO123"
$Gui_w = 482
$Gui_h = 290
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, -1, -1, $WS_POPUP + $WS_EX_LAYERED)
$WinPos = WinGetPos($Form1, "")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_mousedown")
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -30, -30, $Gui_w + 50, $Gui_h)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
_caidan()
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
GUICtrlSetState($2, $GUI_show)
While 1
_checkmenushow()
Sleep(150)
WEnd
Func _checkmenushow()
$MousePos = MouseGetPos()
$WinPos = WinGetPos($Form1)
;~ MsgBox(4096, "Get ClassName", "ClassName of " & $Form1 & ": " & _WinAPI_GetClassName($Form1),1)
;~ MsgBox(4096, "Get ClassName", "ClassName of " & $Form2 & ": " & _WinAPI_GetClassName($Form2),1)
If $MousePos[0] > $WinPos[0] And $MousePos[0] < $WinPos[0] + $WinPos[2] And $MousePos[1] > $WinPos[1] And $MousePos[1] < $WinPos[1] + $WinPos[3] Then
If WinActive($Form1) Then ;这样要form在激活状态下才能显示菜单,如何实现不用激活窗口,只要有可见的form1区域,鼠标移到该区域内即显示菜单呢?
GUISetState(@SW_SHOW, $Form2)
EndIf
Else
GUISetState(@SW_HIDE, $Form2)
EndIf
EndFunc ;==>_checkmenushow
Func _mousedown()
$M1 = GUIGetCursorInfo($Form1)
$M2 = GUIGetCursorInfo($Form2)
If $M1[4] = 0 Or $M2[4] = 0 Then ;点击网页中无超链接的地方和菜单空白处实现了移动窗口
$MousePos = MouseGetPos()
$WinPos = WinGetPos($Form1, "")
$PosDiff[0] = $WinPos[0] - $MousePos[0]
$PosDiff[1] = $WinPos[1] - $MousePos[1]
While _IsPressed("01", DllOpen("user32.dll"))
$MousePos = MouseGetPos()
WinMove($Form1, "", $MousePos[0] + $PosDiff[0], $MousePos[1] + $PosDiff[1])
;~ WinMove($Form2, "", $MousePos[0] + $PosDiff[0], $MousePos[1] + $PosDiff[1])
WEnd
EndIf
EndFunc ;==>_mousedown
Func _caidan()
$Form2 = GUICreate("", 200, 20, -1, -1, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_mousedown")
$menu = GUICtrlCreateMenu("菜单A")
$A1 = GUICtrlCreateMenuItem("HAO123", $menu)
GUICtrlSetOnEvent(-1, "_DT")
$A2 = GUICtrlCreateMenuItem("BAIDU", $menu)
GUICtrlSetOnEvent(-1, "_DT")
$menu2 = GUICtrlCreateMenu("菜单B")
$B1 = GUICtrlCreateMenuItem("SOHU", $menu2)
GUICtrlSetOnEvent(-1, "_DT")
$menu3 = GUICtrlCreateMenu("窗口")
$C1 = GUICtrlCreateMenuItem("最小化", $menu3)
GUICtrlSetOnEvent(-1, "_DT")
$C2 = GUICtrlCreateMenuItem("退出", $menu3)
GUICtrlSetOnEvent(-1, "_DT")
EndFunc ;==>_caidan
Func _DT()
Switch @GUI_CtrlId
Case $A1
GUIDelete($Form1)
$url = "http://WWW.HAO123.COM"
Global $Title = "HAO123"
$Gui_w = 482
$Gui_h = 290
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, $WinPos[0], $WinPos[1], $WS_POPUP + $WS_EX_LAYERED)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_mousedown")
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -30, -30, $Gui_w + 50, $Gui_h)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
_caidan()
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
GUICtrlSetState($2, $GUI_show)
Case $A2
GUIDelete($Form1)
$url = "http://WWW.baidu.COM"
Global $Title = "baidu"
$Gui_w = 482
$Gui_h = 290
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, $WinPos[0], $WinPos[1], $WS_POPUP + $WS_EX_LAYERED)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_mousedown")
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -30, -30, $Gui_w + 50, $Gui_h)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
_caidan()
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
GUICtrlSetState($2, $GUI_show)
Case $B1
GUIDelete($Form1)
$url = "http://WWW.163.COM"
Global $Title = "163"
$Gui_w = 482
$Gui_h = 290
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, $WinPos[0], $WinPos[1], $WS_POPUP + $WS_EX_LAYERED)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_mousedown")
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -30, -30, $Gui_w + 50, $Gui_h)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
_caidan()
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
GUICtrlSetState($2, $GUI_show)
Case $C1
WinSetState($Form1, "", @SW_MINIMIZE)
Case $C2
Exit
EndSwitch
EndFunc ;==>_DT