Simulate clicking on a right-click menu (popup menu)
Hi all,
I want to simulate clicking on a right-click menu (popup menu).
How can I do it? What type of MESSAGE should I post?
The problem is that the popup-menu should not be opened (just the CLICK event of menu item should be done), or the pop-up menu should be invisible.
Thanks
Re: Simulate clicking on a right-click menu (popup menu)
did not understand your question really. is that your own app window that contain the poup menu ?
you can send the WM_RBUTTONDOWN / WM_RBUTTONUP Message i guess.
Example : If you send the WM_RBUTTONUP message to desktop, the desktop property menu is displayed.
Re: Simulate clicking on a right-click menu (popup menu)
What popup menu are you dealing with?
Your own or one from a third part app?
1 Attachment(s)
Re: Simulate clicking on a right-click menu (popup menu)
Its about a third party application (Its MMC-Routing and remote access settings on Win2003)
I want to open the CONFIGURATION dialog. See this picture:
http://www.vbforums.com/attachment.p...1&d=1199774547
By clicking on this menu item (Configure and enable...) the configuration dialog will be open.
I want to open the dialog without opening the popup menu. (because the menu is always-on-top and I want to do this automatically, and no popup-menu should be open)
Another solution is to open the 'Action' menu (see the picture), but the Action menu is not a menu! its a toolbar. I donno what to do! I just want to open the dialog (run a COMMAND who opens the dialog)
I think its not possible using Menu APIs. because its an invisible menu (popup menus are invisible I think) So what can I do?!?!
If you don't have Win2003, you can test it on SQL Server 2000 Enterprise manager. Its also the MMC.
Thanks a lot
Re: Simulate clicking on a right-click menu (popup menu)
I thing you will be able to ShellExecute the "Configure and Enable Routing and Remote Access" exe file. Open the program and check it's exe in task manager. if it is a seperate process , i thing you can easily shell it.
Re: Simulate clicking on a right-click menu (popup menu)
Quote:
Originally Posted by Fazi
I thing you will be able to ShellExecute the "Configure and Enable Routing and Remote Access" exe file. Open the program and check it's exe in task manager. if it is a seperate process , i thing you can easily shell it.
Yes, Its a different process (\windows\system32\remrras.exe) but there is 2 problems:
1. When I run remrras.exe, no dialog opens. May be only MMC should execute this process. I search the web and don't find anything about command-line parameters for remrras.exe
2. I want my automated software also do the 'Disable routing and remote access' menu. and this menu item don't run any other process.
What about this solution:
Find the 'Enable Config...' or 'Disable Config...' procedure address in MMC.EXE process memory, and CALL the procedures directly!
Can it possible? or not recommended?
Re: Simulate clicking on a right-click menu (popup menu)
Hi fatehi,
i guess what you´re looking for is located under \windows\system32\rraswiz.exe, which will configure ras and start it.
regards,
prones
Re: Simulate clicking on a right-click menu (popup menu)
hi fatehi,
while reading your initial question once again I might have found you trying the same thing that I´ve been trying :wave:
Like you said there are no params for remrras and there are none for rraswiz as well.
I tried to automate the RAS Setup for non-administrators. In case of restore needs. Currently i have a script that calls up rraswiz and fills in my config via vbscript sendkeys. Just to have an initial config. When finished with this step my script uses "netsh exec ras.netsh" to import my previously saved config (netsh ras dump > ras.netsh). The remoteaccess service is then restarted to effectively write changes within RAS.
If I´m not totally wrong with what was your question, it might help you.
Anyone out there with a more elegant solution? Because sendkeys is not very reliable. I spent a month now, trying to get it done with wmi, .net, registry settings or whatever but to no avail yet :(
regards,
prones
ps: let me know if your mmc approach was successful
Re: Simulate clicking on a right-click menu (popup menu)
Re: Simulate clicking on a right-click menu (popup menu)
:wave: anyone active here?
Re: Simulate clicking on a right-click menu (popup menu)
Quote:
Originally Posted by prones256
hi fatehi,
while reading your initial question once again I might have found you trying the same thing that I´ve been trying :wave:
...
:sick: So.... Seems that there is no more solutions. I can't use Sendkeys (or using sendmessage instead). because the end-user (of my application) should not see anything of RAS or other windows forms that automatically fills.
I think its a weak solution to simulate user clicks and keypresses to automate anything!
One (also weak!) solution is to show an always-on-top window, and simulate behind it! but you should disable ALT-TAB, Ctrl-Alt-Del, task manager and other things... but you have also problems with Popup-menus! because they are on top of the always-on-top windows!!! and more and more problems when simulating.... :(
But I'm working on it. If found any better solution, I'll post it here.
Thanks all who care this topic!
& Best Wishes for all VbForums members! ;)
1 Attachment(s)
Re: Simulate clicking on a right-click menu (popup menu)
As far as manipulating a popup menu see the attached zip file. It’s not a problem, but you are shooting in the dark. I am actively seeking API or code that can read a popup menu and see what item is selected..
Unzip the Demo.zip file.
Run proControlPopupMenu.vbp
Click the “Launch target app” button.
This will launch a seprate app that can create a popup of the type I need to read from.
The top text box will be the hwnd of the target app.
Click the “Open Popup” button to send a mouse click using PostMessage to the app to open the popup.
The second text box will have the hwnd of the menu.
You can manipulate the Popup menu using the bottom two buttons that use PostMessage to send key and mouse action to the menu.
Re: Simulate clicking on a right-click menu (popup menu)
Quote:
Originally Posted by SDG101
As far as manipulating a popup menu see the attached zip file. It’s not a problem, but you are shooting in the dark. I am actively seeking API or code that can read a popup menu and see what item is selected..
...
Thanks a lot for your nice sample. It detects any open popup menu. But it doesn't open a popup menu of an application. I test it on NOTEPAD and on SQL Server 2000 Enterprise Manager, it only detects and click the opened popups but opening the popup should be done manually.
any way, this sample was useful for me. Thanks again.
I'm searching for a solution to find the popupmenu function address in the app memory, and directly do the popupmenu item CLICK event, without opening and clicking it! (all hidden). I think it is possible.
Best regards.
1 Attachment(s)
Re: Simulate clicking on a right-click menu (popup menu)
Try this example. Pay atention to what handel is used for differant operation. Please let me know if this helps.
Re: Simulate clicking on a right-click menu (popup menu)
Quote:
Originally Posted by SDG101
Try this example. Pay atention to what handel is used for differant operation. Please let me know if this helps.
Thanks for your reply. In this sample you are simulate right-mouse-click event on EDIT object of Notepad. Note that I'm searching for a method to open a popup hidden, without showing anything on screen. because I want to do some RRAS settings in Win2003 Server in an Installer application. in this case, you should not open RRAS and open a popup menu on it, except doing it hidden. and bad news is that the Menus, are always in front of AlwaysOnTop forms! so you can't hide them by showing an AlwaysOnTop form in front of them, and do your settings behind it!
Normally, you can simply hide any forms and windows like Notepad, but the popup menus will always appear and visible. :(
Anyway, I think there is two ways:
1. open popup menu hidden (if ever possible!)
2. Do the CLICK_EVENT of popup menu item, without opening it.
There is a nice thread (this thread) that shows a way to do the second solution (click on menus w/o opening them), but works only by normal menus, not by popup menus.
I found in www.microsoft.com website that popup menus are permanently hidden and inaccessible. and this make the second solution harder!!
May be another solution is that hook a popupmenu, and give its function memory address (mnuItem_Click function I mean) and call the function directly w/o opening the menu item. I want to do this on specified application (MMC.EXE) not dynamically for any application, so the function address will not changed. and I can call it later w/o hooking anything!
Can you try this?
Thanks a lot
Re: Simulate clicking on a right-click menu (popup menu)
One thought
MMC SnapIns are configured at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MMC\SnapIns
many GUIDs will be there, Check if "NameStringIndirect" is available for your snapin.
"NameStringIndirect" would be a dll file, using Dependency walker you can see what function it exposes, use resource hacker to see if the dialog you wants to display is there in that dll or not.
Another thought
Instead of popup, clicking, etc. if you can find out what that dialog does, (could be some change in routing tables or enabling disabling something, or as simple as some change in registry) then you don't need to get that dialog or you can create more user friendly dialog.
You might wants to configure routing and remote access not opening a popup menu or clicking something or showing some dialog.
Re: Simulate clicking on a right-click menu (popup menu)
Quote:
Originally Posted by Vishalgiri
One thought
MMC SnapIns are configured at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MMC\SnapIns
....
Thanks for your reply.
I have been tested the registry monitoring solution. The RRAS read and writes large amount of data in registry while configuration! more than 1000 lines in regMonitor log file! and its too hard to detect registry changes. I think this service is related to some windows security settings and too hard to know what its doing!
& About your first solution (check registery snapin settings and chek its DLL functions) I should test it, & it takes time! because I am not familiar with resource hacker and DLL monitoring tools & I should search & learn more about these tools.
Anyway I will post the result!
Thanks a lot