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
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

    • 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!


    • nacerbaaziz
      By nacerbaaziz

      Hello all
      I have a question please
      this  a question is about the context menu
      When i create a list box  Or combo box
      if i create a context menu for this list
      When i press the application key or the shortcut shift + f10
      the menu options is appear normally
      but When i create a List view
      if i create a context menu for this list
      When i press the application key or the shortcut shift + f10
      the menu options isn't appear
      But the right mouse button works normally
      I need a solution please because I deal with the screen readers users
      Unfortunately They can not use the mouse to navigate
      So I have to find a solution to activate keyboard shortcuts
      am waiting  for your help
    • Robdog1955
      By Robdog1955
      I'm trying to click a button on a web page. I have added a couple of MsgBox lines to allow me to watch what happens on the page. As you can see the first half of my script enters data into text boxes on the page. I have no problem there. I just cannot click on the region buttons. The "set focus" line causes an outline to appear around the EU button and the "click button" line causes the "Pick a Region" text to disappear. Here is the code I have so far.
      #include <IE.au3> Local $oIE = _IECreate("http://questchecker.com/") Local $iQuestID = "123456" Local $sCharacterName = "CharacterName" Local $colForms = _IEFormGetCollection($oIE) $iCount = 0 For $oForm In $colForms $oFormElements = _IEFormElementGetCollection($oForm) For $oFormElement In $oFormElements $iCount = $iCount + 1 Local $sTagName = StringLower($oFormElement.tagName) Local $sElementType = $oFormElement.type Local $sElementName = $oFormElement.name Switch $iCount Case 6 _IEFormElementSetValue($oFormElement, "MyRealm", 0) ; realm Case 7 _IEFormElementSetValue($oFormElement, $sCharacterName, 0) Case 8 _IEFormElementSetValue($oFormElement, $iQuestID, 0) EndSwitch Next Next Local $oButtons = _IEGetObjByName($oIE, "questForm") For $oButton In $oButtons If _IEFormElementGetValue($oButton) = "US" Then MsgBox(0, "", "Click Okay to set focus") _IEAction($oButton, "focus") MsgBox(0, "", "Click Okay to click button") _IEAction($oButton, "click") ExitLoop EndIf Next MsgBox(0, "", "Click Okay to quit") _IEQuit($oIE) Exit  
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.