Hi all,

Can anyone give me a hint how to select a menuchoice in an .Net
application via a post message.

I have got this far

objHandle = objForm.FindWindow ("WindowsForms10.Window.8.app.
0.3b95145", "MyApplication")

// FindWindow works and I have got a handle.

// Now I want to activate the a menu choise. e.g. File/Save

PostMessage objHandle, ?????????

Any hints appriciated

/Broeden

Re: Select menu choice in a .Net application via PostMessage by mayayana

mayayana
Tue Apr 03 09:50:58 CDT 2007

What's that got to do with VBScript? There's
VB, VB.Net, and VBScript. They're all entirely
different. You want a group with "dotnet" in
the name. Try one of these groups:

microsoft.public.dotnet.general
microsoft.public.dotnet.languages.vb
microsoft.public.vsnet.general

>
> Can anyone give me a hint how to select a menuchoice in an .Net
> application via a post message.
>
> I have got this far
>
> objHandle = objForm.FindWindow ("WindowsForms10.Window.8.app.
> 0.3b95145", "MyApplication")
>
> // FindWindow works and I have got a handle.
>
> // Now I want to activate the a menu choise. e.g. File/Save
>
> PostMessage objHandle, ?????????
>
> Any hints appriciated
>
> /Broeden
>



Re: Select menu choice in a .Net application via PostMessage by Broeden

Broeden
Tue Apr 03 11:38:19 CDT 2007

On 3 Apr, 16:50, "mayayana" <mayaXXyan...@mindXXspring.com> wrote:
> What's that got to do with VBScript? There's
> VB, VB.Net, and VBScript. They're all entirely
> different. You want a group with "dotnet" in
> the name. Try one of these groups:
>
> microsoft.public.dotnet.general
> microsoft.public.dotnet.languages.vb
> microsoft.public.vsnet.general
>
>
>
>
>
> > Can anyone give me a hint how to select a menuchoice in an .Net
> > application via a post message.
>
> > I have got this far
>
> > objHandle =3D objForm.FindWindow ("WindowsForms10.Window.8.app.
> > 0.3b95145", "MyApplication")
>
> > // FindWindow works and I have got a handle.
>
> > // Now I want to activate the a menu choise. e.g. File/Save
>
> > PostMessage objHandle, ?????????
>
> > Any hints appriciated
>
> > /Broeden- D=F6lj citerad text -
>
> - Visa citerad text -

I know the differences. A little more information.

>From a application that can act as a scripting host for VBScript,
(ArcPad from ESRI to be precise). I need to be able to communicate
with another application via FindWindow and PostMessage.

/Broeden



Re: Select menu choice in a .Net application via PostMessage by mayayana

mayayana
Tue Apr 03 13:36:09 CDT 2007

>I know the differences. A little more information.

>From a application that can act as a scripting host for VBScript,
(ArcPad from ESRI to be precise). I need to be able to communicate
with another application via FindWindow and PostMessage.
>

Maybe someone else can answer that question, but
it sounds like something you need to see the ArcPad
people about. VBS doesn't do API calls. If you have
reason to believe that you can call APIs through script
via ArcPad then that's a custom ArcPad thing.



Re: Select menu choice in a .Net application via PostMessage by mr_unreliable

mr_unreliable
Tue Apr 03 17:03:13 CDT 2007

Broeden wrote:
> Hi all,
>
> Can anyone give me a hint how to select a menuchoice in an .Net
> application via a post message.
>

hi Broeden,

The short story is that you can invoke a menu item by posting
a wm_command message along with the menu item ID.

Here is some code on how to do it. Note that the api declarations
are in a format used by one of those untrustworthy and unreliable
third-party controls (ugh!). which allows for calling api's from
script. But you can change the declarations to standard microsoft
declarations if your compiler supports such a thing.

--- <snip> ---

' --- INVOKE MENU ITEM -------------------------

Public Sub InvokeMenuItem(nMainItemPos)
Dim GetMenu ' as object
Set GetMenu = oATO.DeclareAPI("USER32.DLL", "GetMenu", "ByVal hWnd As
Long")
Dim GetMenuItemID ' as object
Set GetMenuItemID = oATO.DeclareAPI("USER32.DLL", "GetMenuItemID",
"ByVal hMenu As Long", "ByVal nPos As Long")
Dim PostMessage : Set PostMessage = oATO.DeclareAPI("USER32.DLL",
"PostMessageA", "ByVal hWnd As Long", "ByVal wMsg As Long", "ByVal
wParam As Long", "lParam As Any")
Dim Sleep : Set Sleep = oATO.DeclareAPI("KERNEL32.DLL", "Sleep",
"ByVal dwMilliseconds As Long")
'
Const sMe = "[clsWIN:InvokeMenuItem], "
Dim idMenuItem
Const WM_COMMAND = &H111

' first(!), check that the handle we are using is still valid...
BugAssert (IsValid(c_hWnd)), sMe & c_sMsgInvalidHandle

c_hMainMenu = GetMenu(c_hWnd) ' get the "main" menu...
BugAssert (c_hMainMenu <> 0), sMe & "couldn't find Main Menu handle "
' dbPrint sMe & " ..found main menu, handle is: " & CStr(c_hMainMenu)

' --------------------------------------------
' special case for pkzip, where there are an indefinite number of
file menu items,
' with the last one being "exit". In order to deal with the
indefinite number,
' use a "special constant" (last item) to indicate the last item...
' --------------------------------------------

if (nMainItemPos = c_LastMenuItem) then
dbPrint sMe & "setting last menu item = menuItemCount.. "

End If

' if all went well, now get at menu's requested item id...
idMenuItem = GetMenuItemID(c_hMainMenu, nMainItemPos)


' and, invoke/execute that menu item...
Call PostMessage(c_hWnd, WM_COMMAND, idMenuItem, 0)
Call Sleep(c_tLoadDelay)
' dbPrint sMe & "invoked Menu Selection: " & CStr(nMainItemPos)

Set GetMenu = nothing
Set GetMenuItemID = nothing
Set PostMessage = nothing
Set Sleep = nothing
End Sub ' invoke menu item

--- </snip> ---

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)