Discussion:
How to get menu identifier?
(too old to reply)
Sree
2009-09-14 14:38:02 UTC
Permalink
Hi i am new to hooking..i am using wm_getmessage hook to know which menu item
is clicked.
i am using the follwing code to get identifier of the menu

WORD identifier=LOWORD(pMsg->wParam);

it is giving integer value..up to now is fine...
my problem is how to know which menu item is clicked by using this
identifier? is it possible by this? or is there any other way to know which
menu item clicked?

please explain with code if possible..

Thanks in advance...
--
--------------------------------------------
At last i learned something for today...:)
Sree
2009-09-15 12:45:01 UTC
Permalink
Hi guys, no one knows answer for this question? i stuck with this problem
form one week. please help me..

is it possible to know which menu item is clicked using wh_getmessage hook?
if not possible please tell me the way how can we achive this?
i trying with wh_getmessage hook and i am only able to get identifier of the
menu item. how to menu information using this identifier? is it possible?
on internet i not found anywhere about this.....

Thank you in advance...
--
--------------------------------------------
At last i learned something for today...:)
Post by Sree
Hi i am new to hooking..i am using wm_getmessage hook to know which menu item
is clicked.
i am using the follwing code to get identifier of the menu
WORD identifier=LOWORD(pMsg->wParam);
it is giving integer value..up to now is fine...
my problem is how to know which menu item is clicked by using this
identifier? is it possible by this? or is there any other way to know which
menu item clicked?
please explain with code if possible..
Thanks in advance...
--
--------------------------------------------
At last i learned something for today...:)
Ben Voigt [C++ MVP]
2009-09-15 16:03:11 UTC
Permalink
What message are you processing?

Some messages contain a menu child item id, from which you can easily learn
the menu caption (the string that appears in the menu).
WM_COMMAND contains only an application-specific id. You'd have to use
Spy++ on each such application to find out what number corresponds to each
menu item.
Post by Sree
Hi guys, no one knows answer for this question? i stuck with this problem
form one week. please help me..
is it possible to know which menu item is clicked using wh_getmessage hook?
if not possible please tell me the way how can we achive this?
i trying with wh_getmessage hook and i am only able to get identifier of the
menu item. how to menu information using this identifier? is it possible?
on internet i not found anywhere about this.....
Thank you in advance...
--
--------------------------------------------
At last i learned something for today...:)
Post by Sree
Hi i am new to hooking..i am using wm_getmessage hook to know which menu item
is clicked.
i am using the follwing code to get identifier of the menu
WORD identifier=LOWORD(pMsg->wParam);
it is giving integer value..up to now is fine...
my problem is how to know which menu item is clicked by using this
identifier? is it possible by this? or is there any other way to know which
menu item clicked?
please explain with code if possible..
Thanks in advance...
--
--------------------------------------------
At last i learned something for today...:)
Sree
2009-09-16 05:36:01 UTC
Permalink
Thanks for your reply Ben,
actally my intention is to get menu item names,which
user clicks.
i am using WH_GETMESSAGE hook and processing WM_COMMAND msg. by this i am
only able to get identifier of the menu(which is integer value not like
IDM_xxx).

I used spy++ to know which msgs are generating when i clicked a menu or
standard tool bar icon( ex:paste etc). it is generating wm_command msg with
lparam value is zero..by getting loword of wparam i am able to get menu
identifier..from now how to get menu information?

i mean i need menu item text like "paste ctrl+v", "undo ctrl+z" etc..

please help me..i stuck with this..
(i am able to get menu information when i used WH_CALLWNDPROC hook and using
WM_MENUSELECT but this msg generating when menu item is visited. i dont want
this..i want to know menu information when user clicks a menu(wm_command) in
any open application like notepad ,wordpad etc..)

