visual-studio-2013


Click on external application menu items - visual basic


Hi I've been struggling with this for a while now, would really appreciate help. I am developing a windows form application in visual studio 2013. It will open an external application, find a specific window and then I need to click on the menu's. Everything works fine, I find the window & menus but it won't click on the menu. If you look at the pic below, I need to click on "Print transaction listing":
Imports System
Imports System.IO
Imports System.Windows.Forms.Menu
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop
Imports System.Timers
Module FileMenu
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Int32) As Boolean
Public Declare Function GetMenu Lib "user32" Alias "GetMenu" (ByVal hwnd As Int32) As Int32
Public Declare Function GetSubMenu Lib "user32" Alias "GetSubMenu" (ByVal hMenu As Int32, ByVal nPos As Int32) As Int32
Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal winHandle As Int32, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32) As Int32
Public Const BM_GETCHECK = &HF0
Public Const BM_SETCHECK = &HF1
Public Const WM_LBUTTON_DOWN = &H201
Public Const WM_LBUTTON_UP = &H202
Public Const WM_COMMAND = &H111
<DllImport("user32.dll")> _
Public Function GetAsyncKeyState(ByVal vKey As Int32) As Short
End Function
Public Sub OpenMenu()
Dim ParentHWND As Int32
Dim sMenu As Int32
ParentHWND = FindWindow(vbNullString, "*******")
Threading.Thread.Sleep(1000)
If ParentHWND <> 0 Then
SetForegroundWindow(ParentHWND)
Threading.Thread.Sleep(1000)
Dim hMenu As Int32 = GetMenu(ParentHWND)
If hMenu <> 0 Then
SendMessage(hMenu , WM_COMMAND, 0, 0)
Threading.Thread.Sleep(1000)
sMenu = GetSubMenu(hMenu, 0)
Threading.Thread.Sleep(1000)
SendMessage(sMenu, WM_COMMAND, 0, 0)
Threading.Thread.Sleep(1000)
End If
End If
End Sub
End Module

Related Links

SSRS How to display only one row in groups column
SSRS Boolean Parameter With Multiple True Returns
Two Different Chutzpah Visual Studio Extensions
Specflow feature files in Visual studio 2013 express does not show color combinations
How to disable the option of hidden parameter extraction
Visual Studio 2013 Intellisense
How To Outline Within A Method?
How can I add a new top-level project to TFS?
w3wp.exe not attachable after installing Windows Management Framework 4
RM 2013 release fails because RM 2013 removes underscore
Visual Studio 2013 design view is very slow
Meta: Visual Studio Licensing
Text Editor in Visual Studio 2013
Error while trying to update edmx model from database
After Building assigned.apk is not showing on bin/Andriod/release folder am using visual Studio 2013 apche cordova?
vsDiffMerge.exe /m merge option is working like /t option?

Categories

HOME
crystal-reports
pug
vb6
firebase-app-indexing
jbehave
windows-store-apps
automated-tests
recyclerview
subquery
eval
intellij-plugin
automata
maxima
multiple-monitors
session-timeout
saiku
google-people
primes
thumbnails
koa
tarantool
binutils
k2
rworldmap
http-method
auditing
emv
image-quality
version-numbering
frp
hana-studio
pygooglechart
cell-array
ipfw
fractals
hashcat
lego
broadleaf-commerce
wfp
pmwiki
duktape
haskell-pipes
active-model-serializers
delphi-10.1-berlin
floating-accuracy
jupyter-console
tripwire
productivity
constants
excel-interop
dojox.mobile
azure-availability-set
istorage
cgcontext
launch
selenium-firefoxdriver
onresume
uistackview
gameanalytics
string-parsing
hyperthreading
datasnap
jericho-html-parser
leadtools-sdk
ffprobe
coypu
debian-based
swift2.1
adobe-indesign
jython-2.7
multipleselection
mser
and-operator
facebook-wall
argument-passing
kraken.js
late-static-binding
ksoap2
uipickerviewcontroller
gfs
driver-signing
nscolor
sttwitter
shiva3d
device-emulation
moq-3
blockingqueue
rose-db-object
ninject-extensions
driving-directions
surf
ets
svn-hooks
osx-leopard
unreachable-code
gwt-2.2-celltable
graniteds
visual-c++-2008-express
windows-controls
integer-promotion
system-codedom-compiler
usergroups

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App