Jump to content
Sign in to follow this  
Kyan

Contextmenu with mouse left button

Recommended Posts

Kyan

Hi,

Its possible to create a context menu trigged by the left button of the mouse?

$context = GUICtrlCreateContextMenu($icon) ;trigged by the left button mouse's
$contextItem1 = GUICtrlCreateMenu("1st", $context)

I set the context menu to a icon, but I want it open with the left in stead of the right one.

hope there's a way :oops:


Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites
somdcomputerguy

Try this. It's not perfect, sometimes a second single left click is required.

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep (10)
    If _IsPressed("01", $dll) Then
        MouseClick("Right")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
Kyan

Try this. It's not perfect, sometimes a second single left click is required.

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep (10)
    If _IsPressed("01", $dll) Then
        MouseClick("Right")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

hum...there's some function about mousehover?, like, when mouse is hover $icon, it does something (change the cursor settings)?

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites
BrewManNH

What is it that you are trying to do? Your last post is very vague, it would help if you tried to explain what you're attempting in a clearer way. Also, what have you tried that isn't working correctly?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Aipion

DiOgO

Have a look at my example.

#include <GuiMenu.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $msg
Global Enum $i_MenuItem1 = 3335, $i_MenuItem2, $i_MenuItem3, $i_MenuItem4, $i_MenuItem5

    $iGUI = GUICreate("My GUI") ; will create a dialog box that when displayed is centered
$My_icon = GUICtrlCreateIcon(@AutoItExe,-1,10,10,64,64)
    GUISetState(@SW_SHOW)

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
Switch $msg
Case $My_icon


Global $hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, 'Add Files...', $i_MenuItem1)
_GUICtrlMenu_AddMenuItem($hMenu, 'Add Folders...', $i_MenuItem2)
_GUICtrlMenu_AddMenuItem($hMenu, 'Add Temporary Files...', $i_MenuItem3)
_GUICtrlMenu_AddMenuItem ($hMenu, "", 0)
_GUICtrlMenu_AddMenuItem($hMenu, 'Add External Files...', $i_MenuItem4)
_GUICtrlMenu_AddMenuItem($hMenu, 'New Shortcut...', $i_MenuItem5)

$hMenu_MSGS = _GUICtrlMenu_TrackPopupMenu ($hMenu, $iGUI, -1,-1,1,1,2)
_GUICtrlMenu_DestroyMenu ($hMenu)
Switch $hMenu_MSGS
Case $i_MenuItem1
MsgBox(0,"","You Clicked Menu Item 1")
Case $i_MenuItem2
MsgBox(0,"","You Clicked Menu Item 2")
Case $i_MenuItem3
MsgBox(0,"","You Clicked Menu Item 3")
Case $i_MenuItem4
MsgBox(0,"","You Clicked Menu Item 4")
Case $i_MenuItem5
MsgBox(0,"","You Clicked Menu Item 5")
Case Else
;ConsoleWrite("Error")
EndSwitch

Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
    WEnd
    GUIDelete()

Share this post


Link to post
Share on other sites
Kyan

DiOgO

Have a look at my example.

#include <GuiMenu.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $msg
Global Enum $i_MenuItem1 = 3335, $i_MenuItem2, $i_MenuItem3, $i_MenuItem4, $i_MenuItem5

    $iGUI = GUICreate("My GUI") ; will create a dialog box that when displayed is centered
$My_icon = GUICtrlCreateIcon(@AutoItExe,-1,10,10,64,64)
    GUISetState(@SW_SHOW)

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
Switch $msg
Case $My_icon


Global $hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, 'Add Files...', $i_MenuItem1)
_GUICtrlMenu_AddMenuItem($hMenu, 'Add Folders...', $i_MenuItem2)
_GUICtrlMenu_AddMenuItem($hMenu, 'Add Temporary Files...', $i_MenuItem3)
_GUICtrlMenu_AddMenuItem ($hMenu, "", 0)
_GUICtrlMenu_AddMenuItem($hMenu, 'Add External Files...', $i_MenuItem4)
_GUICtrlMenu_AddMenuItem($hMenu, 'New Shortcut...', $i_MenuItem5)

$hMenu_MSGS = _GUICtrlMenu_TrackPopupMenu ($hMenu, $iGUI, -1,-1,1,1,2)
_GUICtrlMenu_DestroyMenu ($hMenu)
Switch $hMenu_MSGS
Case $i_MenuItem1
MsgBox(0,"","You Clicked Menu Item 1")
Case $i_MenuItem2
MsgBox(0,"","You Clicked Menu Item 2")
Case $i_MenuItem3
MsgBox(0,"","You Clicked Menu Item 3")
Case $i_MenuItem4
MsgBox(0,"","You Clicked Menu Item 4")
Case $i_MenuItem5
MsgBox(0,"","You Clicked Menu Item 5")
Case Else
;ConsoleWrite("Error")
EndSwitch

Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
    WEnd
    GUIDelete()

works great :oops:

can I also put check marks in some items?


Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites
Aipion

works great :oops:

can I also put check marks in some items?

Yes you can Via _GUICtrlMenu_SetItemChecked($hMenu, $iItem [, $fState = True [, $fByPos = True]])

Share this post


Link to post
Share on other sites
Kyan

Yes you can Via _GUICtrlMenu_SetItemChecked($hMenu, $iItem [, $fState = True [, $fByPos = True]])

yeah, ahah, thanks again :oops:

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×