Thanks in advance...
--
--------------------------------------------
At last i learned something for today...:)
Post by Ben Voigt [C++ MVP]
What message are you processing?
Some messages contain a menu child item id, from which you can easily learn
the menu caption (the string that appears in the menu).
WM_COMMAND contains only an application-specific id. You'd have to use
Spy++ on each such application to find out what number corresponds to each
menu item.
Post by Sree
Hi guys, no one knows answer for this question? i stuck with this problem
form one week. please help me..
is it possible to know which menu item is clicked using wh_getmessage hook?
if not possible please tell me the way how can we achive this?
i trying with wh_getmessage hook and i am only able to get identifier of the
menu item. how to menu information using this identifier? is it possible?
on internet i not found anywhere about this.....
Thank you in advance...
--
--------------------------------------------
At last i learned something for today...:)
Post by Sree
Hi i am new to hooking..i am using wm_getmessage hook to know which menu item
is clicked.
i am using the follwing code to get identifier of the menu
WORD identifier=LOWORD(pMsg->wParam);
it is giving integer value..up to now is fine...
my problem is how to know which menu item is clicked by using this
identifier? is it possible by this? or is there any other way to know which
menu item clicked?
please explain with code if possible..
Thanks in advance...
--
--------------------------------------------
At last i learned something for today...:)
Ben Voigt [C++ MVP]
2009-09-16 15:59:13 UTC
Permalink
Post by Sree
Thanks for your reply Ben,
actally my intention is to get menu item
names,which user clicks.
i am using WH_GETMESSAGE hook and processing WM_COMMAND msg. by this
i am only able to get identifier of the menu(which is integer value
not like IDM_xxx).
I used spy++ to know which msgs are generating when i clicked a menu
or standard tool bar icon( ex:paste etc). it is generating wm_command
msg with lparam value is zero..by getting loword of wparam i am able
to get menu identifier..from now how to get menu information?
That's not the menu identifier (which is what you got with WM_MENUSELECT),
it's the command (which is why it comes in WM_COMMAND). How would you tell
Windows what value to send from menus you created? You'll have to check
that structure for every menu in the program and see which one matches,
there is no one-to-one mapping for command like there is for menu ids.
(More than one menu item can send the same command, toolbars and
accelerators/hotkeys can also generate WM_COMMAND). But in most cases
you'll find a menu item that sends the command and you can use its caption.
Post by Sree
i mean i need menu item text like "paste ctrl+v", "undo ctrl+z" etc..
please help me..i stuck with this..
(i am able to get menu information when i used WH_CALLWNDPROC hook
and using WM_MENUSELECT but this msg generating when menu item is
visited. i dont want this..i want to know menu information when user
clicks a menu(wm_command) in any open application like notepad
,wordpad etc..)
Thanks in advance...
Post by Ben Voigt [C++ MVP]
What message are you processing?
Some messages contain a menu child item id, from which you can
easily learn the menu caption (the string that appears in the menu).
WM_COMMAND contains only an application-specific id. You'd have to
use Spy++ on each such application to find out what number
corresponds to each menu item.
Post by Sree
Hi guys, no one knows answer for this question? i stuck with this
problem form one week. please help me..
is it possible to know which menu item is clicked using
wh_getmessage hook?
if not possible please tell me the way how can we achive this?
i trying with wh_getmessage hook and i am only able to get
identifier of the
menu item. how to menu information using this identifier? is it
possible? on internet i not found anywhere about this.....
Thank you in advance...
--
--------------------------------------------
At last i learned something for today...:)
Post by Sree
Hi i am new to hooking..i am using wm_getmessage hook to know which menu item
is clicked.
i am using the follwing code to get identifier of the menu
WORD identifier=LOWORD(pMsg->wParam);
it is giving integer value..up to now is fine...
my problem is how to know which menu item is clicked by using this
identifier? is it possible by this? or is there any other way to know which
menu item clicked?
please explain with code if possible..
Thanks in advance...
--
--------------------------------------------
At last i learned something for today...:)
Sree
2009-09-17 07:01:03 UTC
Permalink
Thanks for your reply ben,
what i understood from your post is it is difficult to get
menu text bcox so many actions cause WM_COMMAND. but as i learn from msdn
LOWORD of wParam will give the menu identifier.and i found from spy++ that
each menu contains unique identier..by comparing this identifier i thought to
know which menu item is clicked..
(using WH_GETMESSAGE).
i am trying to hook wordpad..any how i got some idea...when i visited the
menu item(wm_menuselect trap with WH_CALLWNDPROC) and got the menu
information.

Here i got one big problem...

when i tried the same code of VS2005 and sql server 2005 it is not
generating any WH_MENUSELECT..then my code become useless...how can we get
the menu item text?



My intesion is:
i want to write menu item text when the user clicks menu
item in any open application(like VS2005 or SQL2005 or MS-Word etc). Please
tell me how can i achive this..which msg i have to trap? which hook i have to
use?(FYI wm_menuselect is not generating in vs2005). i have little bit
knowledge abt hooking..just tell me the way how i do this...

