|
-
Oct 19th, 2007, 11:06 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] menuItemExecute
Am trying to execute a menu item " Documents " in the Adobe Profeesional 7.0
Code:
Dim Ok as boolean
ok = AcrobatApp.MenuItemExecute("DigSig:ToolsDiff")
This not working..
This ok return false only at all time..
Can anybody say how to execute this menu??
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 19th, 2007, 11:34 PM
#2
Re: menuItemExecute
Would you like to use SendKeys?
-
Oct 19th, 2007, 11:42 PM
#3
Thread Starter
Fanatic Member
Re: menuItemExecute
Without using sendKeys is it possible to fire this menu?
Last edited by vijy; Oct 19th, 2007 at 11:47 PM.
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 19th, 2007, 11:48 PM
#4
Re: menuItemExecute
only other way i know is SendMessage / PostMessae
-
Oct 19th, 2007, 11:53 PM
#5
Thread Starter
Fanatic Member
Re: menuItemExecute
Sorry i don know Send.../post messag..
If any solution in .net too?? U can share..
Could u say why menuItemExecute not working..??
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 19th, 2007, 11:56 PM
#6
Thread Starter
Fanatic Member
Re: menuItemExecute
U Pls share how to use post/send message in this application???
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 20th, 2007, 12:11 AM
#7
Re: menuItemExecute
vijy,
try this example shows how to execute notepad's Help>About Notepad menu item. Before run this code,keep open your note pad.
Code:
Option Explicit
Private Const WM_COMMAND = &H111
Private Const MIIM_TYPE = &H10
Private Const MIIM_ID = 2
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetMenu Lib "user32" (ByVal Hwnd As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" _
(ByVal hMenu As Long, ByVal un As Long, ByVal b As Long, lpMenuItemInfo As MENUITEMINFO) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Code:
Sub MenuClick(Hwnd As Long, Menu As Long, Item As Long)
Dim hMenu As Long, hSubMenu As Long, L As Long
Dim M As MENUITEMINFO
If Hwnd Then
hMenu = GetMenu(Hwnd)
If hMenu Then
hSubMenu = GetSubMenu(hMenu, Menu)
If hSubMenu Then
M.fMask = MIIM_TYPE Or MIIM_ID
M.dwTypeData = Space$(128)
M.cbSize = Len(M)
M.cch = 128
L = GetMenuItemInfo(hSubMenu, Item, True, M)
L = SendMessage(Hwnd, WM_COMMAND, M.wID, ByVal 0)
End If
End If
End If
End Sub
Code:
' Example - Open Notepad's About Dialog.
Private Sub Command1_Click()
Dim Lng As Long
Lng = FindWindow(vbNullString, "Untitled - Notepad")
MenuClick Lng, 4, 2 ' 0 based, menu seperators count as an item.
'4 mean, the 5th menu in note pad. 2 mean the 3rd item in the 5th menu. as sad, starts at 0 based.
End Sub
How this will give you the idea.
-
Oct 20th, 2007, 12:43 AM
#8
Thread Starter
Fanatic Member
Re: menuItemExecute
Thanks Fazi..
I studied this code..Any reference we have to include????
Let me try this in Adobe also...
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 20th, 2007, 12:47 AM
#9
Re: menuItemExecute
no referrences.
only you need the handle of the window where that menus are hanging.
-
Oct 20th, 2007, 12:54 AM
#10
Thread Starter
Fanatic Member
Re: menuItemExecute
Thank u...
Let me try and tell u..
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 21st, 2007, 05:28 AM
#11
Thread Starter
Fanatic Member
Re: menuItemExecute
Hi Fazi..
Am getting problem in send message..
If u have Adobe Profession 7.0 means pls try this...
1.Open a Pdf File..
Code:
OnCommand_Click
Dim Lng As Long
Lng = FindWindow(vbNullString, "Adobe Acrobat Professional - [test1.pdf]")
MenuClick Lng, 3, 10
Code:
Sub MenuClick(hwnd As Long, Menu As Long, Item As Long)
Dim hMenu As Long, hSubMenu As Long, L As Long
Dim M As MENUITEMINFO
If hwnd Then
hMenu = GetMenu(hwnd)
If hMenu Then
hSubMenu = GetSubMenu(hMenu, Menu)
If hSubMenu Then
M.fMask = MIIM_TYPE Or MIIM_ID
M.dwTypeData = Space$(128)
M.cbSize = Len(M)
M.cch = 128
L = GetMenuItemInfo(hSubMenu, Item, True, M)
L = SendMessage(hwnd, WM_COMMAND, M.wID, ByVal 0)
End If
End If
End If
End Sub
This code u only gave me yesterday..
This not workling...
Could u say watz the prob...
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 21st, 2007, 05:35 AM
#12
Thread Starter
Fanatic Member
Re: menuItemExecute
If i didnt open any file in Adobe means...
it is...
Code:
Lng = FindWindow(vbNullString, "Adobe Acrobat Professional")
MenuClick Lng, 3, 10
this working Fine..
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 21st, 2007, 05:52 AM
#13
Re: menuItemExecute
ok, i can give a temprary solution. i dont have adobe 7. using 8.
just find the window handle using a program like winspector spy, Jocim Anderson Window Finder (in VBF code bank) or the program in my signature.
So if you bring the cursor over tht window, which you want to send the message, you will shown the handle.
with out using find window, you just put the handle directly in SendMessage.
check weather your program works as expected. then you can realize what is the trouble. i mean weather you passing the correct window handle or not.
-
Oct 21st, 2007, 03:23 PM
#14
Re: menuItemExecute
You might want to try the Adobe SDK and also register as a member (free) as the info they have really helps with this kind of programming as is not really something that allot of developers do outsite their site.
I have done some development with it under 5.0 and their pdf documentation manuals are really helpful but you need to register in order to download them and accept the disclosure too.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 21st, 2007, 10:29 PM
#15
Thread Starter
Fanatic Member
Re: menuItemExecute
@ RobDogg
Ok Rob, I will register and see..
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 21st, 2007, 10:46 PM
#16
Thread Starter
Fanatic Member
Re: menuItemExecute
@ Fazi
ya fine, i will try through winspector spy,
Window handle id is a constant or it varies.. i watched the value its differing,
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 21st, 2007, 11:09 PM
#17
Thread Starter
Fanatic Member
Re: menuItemExecute
@ Fazi..
FindWindow returning a long value and the sendmessage also get executing but the menu only not executing,,
i dont know how to check its correct value or not..
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 21st, 2007, 11:34 PM
#18
Re: menuItemExecute
 Originally Posted by vijy
@ Fazi
ya fine, i will try through winspector spy,
Window handle id is a constant or it varies.. i watched the value its differing,
Yes, the handles value is not constant. Changes each time...
-
Oct 21st, 2007, 11:39 PM
#19
Re: menuItemExecute
 Originally Posted by vijy
@ Fazi..
FindWindow returning a long value and the sendmessage also get executing but the menu only not executing,,
i dont know how to check its correct value or not..
Then there wan't be a problem with the handle. somthing elase in your code.
check the return values of Getmenu api's
-
Oct 22nd, 2007, 12:07 AM
#20
Thread Starter
Fanatic Member
Re: menuItemExecute
I checked window handle through spy++, its correct only..
Getmenu too returning values.. But the menu only not executing if any files opened in the Adobe... :-(
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 22nd, 2007, 12:21 AM
#21
Re: menuItemExecute
GetMenu()
If the function succeeds, the return value is the handle of the menu.
GetMenuItemInfo()
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
GetSubMenu()
If the function succeeds, the return value is the handle of the drop-down menu or submenu activated by the menu item. If the menu item does not activate a drop-down menu or submenu, the return value is NULL.
-
Oct 22nd, 2007, 12:43 AM
#22
Re: menuItemExecute
I think without using the Adobe SDK you will continue having issues as its not really designed to be automated this way. You need to use some JavaScript and other scripts inside Adobe and/or the document itself.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 22nd, 2007, 12:50 AM
#23
Thread Starter
Fanatic Member
Re: menuItemExecute
@ RobDogg.
I googled in adobe for the script of this "Documents", they clearly stated that "Documents menu is not automated"....
I already did some applications using Adobe scripts..
@ Fazi.
Is it possible to execute the menu using process id.... If so means i can execute the Adobe.exe using shell.. and get the process id..
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 22nd, 2007, 12:59 AM
#24
Re: menuItemExecute
I am not sure about that vijy.
do your code works with notepad if you change the handle to notepad?
if its working with notepad and not working with adobe, you have to check what RobDog advised.
-
Oct 22nd, 2007, 01:00 AM
#25
Re: menuItemExecute
With the sdk they show how you can execute and even add your own menu items to Adobes menus.
With using vb you can create the AcroExch.App object and automate the application. Why doesnt MenuItemExecute work for you? Are you sure you have the correct menuitem id for the desired menu item? This is the most proper and stable way to automate Adobe.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 22nd, 2007, 01:14 AM
#26
Thread Starter
Fanatic Member
Re: menuItemExecute
Yes rob, am giving the correct value for menuItemExecute.. Its working fine..
In pdf, if i didnt opened any file in Adobe means,the menu executing..
Am getting problem in this case alone " If any pdf file opened in the Adobe,MenuClick not executing "
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 22nd, 2007, 01:32 AM
#27
Thread Starter
Fanatic Member
Re: menuItemExecute
@ Fazi..
This working fine in notepad.. Only in Adobe this not working..
Code:
Lng = FindWindow(vbNullString, "test1.txt - Notepad")
MenuClick Lng, 0, 1
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 22nd, 2007, 02:09 AM
#28
Re: menuItemExecute
I dont have Adobe anymore but if it works fine when a document is opened in it and it doesnt work if there is no document loaded then perhaps the menu item is not available unless there is at least one open document?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 22nd, 2007, 02:31 AM
#29
Thread Starter
Fanatic Member
Re: menuItemExecute
Rob MenuClick works fine if the Adobe doesnt open any pdf files..
In case 1 MenuClick Working Fine..
In Case 2, menuClick not working...
Case 1:
Code:
Lng = FindWindow(vbNullString, "Adobe Acrobat Professional")
MenuClick Lng, 3, 10
Case 2:
Code:
Lng = FindWindow(vbNullString, "Adobe Acrobat Professional - [test1.pdf]")
MenuClick Lng, 3, 10
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 22nd, 2007, 02:33 AM
#30
Re: menuItemExecute
Have you used Spy++ to determine the window structure as once documents are opened in it the structure changes. The document opened is a child window and the menu handles may change due to merging of the menus etc. But is the exact window caption in Spy++ as you have it exactly in your code in case #2?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 22nd, 2007, 02:34 AM
#31
Thread Starter
Fanatic Member
Re: menuItemExecute
Rob,
I googled and got a javascript from Adobe developers for executing menu item..
I think it will work sound to Here
Let me try this..
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 22nd, 2007, 02:35 AM
#32
Re: menuItemExecute
But that is the MenuItemExecute function we discussed earlier in this thread.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 22nd, 2007, 03:39 AM
#33
Thread Starter
Fanatic Member
Re: menuItemExecute
Lng = FindWindow(vbNullString, "Adobe Acrobat Professional - [test1.pdf]")
this will return the window handle,,
I checked the winows handle in spy++ along with the value returned from the find window both are different.. ...
Last edited by vijy; Oct 22nd, 2007 at 03:48 AM.
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 22nd, 2007, 04:18 AM
#34
Last edited by Fazi; Oct 22nd, 2007 at 05:44 AM.
-
Oct 22nd, 2007, 04:59 AM
#35
Thread Starter
Fanatic Member
Re: menuItemExecute
I Got the result....
Thanks Fazi...
When i opened a file in the Adobe,before the "File" menu,an image(Adobe Logo) is there... I didnt counted the image, When passing menu value in the MenuClick hwnd,menu,....
If no file opened in pdf means...there is no Logo before the "File" Menu.. This is the problem..
I attached two images.. jus see it.
Thanks a lot Rob and Fazi...
Last edited by vijy; May 23rd, 2008 at 01:15 AM.
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 22nd, 2007, 05:09 AM
#36
Thread Starter
Fanatic Member
Re: menuItemExecute
Now i want to click "ok" in the dialog Box,.. Could u tell which Api to use pls..
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 22nd, 2007, 05:13 AM
#37
Re: menuItemExecute
SendMessage Button_handle,BM_CLICK,0,0
-
Oct 22nd, 2007, 05:27 AM
#38
Thread Starter
Fanatic Member
Re: menuItemExecute
How to get the Button_Handle of the Particular dialogue box through code???
FindWindow("Button",vbNullString)
Last edited by vijy; Oct 22nd, 2007 at 05:43 AM.
Visual Studio.net 2010
If this post is useful, rate it

-
Oct 22nd, 2007, 05:43 AM
#39
Re: menuItemExecute
This code shows how to obtain the Notepad About box button handle.
Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim lngresult As Long
lngresult = FindWindow(vbNullString, "About Notepad")
lngresult = FindWindowEx(lngresult, 0&, vbNullString, "OK") 'OK IS THE Button text
MsgBox lngresult
End Sub
Hope this will solve the issue.
Good Luck
Last edited by Fazi; Oct 22nd, 2007 at 05:48 AM.
-
Oct 23rd, 2007, 04:03 AM
#40
Re: menuItemExecute
A modal dialog window has a special class name of #32770. Use Spy++ to verify it and your level of nesting of the OK button. It may not be the first child window
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|