How do I add items to all windows' window menus? - windows

I'd like to write a utility in the vein of PowerMenu - it adds some extra stuff into all applications' window menus (alt-space, that menu).
How does one go about doing this?

Inject some code to each window's process.
Use GetSystemMenu() in the hook to retrieve that windows "alt-space" menu
Make your modifications
Cleanup
I'd personally use SetWindowsHookEx(), WH_CALLWNDPROC, and a CallWndProc to achieve step 1, requiring a call to UnhookWindowsHookEx() in step 4, and bit of custom message pumping to get step 2 rolling. That's just personal preference though.

You can do it in such a way:
Get all the windows that have a system menu
Insert custom items into the menu
Install hooks that will send events from menu items to your process
Handle events inside your process
You can find an example here https://github.com/AlexanderPro/SmartSystemMenu

Related

Custom Title Bar Context Menu Actions

I want to add custom actions to every window's title bar context menu. The goal is to add an option like in the task view where you can move a window to a different virtual desktop. I was able to do this with hotkeys using GlobalHotKey and WindowsDesktop packages in C#. But I want to do it in the UI as well similar to some Linux desktop environments.
I know you cannot normally do this with the registry like you can with other context menus. When creating your own application I know you can use GetSystemMenu, AppendMenu, etc. and override WndProc to handle it. But this obviously will not work for what I am intending.
The application Moo0 Window Menu Plus achieves the desired effect but I have no idea how they do it.
I have a feeling the solution is probably somewhat hacky but I would still like to know how it could be done. I am open to using any language to achieve this.
You need to inject into the process, that is the only way to add a menu item.
A shell hook will notify you with HSHELL_WINDOWCREATED when a appropriate window has been created. You can then inject into the process (with another hook type or CreateRemoteThread). Once you have your .DLL in the process you can subclass the window and change the system menu.
You need to create both a 32-bit and 64-bit injection .DLL and I would recommend that you write it in native code, not C#.

Handle GUI window changes

I'm doing an automation script for installation wizards using AutoIt. I'm trying to handle window changes in some way.
Can some one explain how these GUI's work?
When I click on the Next button it looks just like the components in the GUI is beeing changed. Is this tha case? Or is a new window created and the old destroyed?
I've noticed that the process ID is the same for all windows.
I'm sure there is some way to know which "state" the GUI is in, or which step?
By the way. All the windows has the same title.
Thanks
/Anders
This will be dependant on the program you are automating.
The easiest approach would be to look at what changes in the GUI between stages, likely candidates are if there is a label that is giving instructions for that step, or a button that has text changing (e.g. if the button says "Finish" then you know your at the end).
Most installer programs have child windows for grouping the controls of each stage. These are typically implemented as dialog resources (as can be seen when using something like reshacker on them). So although the window remains the same, the panels are being created/destroyed as appropriate. This is a very neat method of doing it, for the obvious reason that you don't need to have to code to create/destroy a lot of controls. Resource created dialogs don't have nice class names like windows sometimes do though, so this may not be a reliable way to check the state.

How to disable cut, copy, paste, rename, etc from the Windows Registry?

I'm trying to create a software in VB.Net as my uni project to disable the following from a Windows 7 pc. I think they have to be disabled from the context menu of the Windows Registry, but instead of disabling the whole context menu, I'd like to disable the following individually.
Cut, copy, paste, rename, delete, open, print, share, create shortcut, open with, send to, new, properties.
I want to give users the option of disabling them selectively/individually via checkboxes so those options will be disabled in the right-click of a mouse.
My problem is I don't know which is the right key to disable as the registry is so huge & some keys are similiarly named.
Could anyone help me to say what are the exact key locations of the above-mentioned right-click functions in the Windows Registry or how to go about this ?
The deep flaw in the assumptions made in this question is that the context menu is configured by registry entries. It is not. Windows allows modifying a window's context menu by sending the WM_CONTEXTMENU message. Code, not config. If you are not happy with the default implementation of that message then you subclass the window procedure and provide your own message handler for that message so you can display your own context menu. This is core to the way Windows works.
Modifying the context menu of a program you didn't write is possible too but much more complicated. You use SetWindowsHookEx() to inject a DLL into the other process. You cannot write a DLL like that in VB.NET, it requires native code. Because that process won't have the CLR loaded to run your managed code.

Windows explorer get list of selected items and pass it to another process

I have to create File/Folder management system. In which user can select multiple files/folder and from context menu execute an command.
That command sends list of all selected files/folders list to invoke a process. So that, process can work on file/folder list.
If process is running the context menu should not shown or greyed out.
I added context menu but can't find the way to disable it. How can I do all this?
Any possible study link will help a lot?
Your IContextMenu::QueryContextMenu handler can apply whatever logic you desire to determine whether to show/hide a menu item, and if shown, whether it is enabled or disabled. Note, however, that in general, shell extensions should not be written in managed code due to CLR injection concerns.

Replacing the Start Menu

I want to make my own Start Menu replacement and I am trying to figure out what approach to use. There are a number of ways the Start Menu is activated: click on it, hit windows key, hit Ctrl+Esc keys or tab until it gets focus and hit the space or enter key.
I know enough about win32 to do each one of these separately and I could figure it out with Spy++. I'd really like to know if there is an easier way through and I can't find any helpful articles.
I'd like to do this for XP and Vista/Windows 7.
I guess that you would have to inject yourself into the explorer.exe process (There can be more than one, but you want the one that has the "Shell_TrayWnd" window) and subclass the taskbar or one of its children to catch/eat the message that brings up the startmenu and instead, show your own window.
Take a look at http://bitbucket.org/wez/evildesk/src/755606d7935d/gdi.cpp , I think you could start your project by seing what they've done.
You can use WindowBlinds and design your own Start Menu as well.

Resources