Jump to content

Click on menubar item


Go to solution Solved by Melba23,

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

 

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • Moderators
  • Solution

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • Moderators

MikahS,

Dang, you're fast ;)

I aim to please! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

TheAutomator,

Only too human, alas. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

×
×
  • Create New...