Clicking Menu of external application using pinvoke c# - c#

I am trying to create a app which uses winapi using pinvoke, this application reads menu structure of notepad. I got the whole menu structure using "GetSubMenu" and getting the text of menuitem using "GetMenuString"
In my app, I created same menu structure based on the structure I got from notepad. I would like to create functionality in my application such that when a user clicks on menu in my application it will click the corresponding menu in the notepad. How can I achieve this, I have tried tons of things but nothing seems to work. I tried using SendMessage, PostMessage but not sure how to use them.
Sorry if I have asked an already asked question, but a guidance would be highly appreciated.
EDIT:
As I said I create menu structure based on the menu structure I get from Notepad using GetMenuString, I want to send click to the menuitem in Notepad using MenuItemID, I don't want to click on particular coordinates, but on a particular menu.

Related

How to develop a shell ext. that adds a new button in a Explorer window? using SharpShell

Scenario
My current O.S. is Windows 8.1 x64, with plans to updgrade to Windows 10 x64 in the near future.
I frequently need to toggle between to show hidden files in explorer.
To solve this, I added a simple contextmenu item via registry, then when I do right click on the background of a folder I have my item that tooggles the hidden files visibility of Explorer.
Problem
Now I would like to make this functionality more accesible to avoid the need of that extra click to open the contextmenu. I would like to integrate the functionality as a shell extension to add a button near the default buttons that are at the bottom-right corner of each Explorer window:
Question
In C# or preferably VB.Net, and preferably using SharpShell library, how can I create a simple shell extension that adds a button with icon there?.
Note that when the button is clicked I need to have some kind of reference to identify the current Window on where I clicked the button.
Research
I've read all the official articles for beginners in this url below, however I didn't found any that talks about integrating an "addon" in Explorer (only about info tips).
Sharpshell - CodeProject
I know the existance of some expecific applications such as QTTabBar that adds functionalities in explorer such as menus and buttons via shell extension, It has a C# source code here and I'd anaylez it but it's a very huge VS solution and my main language is VB.Net, it's very unclear for me what the author do in the source code to add "addons" in the Explorer.
EDIT
AWM (Actual Window Manager) example of its Explorer integration:
QTTabBar's Explorer integration:

How to include windows right click menu in my application?

I have a desktop app which after taking input from the user displays a list of files and folder(using a ListBox).
I want that when the user right clicks on any item in the ListBox, the right click menu of windows explorer should display.
I know I will have to use P/Invoke for this, but I am unable to find any relevant information such as which dll I have to use or which function I have to call.
Can anybody help me with that?
So this question is very old but has no accepted answer. I dont think Visionstar understood the issue OP is having.
My understanding is that you have an application running, and you would like to add an option in the WINDOWS EXPLORER's right-click menu. Not in your own application's context menu.
I do not think you can achieve this within your own application, however, what you can do is add an item in the Windows explorer's context menu (nothing to do with your application, you can just do that in windows; see link below) that you can setup to call a little script you would make (literally a little batch file... but could be a .net app too). That little script can take care of warning you main application. By creating a text file, or json file in a hot folder, or some other mechanism you would have to come up with.
Adding an item in the windows' contextual menu:
How add context menu item to Windows Explorer for folders
If you need to deploy this to other PCs, you can make a add_menu.reg file to make it simpler. I'll let you Google that one, but I think it's as simpe as a right-click -> export key in your regedit.
You will need to code it yourself, there is no embedded way simply add a OS-Contextmenu to it,because you have programmed the listbox, so you have to append some contextmenu to the listitem-rightclicks
Here are examples/guidance for adding a context menu:
http://msdn.microsoft.com/en-us/library/aa984254%28v=vs.71%29.aspx
http://social.msdn.microsoft.com/Forums/windows/en-US/790cd8be-0ba8-4f10-95a8-c88f1023d6e7/how-can-i-create-a-rightclick-menu-i-c?forum=winforms

How to show system menu of a file in C#

I need to show system menu of a file in my application. This menu same as the image.
And, I also want to add a my menu element to this menu.
How can I do ?
Thanks
What you're looking for is called a shell context menu. To display such a menu in your application, you'll have to call the Windows API. This is not at all easy, but fortunately for you some other people have taken a stab at it.
The C# File Browser on CodeProject has a shell context menu, which is also described in that article.
Then Andreas Johansson extracted the shell context menu code from that project and uploaded it as a separate ZIP file, which you can download here.
I have no idea how to use it, or even if it works. That's left as an exercise for the reader. But there is a lot you can learn from this if you dig into the code.

Add custom item to right click menu when user selects text

I want to add a custom menu item to the menu that appears when a user selects some text and right clicks. I searched a lot but did not get any answer. Maybe I did not put in the right keyword.
Is it possible to do this?
If this is possible, I want to do this for all applications in windows whenever the user selects text. Is there a universal way to do it or will have to write code specific to the application?
I am using C#.
I don't think you can do that universally in all windows apps. But it is certainly possible to do in your own app using a popup menu.
I've also tried a way to add an item to the standard ContextMenu and failed. From my point of view, the only solution is to set the TextBox's ContextMenuStrip property to an instance of the ContextMenuStrip class and implement both standard and your custom menu items. It is easy to mimic standard operation, since the TextBox class provides all required methods: Cut, Copy, Paste, SelectAll.
The universal way is basically writing a "custom shell extension".
There is an article on CodeProject about how to do this.
http://www.codeproject.com/Articles/174369/How-to-Write-Windows-Shell-Extension-with-NET-Lang
The other way to do this is to build this into your application. For example you might have a text editor and you'll want to highlight a word and get a definition for that word. To do this you'll need to implement a context menu.
The VERY BASIC concept is detailed over on CodeReview.StackExchange.
https://codereview.stackexchange.com/questions/3983/c-programatically-creating-context-menu

how to get the control of the UI Element Clicked in a external application

How can i get the control (and possibly its text value) of a control which was clicked in another third party application (its not a .net or wpf application for which there are answers which did not solve my problem)
I can get the click event in my app (using the global hooks as mentioned here) i want the control/handle of that particular UI Element
Example : I have opened Notepad and when i click on File Menu, i want the control of that File button.
Look at the documentation for SetWindowsHookEx using the WH_CALLWNDPROC param. This will let you intercept messages in Notepad window procedure. You'll need to figure out which messages get generated from clicking the menu items in Notepad, you can use Spy++ for that. But there is no real control for the File button, it is part of a menu.

Categories