在另一个应用程序中选择一个菜单项 [英] Select a menu item in another application
问题描述
我使用VB6,试图在第三方应用程序的子菜单中选择一个菜单项。我可以得到我想要点击,但现在我不知道如何实际点击才能有相关的动作运行键的菜单项目的ID。这里是我的code迄今:
I am using VB6 to try and select a menu item in a sub menu of a third-party application. I can get the ID for the menu item I want to click but now I am not sure how to actually click the button in order to have the related actions run. Here is my code so far:
hwnd = FindWindow(psClassname, vbNullString)
If hwnd > 0 Then
Call SetForegroundWindow(hwnd)
mwnd = GetMenu(hwnd)
sub_menu = GetSubMenu(mwnd, 0)
button_ID = GetMenuItemID(sub_menu, 0)
Call SetFocus(button_ID)
我得到的错误:
参数或无效的属性赋值错误号
Wrong number of arguments or invalid property assignment
我也尝试过使用:
Call SendMessage(button_ID, BM_CLICK, 0, 0)
但是这也不能工作。任何想法将大大AP preciated!
but this didn't work either. Any ideas would be greatly appreciated!
推荐答案
如果你有菜单项的ID,你可以发送/发布 WM_COMMAND
消息其母公司,包括ID。例如:
If you have the ID of the menu item, you can just send/post a WM_COMMAND
message to its parent that includes the ID. For example:
Private Const WM_COMMAND As Long = &H111
SendMessage hwnd, WM_COMMAND, button_ID, ByVal 0&
这篇关于在另一个应用程序中选择一个菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!