如何创建这样的菜单?
就是没有标题栏,没有第一级菜单那一栏,一运行就出来子菜单,如下图所示没有标题栏,可以用窗口将成为该窗口的子窗口来实现:GUICreate("", $width, $heighth, $Xpos, $Ypos, $WS_POPUP, -1, WinGetHandle(AutoItWinGetTitle()))
没有第一级菜单那一栏,可以用这样来实现:GUICtrlCreateMenu("", 0)
现在的唯一问题是,怎么一运行就显示子菜单
做个窗体,运行时就隐藏窗体,send模拟右键点击 都隐藏了,还怎么用send点击?? 收藏调用时是可以点击的,试下就知道了,我做过绿化器,调用别人的注册机,整个过程都是收藏运行的,当然可以点击了。 上面收藏应隐藏,手机上不能编辑,sorry 希望可以有完全的解决方案。 本帖最后由 飘云 于 2011-3-2 14:38 编辑
为啥一定要用GUICtrlCreateMenu呢,用GUICtrlCreateContextMenu不是也可以吗
另外,那个menu你是要一直存在呢?还是点一个其中的项目就消失呢?默认下这类菜单都是点一下就消失的
写了个类似的效果,主要思路就是用TrackPopupMenuEx函数弹出菜单,不过如果点一下其它地方菜单会消失,有待改进,但至少是个思路不是吗
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$form = GUICreate("", 100, 100, -1000, -1000, -1, -1,WinGetHandle(AutoItWinGetTitle()))
GUISetState()
$context = GUICtrlCreateContextMenu()
$item_1 = GUICtrlCreateMenuItem("System32",$context)
$item_2 = GUICtrlCreateMenuItem("My Documents",$context)
GUICtrlCreateMenuItem("",$context)
$item_3 = GUICtrlCreateMenuItem("C Drive",$context)
$item_4 = GUICtrlCreateMenuItem("D Drive",$context)
GUICtrlCreateMenuItem("",$context)
$item_5 = GUICtrlCreateMenu("Utilities",$context)
$item_6 = GUICtrlCreateMenu("Command Line",$context)
GUICtrlCreateMenuItem("",$context)
$item_7 = GUICtrlCreateMenuItem("Internet",$context)
GUICtrlCreateMenuItem("",$context)
$item_8 = GUICtrlCreateMenuItem("Configure...",$context)
ShowMenu($form,$context)
While 1
Sleep(100)
$msg = GUIGetMsg()
If $msg = GUIGetMsg() Then ExitLoop
WEnd
Func ShowMenu($hWnd, $nContextID)
Local $moPos = MouseGetPos()
Local $hMenu = GUICtrlGetHandle($nContextID);获取需要显示的菜单的句柄
DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $moPos, "int", $moPos, "hwnd", $hWnd, "ptr", 0);弹出菜单
EndFunc ;==>按钮弹出菜单函数
不错,,,又学习到好东西了,支持下! 谢谢飘云兄,的确不失一个解决问题的思路与方向,虽然这种菜单一就会消失,有点不合我的要求。 “不过如果点一下其它地方菜单会消失,有待改进”
嗯,已经找到方法,让点别的地方,菜单不消失了,这样,这种方法还是非常不错的。再次感谢飘云兄。
先前没有想到建右键菜单来解决这个问题,思路受阻了 都是高手哇 不错,,,又学习到好东西了,支持下! 回复 7# 飘云
对了,当点了屏幕别的地方,ContextMenu消失后(也就是没有点右键菜单上的任何东西),怎么让程序guidelete掉guicreate()创建的图呀,或者说怎么让程序退出呀
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$form = GUICreate("", 100, 100, -1000, -1000, -1, -1,WinGetHandle(AutoItWinGetTitle()))
GUISetState()
$context = GUICtrlCreateContextMenu()
$item_1 = GUICtrlCreateMenuItem("System32",$context)
$item_2 = GUICtrlCreateMenuItem("My Documents",$context)
GUICtrlCreateMenuItem("",$context)
$item_3 = GUICtrlCreateMenuItem("C Drive",$context)
$item_4 = GUICtrlCreateMenuItem("D Drive",$context)
GUICtrlCreateMenuItem("",$context)
$item_5 = GUICtrlCreateMenu("Utilities",$context)
$item_6 = GUICtrlCreateMenu("Command Line",$context)
GUICtrlCreateMenuItem("",$context)
$item_7 = GUICtrlCreateMenuItem("Internet",$context)
GUICtrlCreateMenuItem("",$context)
$item_8 = GUICtrlCreateMenuItem("Configure...",$context)
ShowMenu($form,$context)
While 1
Sleep(100)
$msg = GUIGetMsg()
Switch $msg
Case $item_1
ExitLoop
Case $item_2
MsgBox(0,0,"0k")
EndSwitch
GUIDelete()
WEnd
Func ShowMenu($hWnd, $nContextID)
Local $moPos = MouseGetPos()
Local $hMenu = GUICtrlGetHandle($nContextID);获取需要显示的菜单的句柄
DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $moPos, "int", $moPos, "hwnd", $hWnd, "ptr", 0);弹出菜单
EndFunc ;==>按钮弹出菜单函数
回复飘云
对了,当点了屏幕别的地方,ContextMenu消失后(也就是没有点右键菜单上的任何东西),怎么 ...
happytc 发表于 2011-3-5 22:56 http://www.autoitx.com/images/common/back.gif
若这个gui不能删掉,导致别的gui通通不能调出来了,问题就大了。 本帖最后由 飘云 于 2011-3-6 15:59 编辑
回复 14# happytc
很简单啊,定义个全局变量Global $result,然后弹出函数的调用是有返回值的,$result=DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", GUICtrlGetHandle($nContextID), "int", 0x0100, "int", $moPos, "int", $moPos, "hwnd", $hWnd, "ptr", 0);弹出菜单,注意第2个参数变为0x0100,然后返回到变量$result中,最后在while循环中加入
If $result=0 Then
GUIDelete()
ExitLoop
EndIf
即可
关于TrackPopupMenuEx函数具体可查看MSDN资料库中的说明
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $result
$form = GUICreate("", 100, 100, -1000, -1000, -1, -1,WinGetHandle(AutoItWinGetTitle()))
GUISetState()
$context = GUICtrlCreateContextMenu()
$item_1 = GUICtrlCreateMenuItem("System32",$context)
$item_2 = GUICtrlCreateMenuItem("My Documents",$context)
GUICtrlCreateMenuItem("",$context)
$item_3 = GUICtrlCreateMenuItem("C Drive",$context)
$item_4 = GUICtrlCreateMenuItem("D Drive",$context)
GUICtrlCreateMenuItem("",$context)
$item_5 = GUICtrlCreateMenu("Utilities",$context)
$item_6 = GUICtrlCreateMenu("Command Line",$context)
GUICtrlCreateMenuItem("",$context)
$item_7 = GUICtrlCreateMenuItem("Internet",$context)
GUICtrlCreateMenuItem("",$context)
$item_8 = GUICtrlCreateMenuItem("Configure...",$context)
ShowMenu($form,$context)
While 1
Sleep(1000)
$msg = GUIGetMsg()
Switch $msg
Case $item_1
ExitLoop
Case $item_2
MsgBox(0,0,"0k")
EndSwitch
If $result=0 Then
GUIDelete()
ExitLoop
EndIf
WEnd
Func ShowMenu($hWnd, $nContextID)
Local $moPos = MouseGetPos()
$result=DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", GUICtrlGetHandle($nContextID), "int", 0x0100, "int", $moPos, "int", $moPos, "hwnd", $hWnd, "ptr", 0);弹出菜单
EndFunc ;==>按钮弹出菜单函数
页:
[1]
2