Jump to content
Sign in to follow this  
TheAutomator

Click on menubar item

Recommended Posts

TheAutomator

Hello :)

How does Autoit detect when you click on a menu button? (not a sub-menu item, but the actual menu button itself)

$Form = GUICreate("", 410, 270)
    $Menu_Help = GUICtrlCreateMenu("Help")
GUISetState(@SW_SHOW)

while true
    Switch GUIGetMsg()
        Case $Menu_Help
        msgbox(0,1,2)
    EndSwitch
wend

Thanks in advance :)

TheAutomator

[EDIT:] Should this be in the gui section?

Edited by TheAutomator

Share this post


Link to post
Share on other sites
LarsJ

WM_ENTERMENULOOP:

 

#include <WindowsConstants.au3>

$Form = GUICreate("", 410, 270)
$Menu_Help = GUICtrlCreateMenu("Help")
GUISetState(@SW_SHOW)

GUIRegisterMsg( $WM_ENTERMENULOOP, "WM_ENTERMENULOOP" )

while true
    Switch GUIGetMsg()
        Case $Menu_Help
          msgbox(0,1,2)
        Case -3
          Exit
    EndSwitch
wend

Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam )
  msgbox(0,1,"WM_ENTERMENULOOP")
EndFunc

Share this post


Link to post
Share on other sites
TheAutomator

WM_ENTERMENULOOP:

 

#include <WindowsConstants.au3>

$Form = GUICreate("", 410, 270)
$Menu_Help = GUICtrlCreateMenu("Help")
GUISetState(@SW_SHOW)

GUIRegisterMsg( $WM_ENTERMENULOOP, "WM_ENTERMENULOOP" )

while true
    Switch GUIGetMsg()
        Case $Menu_Help
          msgbox(0,1,2)
        Case -3
          Exit
    EndSwitch
wend

Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam )
  msgbox(0,1,"WM_ENTERMENULOOP")
EndFunc

 

how do i know which item is clicked on if i have 2 menu heather's?

also just clicking on the menu bar gives the message... 

TheAutomator

Edited by TheAutomator

Share this post


Link to post
Share on other sites
MikahS

how do i know which item is clicked on if i have 2 menu heather's?

also just clicking on the menu bar gives the message... 

TheAutomator

Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam )
    Local $gFocus = ControlGetFocus('[ACTIVE]') ; get the focus of the menu you are selecting
    MsgBox(0, "", $gFocus) ; tell us
EndFunc
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
TheAutomator
Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam )
    Local $gFocus = ControlGetFocus('[ACTIVE]') ; get the focus of the menu you are selecting
    MsgBox(0, "", $gFocus) ; tell us
EndFunc

 

did you test the script?

because the msgbox is just empty and also it still gives a pop-up when you click on the menu bar..

TheAutomator

Share this post


Link to post
Share on other sites
MikahS

did you test the script?

because the msgbox is just empty and also it still gives a pop-up when you click on the menu bar..

TheAutomator

Nope, just thought I would throw something out there. Yes, what it is doing is their is not control focused when you click on a menu item because it will instantly take away focus, should have thought of that..

But, maybe..

Local $hts = _HexToString($lparam)
MsgBox(0, "", $hts)
;untested
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
TheAutomator

 

Nope, just thought I would throw something out there. Yes, what it is doing is their is not control focused when you click on a menu item because it will instantly take away focus, should have thought of that..

But, maybe..

Local $hts = _HexToString($lparam)
Local $stascii = StringToASCIIArray($hts)
Local $t = _ArrayToString($stascii)
MsgBox(0, "", $t)
;untested

 

nope :(

Share this post


Link to post
Share on other sites
MikahS

I edited my post, give that one a try as well. You don't need to make it ASCII.

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
TheAutomator

I edited my post, give that one a try as well. You don't need to make it ASCII.

 

Still not working...

Thanks for the effort but I think its not the right way to do this, I swear I saw an answer on this forum for that exact problem a LONG time ago but I can't find it anymore  :huh:

think it was answered by Melba23 ...

Share this post


Link to post
Share on other sites
MikahS

Still not working...

Thanks for the effort but I think its not the right way to do this, I swear I saw an answer on this forum for that exact problem a LONG time ago but I can't find it anymore  :huh:

think it was answered by Melba23 ...

Seems to me like it is time for a wild goose chase ;)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
MikahS

Haha, I guess so  :D

Thanks for the help already btw ;)

 

My pleasure ;)

I will help on the goose chase but I must get going, Later tonight I will search more :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Melba23

TheAutomator,

 

think it was answered by Melba23

Someone called? :D

Perhaps you mean >this post? But beware you need at least 1 valid menu entry first. ;)

I posted >this other solution a long time ago, but I would recommend the above. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
MikahS

TheAutomator,

 

Someone called? :D

Perhaps you mean >this post? But beware you need at least 1 valid menu entry first. ;)

I posted >this other solution a long time ago, but I would recommend the above. :)

M23

 

Dang, you're fast ;)

Could it be a blank menu item such as a line made with ""?


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Melba23

MikahS,

Dang, you're fast ;)

I aim to please! :D

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
TheAutomator

MikahS,

I aim to please! :D

