-
Aug 27th, 2002, 09:24 PM
#1
Thread Starter
New Member
using API, how to send message to click menu item programmatically..
Hi
the problem :
how to click menu item using Windows API programmatically , i have the window handle for Menu.
please help me out ....
Adesh. ( adesh_y@yahoo.com )
-
Aug 28th, 2002, 04:02 AM
#2
New Member
Click a menu item
Call SendMessage( X, WM_COMMAND, Y, ByVal 0)
X = Handle to the owner window
Y = menu item ID
*get the item id using the GetMenuItemID function
-
Mar 30th, 2017, 05:40 PM
#3
Junior Member
Re: using API, how to send message to click menu item programmatically..
You could do PopUp Menu for the menu item which will cause it to show near your mouse instead of at the menu bar, can probably mess with x and y to fix that. Scrapers〘N〙Bots
〘SCRAPER〙software that extracts, organizes and displays data from the web.
〘BOT〙software that automates and speeds up tasks on the web, mimicking human behavior.
-
Mar 30th, 2017, 08:20 PM
#4
Re: using API, how to send message to click menu item programmatically..
you can get the rest of the required info with spy++. You can also send alt-keystrokes if the menu supports them.
-
May 11th, 2018, 10:57 PM
#5
Junior Member
Re: using API, how to send message to click menu item programmatically..
Originally Posted by adesh
Hi
the problem :
how to click menu item using Windows API programmatically , i have the window handle for Menu.
please help me out ....
Adesh. ( adesh_y@yahoo.com )
Here is what to do.
[1] Make a shortcut key for the menu item
[2] to open the menu run this code changing the "%f" to whatever the appropriate sendkeys is.
Sub subSendAltF()
Dim wshShell: Set wshShell = CreateObject("WScript.Shell")
If Not (wshShell Is Nothing) Then
wshShell.SendKeys "%f"
DoEvents
Set wshShell = Nothing
End If
End Sub
〘SCRAPER〙software that extracts, organizes and displays data from the web.
〘BOT〙software that automates and speeds up tasks on the web, mimicking human behavior.
-
May 14th, 2018, 04:06 AM
#6
Re: using API, how to send message to click menu item programmatically..
You know... I got my start as a 90s teen on AOL making addons. Clicking menus was a big part of it back in the day. None of my code survives, but I've got a module from someone elses...
Code:
Public Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Public Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Public Declare Function GetMenuString Lib "user32" Alias "GetMenuStringA" (ByVal hMenu As Long, ByVal wIDItem As Long, ByVal lpString As String, ByVal nMaxCount As Long, ByVal wFlag As Long) As Long
Public Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Sub RunMenuByString(SearchString As String)
Dim AOL As Long, aMenu As Long, mCount As Long
Dim LookFor As Long, sMenu As Long, sCount As Long
Dim LookSub As Long, sID As Long, sString As String
AOL& = FindWindow("AOL Frame25", vbNullString)
aMenu& = GetMenu(AOL&)
mCount& = GetMenuItemCount(aMenu&)
For LookFor& = 0& To mCount& - 1
sMenu& = GetSubMenu(aMenu&, LookFor&)
sCount& = GetMenuItemCount(sMenu&)
For LookSub& = 0 To sCount& - 1
sID& = GetMenuItemID(sMenu&, LookSub&)
sString$ = String$(100, " ")
Call GetMenuString(sMenu&, sID&, sString$, 100&, 1&)
If InStr(LCase(sString$), LCase(SearchString$)) Then
Call SendMessage(AOL&, WM_COMMAND, sID&, ByVal 0&)
Exit Sub
End If
Next LookSub&
Next LookFor&
End Sub
You'd replace AOL with your window handle.
Edit: ...no I didn't see the dates before the last post
-
Feb 22nd, 2022, 12:08 PM
#7
New Member
Re: using API, how to send message to click menu item programmatically..
Thanks for your code, it helped me select some menus in Adobe Reader.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|