Sign in to follow this  
Followers 0
SagePourpre

How to handle events to a custom menu ?

3 posts in this topic

Hi everybody. I'm turning around this little unsolved problem I got last

week and still can't figure it out. So I thought maybe someone in here would

have an idea of how exactly to cure my soul of this unanswered mystery of mine.

The script below create a new menu in your scite window called "autoit".

It have one item.

I would need now to assign an event to the item when user click it ?

Any idea how to listen for these events ?

#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <GuiMenu.au3>
#include <GuiConstantsEx.au3>
Opt('GuiOnEventMode',1)
; '[CLASS:SciTEWindow]'






$hWnd = WinGetHandle('[CLASS:SciTEWindow]')
$hMain = _GUICtrlMenu_GetMenu($hWnd)

Local Enum $iditem1 = 100000
$hMenu = _GUICtrlMenu_CreateMenu()
_GUICtrlMenu_InsertMenuItem($hMenu,0,'Item 1',$iditem1)


_GUICtrlMenu_InsertMenuItem($hMain, 9, "&AutoIt", 0, $hMenu)

_GUICtrlMenu_DrawMenuBar($hWnd)

$dll = DllOpen('user32.dll')
While Not _IsPressed(23,$dll) ; Press end to terminate script and remove menu
    Sleep(100)
WEnd



DllClose($dll)
_GUICtrlMenu_RemoveMenu($hMain,9)

Share this post


Link to post
Share on other sites

http://www.autoitscript.com/forum/index.php?showtopic=56536

Read through this topic, you'll get the handle of it. Generally, the system will notify your hook when a menu is about to be opened or close. You're free to do what ever is possible to be done. If you want better control on the process, you need to hook into the window's message loop, but AutoIt cannot be used to compile a dll library. You'll have to create your own and handle the stuff you want there. Then you can use AutoIt to hook the window using this dll.

Share this post


Link to post
Share on other sites

Oh.

The solution you provide on that topic is exactly what I needed.

Thank you ( a lot ).

Problem is solved.

:mellow:

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