M23

 

Sometimes I doubt if you are human Melba23,

You never sleep and your everywhere on this forum  :D

Thanks for solving my problem  ;)

Edited by TheAutomator

Share this post


Link to post
Share on other sites
Melba23

TheAutomator,

Only too human, alas. ;)

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
LarsJ

WM_ENTERMENULOOP

You can do something like this. But menus without menu items are not proper menus.

 

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

$Form = GUICreate("", 410, 270)
$Menu_File1 = GUICtrlCreateMenu("File1")
$Menu_File2 = GUICtrlCreateMenu("File2",-1)
$Menu_File3 = GUICtrlCreateMenu("File3",-1)

GUISetState(@SW_SHOW)

GUIRegisterMsg( $WM_ENTERMENULOOP, "WM_ENTERMENULOOP" )

while true
  Switch GUIGetMsg()
    Case -3
      ExitLoop
  EndSwitch
wend

Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam )
  Local $x = GUIGetCursorInfo()[0]
  Local $i = Int( $x / ( 112 / 3 ) )
  Switch $i
    Case 0
      MsgBox( 0, "", "File1" )
    Case 1
      MsgBox( 0, "", "File2" )
    Case 2
      MsgBox( 0, "", "File3" )
    Case Else
      MsgBox( 0, "", "No menu" )
  EndSwitch
  Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites
TheAutomator

WM_ENTERMENULOOP

You can do something like this. But menus without menu items are not proper menus.

 

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

$Form = GUICreate("", 410, 270)
$Menu_File1 = GUICtrlCreateMenu("File1")
$Menu_File2 = GUICtrlCreateMenu("File2",-1)
$Menu_File3 = GUICtrlCreateMenu("File3",-1)

GUISetState(@SW_SHOW)

GUIRegisterMsg( $WM_ENTERMENULOOP, "WM_ENTERMENULOOP" )

while true
  Switch GUIGetMsg()
    Case -3
      ExitLoop
  EndSwitch
wend

Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam )
  Local $x = GUIGetCursorInfo()[0]
  Local $i = Int( $x / ( 112 / 3 ) )
  Switch $i
    Case 0
      MsgBox( 0, "", "File1" )
    Case 1
      MsgBox( 0, "", "File2" )
    Case 2
      MsgBox( 0, "", "File3" )
    Case Else
      MsgBox( 0, "", "No menu" )
  EndSwitch
  Return $GUI_RUNDEFMSG
EndFunc

 

Yes that's also an option, thanks ;)

TheAutomator

Edited by TheAutomator

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  

  • Similar Content

    • Pagi
      By Pagi
       
      <a href="index.php=4143b27b41db0a40c499202865c3e24d" class="menuitem " target="\_self"> "Menu Item 1" </a>
      Can you tell me if it´s possible to click this menu button? If yes, how? Cause I have no idea, I think i should use _IETagNameGetCollection
    • Pike
      By Pike
      Hello Everyone,
      New Guy here. This is a two-part question, hopefully easy enough though. I know it's ugly coding, this is because I have only a couple hours worth of coding experience and could really use some help.
      1) When I single click the button I want one action (like playing a sound clip) and when I double click the button I want a different action (such as opening dialogue box to ask for soundclip directory address). At the bottom of the script I made a comment which one I would like single click versus double click.
      2) I can not get the FileOpenDialogue to save the file address to the config.ini file at the 'One' position on the .ini.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <AutoItConstants.au3> #include <Sound.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Global $OneID _Main() Func _Main() GUICreate("Form1", 156, 86, 281, 276) $OneID = GUICtrlCreateButton("Button", 15, 17, 122, 37) GUICtrlSetOnEvent($OneID, "OnOne") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") GUISetState() While 1 While 1 Sleep(1000) WEnd WEnd EndFunc ;---------------Functions------------- While 1 Sleep(100) WEnd Func OnOne() ; ******************Single Click for this action**************** $OneID = IniRead("config.ini", "Config", "One", $OneID) If $OneID = True Then SoundPlay($OneID, @HotKeyPressed) Else ; *******Double Click for this action*****And Help Saving File Address to config.ini 'One'*********** $OneID = FileOpenDialog("Select file", @WorkingDir, "All (*.*)") IniWrite("config.ini", "Config", "One", $OneID) $OneID = InputBox("Enter Information", "Short Name for File?", "") IniWrite("config.ini", "Config", "NameOne", $OneID) EndIf EndFunc Any help would be greatly appreciated, and if you need anymore clarity as to what exactly I'm trying to do, please do not hesitate to ask. Thanks so much!
      Pike
    • nacerbaaziz
      By nacerbaaziz
      Hello
      I have an inquiry please
      when i use the control get focus
      it don't detect the menu item
      there are any Method to do that?
      i'll use that to make a custom screen reader in my program
      please help me to do that
      I am waiting for your answers
      greetings to you
      Thank you in advance
       
    • dadalt
      By dadalt
      Hi!
      I have a button where I need to close it!
      I was doing through  clicking same position in screen but there are some id's that have different sizes.
      What are the possible ways to click this closable button?
      Is there a way to close it through id? Is there a way to get it's position through it's ID?  
      Thanks in advance!


×