🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #6428

"use" menu item in another app?

#6428
From: Segal
Date: Tue, 17 May 2005 08:58
30 lines
1850 bytes
Hello. I can get a hold of a menu in another app just fine, like this:

   HWND hwnd = NULL;
   char buff[101];

   hwnd = FindWindowEx(NULL, hwnd, NULL, "Target App");

   HMENU hmenu = GetMenu(hwnd);

   MENUITEMINFO menuinfo;
   memset(&menuinfo, 0, sizeof(menuinfo));
   menuinfo.cbSize = sizeof(MENUITEMINFO);
   menuinfo.fMask = MIIM_STRING;
   menuinfo.dwTypeData = NULL;

   GetMenuItemInfo(hmenu, 2, true, &menuinfo);
   menuinfo.dwTypeData = buff;
   if (GetMenuItemInfo(hmenu, 2, true, &menuinfo))
      ShowMessage(String(buff));

This gets me the caption of the item, but how to I simulate a click?

I've been looking through the WinAPI docs all day to no avail.

Thanks for any help.

P.S. My code example is my rough draft. I have never done any thing like 
this - tapping into another app's menu - if there is any way to better 
the code I put forth above please feel free to make corrections I need 
all the good advice and help I can get :-) 
Technical Details
Message-ID: <4289b235@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,de4107a245e3b3a8,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Segal" <none@none.spam.sucks.balls>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: "use" menu item in another app?
Date: Tue, 17 May 2005 01:58:19 -0700
Lines: 32
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 66.234.219.101
Message-ID: <4289b235@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1116320309 66.234.219.101 (17 May 2005 01:58:29 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail