473,324 Members | 2,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

C# WinAPI Clicking on menu items

I'm trying to click on a menu item inside a program called Media Subtitler and whatever I'm trying to do it's not working.

First, I tried to use the function GetMenu but it returned IntPtr.Zero. Then, I tried using the ALT key + using the first letter of my menu (F stands for file) but it did nothing. Then, I tried using a simple MOUSEDOWN and MOUSEUP messages but again, it did nothing (I also tried creating a loop that clicks on everything in that range but there was no click in that area).

What I clearly know is that I'm working on the correct window.

What am I doing wrong?

If someone wants to test it out you can download Media Subtitler for free and it doesn't weight that much.

Also, Here's the code I've been testing:
Expand|Select|Wrap|Line Numbers
  1. Process p = Process.Start(@"C:\Program Files\DivXLand\Media Subtitler\MediaSub.exe");
  2.         p.WaitForInputIdle(1500);
  3.         Thread.Sleep(3000);
  4.  
  5.         SetForegroundWindow(p.MainWindowHandle);
  6.         ShowWindow(p.MainWindowHandle, SW_MAXIMIZE);
  7.  
  8.         IntPtr handle = p.MainWindowHandle;
  9.  
  10.         SendMessage(handle, WM_NCHITTEST, 0, MakeLParam(18, 29));
  11.  
  12.         //for (int i = 0; i < 200; i++)
  13.         //{
  14.         //    for (int x = 0; x < 200; x++)
  15.         //    {
  16.         //        SendMessage(p.MainWindowHandle, WM_LBUTTONDOWN, 0, MakeLParam(i, x));
  17.         //        SendMessage(p.MainWindowHandle, WM_LBUTTONUP, 0, MakeLParam(i, x));
  18.         //    }
  19.         //}
  20.         //IntPtr menuItems = GetMenu(p.MainWindowHandle);
  21.         return;
  22.         //SendMessage(p.MainWindowHandle, WM_COMMAND, 6, 0);
  23.         SendMessage(p.MainWindowHandle, WM_KEYDOWN, VK_MENU, 0);
  24.         SendMessage(p.MainWindowHandle, WM_KEYUP, VK_MENU, 0);
  25.         SendMessage(p.MainWindowHandle, WM_KEYDOWN, VK_F, 0);
  26.         SendMessage(p.MainWindowHandle, WM_KEYUP, VK_F, 0);

Thanks for any help!
Feb 22 '12 #1
1 4310
For anyone who's interested, here's the answer:
http://stackoverflow.com/questions/9...-on-menu-items
Feb 23 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Heather | last post by:
I notice the Tag property for menu items. Is there a way to assign say a 1 to the Tag property of certain menu items and then make those menu items not visible programatically? Thanks! Heather
4
by: Ian Hinson | last post by:
The pop-up (drop-down?) menu items that appear in both built-in and custom menubars since Office 2000 now sometimes appear "sunken" and by default are not visible, unless the chevron is clicked at...
1
by: Sakharam Phapale | last post by:
Hi All, How to show dropdown list of menu items just like click on Parent menu. For example, Edit (Parent menu) Cut (child menu) Copy (child menu) Paste (child menu)
0
by: Elaine | last post by:
I have a truly curious problem with HtmlHelp and Sibling Mode in Visual C++ ..Net 2003 in an MFC app. Sibling mode allows the help viewer to display on top of the app, but if the app is clicked,...
10
by: tmaster | last post by:
When I try to dynamically add a second sub menu item to this ContextMenu item, I get an error 'Specified argument was out of the range of valid values'. Private Sub mnuTopics_Show_Select(ByVal...
2
by: Sakharam Phapale | last post by:
Hi All, How to show dropdown list of menu items just like click on Parent menu. For example, Edit (Parent menu) Cut (child menu) Copy (child menu) Paste (child menu)
4
by: Bob Homes | last post by:
In VB6, I used a system, which I loved, whereby I assigned a "helpId" to each menu item; that way, you could rest the cursor on the item (without actually running it) and then press F1 to get...
8
by: gs | last post by:
I was able to set tooltips on objects other than main menu. I would like to get the effect of tooltip or microhelp in the bottom status bar when the mouse is hovering over a submenu item. How do...
1
by: xpnctoc | last post by:
Here's the 30,000-ft. view: I wrapped an asp:Menu control in an ascx control. When I try to dynamically populate the menu in the ascx control, the items appear, but clicking on them fails to trigger...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.