also i want to the information about standard tool bar icons when the user
clicks them..how can i achive this also...please help me...

Thanks in advance..
--
--------------------------------------------
At last i learned something for today...:)
Post by Ben Voigt [C++ MVP]
Post by Sree
Thanks for your reply Ben,
actally my intention is to get menu item
names,which user clicks.
i am using WH_GETMESSAGE hook and processing WM_COMMAND msg. by this
i am only able to get identifier of the menu(which is integer value
not like IDM_xxx).
I used spy++ to know which msgs are generating when i clicked a menu
or standard tool bar icon( ex:paste etc). it is generating wm_command
msg with lparam value is zero..by getting loword of wparam i am able
to get menu identifier..from now how to get menu information?
That's not the menu identifier (which is what you got with WM_MENUSELECT),
it's the command (which is why it comes in WM_COMMAND). How would you tell
Windows what value to send from menus you created? You'll have to check
that structure for every menu in the program and see which one matches,
there is no one-to-one mapping for command like there is for menu ids.
(More than one menu item can send the same command, toolbars and
accelerators/hotkeys can also generate WM_COMMAND). But in most cases
you'll find a menu item that sends the command and you can use its caption.
Post by Sree
i mean i need menu item text like "paste ctrl+v", "undo ctrl+z" etc..
please help me..i stuck with this..
(i am able to get menu information when i used WH_CALLWNDPROC hook
and using WM_MENUSELECT but this msg generating when menu item is
visited. i dont want this..i want to know menu information when user
clicks a menu(wm_command) in any open application like notepad
,wordpad etc..)
Thanks in advance...
Post by Ben Voigt [C++ MVP]
What message are you processing?
Some messages contain a menu child item id, from which you can
easily learn the menu caption (the string that appears in the menu).
WM_COMMAND contains only an application-specific id. You'd have to
use Spy++ on each such application to find out what number
corresponds to each menu item.
Post by Sree
Hi guys, no one knows answer for this question? i stuck with this
problem form one week. please help me..
is it possible to know which menu item is clicked using
wh_getmessage hook?
if not possible please tell me the way how can we achive this?
i trying with wh_getmessage hook and i am only able to get
identifier of the
menu item. how to menu information using this identifier? is it
possible? on internet i not found anywhere about this.....
Thank you in advance...
--
--------------------------------------------
At last i learned something for today...:)
Post by Sree
Hi i am new to hooking..i am using wm_getmessage hook to know which menu item
is clicked.
i am using the follwing code to get identifier of the menu
WORD identifier=LOWORD(pMsg->wParam);
it is giving integer value..up to now is fine...
my problem is how to know which menu item is clicked by using this
identifier? is it possible by this? or is there any other way to know which
menu item clicked?
please explain with code if possible..
Thanks in advance...
--
--------------------------------------------
At last i learned something for today...:)
Ben Voigt [C++ MVP]
2009-09-17 16:32:12 UTC
Permalink
This post might be inappropriate. Click to display it.
avaya sahu
2010-08-27 13:52:30 UTC
Permalink
I am trying to fire IE print command menu id from the popup. What are the options i should choose for monitoring the menu click event in spy++.
Please guide me.
Post by Sree
Hi i am new to hooking..i am using wm_getmessage hook to know which menu item
is clicked.
i am using the follwing code to get identifier of the menu
WORD identifier=LOWORD(pMsg->wParam);
it is giving integer value..up to now is fine...
my problem is how to know which menu item is clicked by using this
identifier? is it possible by this? or is there any other way to know which
menu item clicked?
please explain with code if possible..
Thanks in advance...
--
--------------------------------------------
At last i learned something for today...:)
Post by Sree
Hi guys, no one knows answer for this question? i stuck with this problem
form one week. please help me..
is it possible to know which menu item is clicked using wh_getmessage hook?
if not possible please tell me the way how can we achive this?
i trying with wh_getmessage hook and i am only able to get identifier of the
menu item. how to menu information using this identifier? is it possible?
on internet i not found anywhere about this.....
Thank you in advance...
--
--------------------------------------------
At last i learned something for today...:)
Post by Ben Voigt [C++ MVP]
What message are you processing?
Some messages contain a menu child item id, from which you can easily learn
the menu caption (the string that appears in the menu).
WM_COMMAND contains only an application-specific id. You'd have to use
Spy++ on each such application to find out what number corresponds to each
menu item.
it is a Win32 classic question...
Post by Sree
Thanks for your reply Ben,
actally my intention is to get menu item names,which
user clicks.
i am using WH_GETMESSAGE hook and processing WM_COMMAND msg. by this i am
only able to get identifier of the menu(which is integer value not like
IDM_xxx).
I used spy++ to know which msgs are generating when i clicked a menu or
standard tool bar icon( ex:paste etc). it is generating wm_command msg with
lparam value is zero..by getting loword of wparam i am able to get menu
identifier..from now how to get menu information?
i mean i need menu item text like "paste ctrl+v", "undo ctrl+z" etc..
please help me..i stuck with this..
(i am able to get menu information when i used WH_CALLWNDPROC hook and using
WM_MENUSELECT but this msg generating when menu item is visited. i dont want
this..i want to know menu information when user clicks a menu(wm_command) in
any open application like notepad ,wordpad etc..)
Thanks in advance...
--
--------------------------------------------
At last i learned something for today...:)
Post by Sree
Hi domi,
i also searched that group but i not found any answer. for
searching in that group also it is giving only three results.
if you find any link please provide me..i am very thankful if i get any
link...
--
--------------------------------------------
At last i learned something for today...:)
Post by Ben Voigt [C++ MVP]
That's not the menu identifier (which is what you got with WM_MENUSELECT),
it is the command (which is why it comes in WM_COMMAND). How would you tell
Windows what value to send from menus you created? You'll have to check
that structure for every menu in the program and see which one matches,
there is no one-to-one mapping for command like there is for menu ids.
(More than one menu item can send the same command, toolbars and
accelerators/hotkeys can also generate WM_COMMAND). But in most cases
you will find a menu item that sends the command and you can use its caption.
Post by Sree
Thanks for your reply ben,
what i understood from your post is it is difficult to get
menu text bcox so many actions cause WM_COMMAND. but as i learn from msdn
LOWORD of wParam will give the menu identifier.and i found from spy++ that
each menu contains unique identier..by comparing this identifier i thought to
know which menu item is clicked..
(using WH_GETMESSAGE).
i am trying to hook wordpad..any how i got some idea...when i visited the
menu item(wm_menuselect trap with WH_CALLWNDPROC) and got the menu
information.
Here i got one big problem...
when i tried the same code of VS2005 and sql server 2005 it is not
generating any WH_MENUSELECT..then my code become useless...how can we get
the menu item text?
i want to write menu item text when the user clicks menu
item in any open application(like VS2005 or SQL2005 or MS-Word etc). Please
tell me how can i achive this..which msg i have to trap? which hook i have to
use?(FYI wm_menuselect is not generating in vs2005). i have little bit
knowledge abt hooking..just tell me the way how i do this...
also i want to the information about standard tool bar icons when the user
clicks them..how can i achive this also...please help me...
Thanks in advance..
--
--------------------------------------------
At last i learned something for today...:)
Visual Studio (and probably some other products as well) do not use true
Win32 menu APIs. They have pull-off menus which are a custom control. I'd
think they still produce WM_COMMAND with a ID meaningful to the program, but
as for how to retrieve the string... it is specific to the particular library
used for the custom menus.
You're most likely going to have to use Spy++ and make a dictionary of
command numbers vs menu text.
Word does not have menus at all (starting in Office 2007).
Toolbars also are not a standard control (although I think there is a common
control, many programs use a custom toolbar implementation).
Submitted via EggHeadCafe - Software Developer Portal of Choice
Book Review: Excel 2010 - The Missing Manual [OReilly]
http://www.eggheadcafe.com/tutorials/aspnet/7d211741-221d-46c7-b9c3-d34bf84568be/book-review-excel-2010--the-missing-manual-oreilly.aspx
domi
2009-09-15 19:43:30 UTC
Permalink
Post by Sree
Hi guys, no one knows answer for this question? i stuck with this problem
form one week. please help me..
It's a Win32 classic question...
(see on Win32 grp (news://comp.os.ms-windows.programmer.win32)
Sree
2009-09-16 05:39:03 UTC
Permalink
Hi domi,
i also searched that group but i not found any answer. for
searching in that group also it is giving only three results.

if you find any link please provide me..i am very thankful if i get any
link...
--
--------------------------------------------
At last i learned something for today...:)
Post by domi
Post by Sree
Hi guys, no one knows answer for this question? i stuck with this problem
form one week. please help me..
It's a Win32 classic question...
(see on Win32 grp (news://comp.os.ms-windows.programmer.win32)
Loading...