Link to home
Start Free TrialLog in
Avatar of Ian Sturland
Ian Sturland

asked on

Cannot Select ComboBox item in another application

I am calling an external application from MS Access in Vb6 and trying to change a combo box selection, but all the sendmessage constants I have tried do not work. Code I have so far successfully opens the App, navigates to the correct window, expands the combobox and thats as far as i get. I have also attached a link to the Spy ++ tree
Sub RunSailwaveUpdates()
Dim hwnd As Integer
Dim SortSelect As String
SortSelect = "Fleet"
hwnd = FindWindow(vbNullString, "Sailwave - 
C:\Users\Public\Documents\Sailwave\Results\Summer Points.blw")
start_doc = ShellExecute(0&, "open", " 
C:\Users\Public\Documents\Sailwave\Results\Summer Points.blw", 0, 0, 
SW_NORMAL)
If start_doc = 2 Then Exit Sub
If start_doc = 3 Then Exit Sub
Do
DoEvents
hwindow2 = FindWindow(vbNullString, "Sailwave - 
C:\Users\Public\Documents\Sailwave\Results\Summer Points.blw")
hwindow3 = FindWindowEx(hwindow2, ByVal 0&, "ClaChildClient", vbNullString)
scoreseriesbutton = FindWindowEx(hwindow3, 0&, "ClaButton_0400000H", "Score 
Series")
Loop Until hwindow2 > 0 And hwindow3 > 0 And scoreseriesbutton > 0
WaitSeconds (0.5)
Call SendMessage(scoreseriesbutton, BM_CLICK, 0, ByVal 0&)
Do
DoEvents
scoreseries = FindWindow(vbNullString, "Score Series")
scoreseries2 = FindWindowEx(scoreseries, 0&, "ClaChildClient", vbNullString)
groupoption = FindWindowEx(scoreseries2, 0&, "ClaRadio_0400000H", "Score 
groups of competitors separately  -  scoring system is applied to each 
group")
groupfield = FindWindowEx(scoreseries2, 0&, "ClaPrompt_0400000H", "Grouping 
field")
groupfield1 = FindWindowEx(scoreseries2, ByVal 0&, "ClaDrop_0400000H", " ")
groupfield3 = GetWindow(groupfield, GW_HWNDNEXT)
Loop Until scoreseries > 0 And groupoption > 0 And groupfield > 0 And 
groupfield1 > 0 And scoreseries2 > 0 And groupfield1 > 0 And groupfield3 > 0
WaitSeconds (0.5)
Call SendMessage(groupoption, BM_CLICK, 0, ByVal 0&)
Do
DoEvents
Call SendMessage(groupfield3, CB_SHOWDROPDOWN, 1, 0)
Call SendMessage(groupfield3, CB_SETCURSEL, 2, 0)
Call SendMessage(groupfield3, WM_SETREDRAW, 1, 0)
selectedsort = SendMessage(groupfield3, CB_GETCURSEL, 0, 0)
Loop Until selectedsort > 0
End Sub

Open in new window

Spy--.PNG
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Any reason you don't want to control Access via OLE automation?

Jim.
Avatar of Ian Sturland
Ian Sturland

ASKER

Hi
Access is my Front end application, SailWave is a third party App. I am controlling actions in the 3rd party app as my application modifies the 3rd party app source file but then needs the functionality within the 3rd party app to take place.
I have got the app to open, click a button on the parent window, select a radio button on the child, but getting the combo box to preselect a specific option that I need to pass as a variable is a nightmare.
New to WinAPI but open to other methods if I can understand them :-)
Sorry, I read that totally backwards.  I thought you were working in VB6 and trying to get an Access combo.

 This is the exact opposite and has nothing to do with Access at all really.   What is your 3rd party app written in and does it not offer any kind of API or OLE interface?

Jim.
I looked at the web site:  https://www.sailwave.com/

 and it looks like they just have import/export capability built-in.    It would be very helpful to know what it was written in and what they are using for the interface (ie. Winforms).

 If you don't have that info, then it's going to be a lot of reverse engineering to figure out all the GUI elements and how to work with them.

 and by the way, Access uses VBA, not VB6 for it's programming language.   Not sure if your saying that this app is written in VB6, or if that was a mistake when you posted the question.

Jim.
No OLE interface available as i am aware of, i am using Win32 API calls in my access vba project to post actions in the 3rd party App, if you see my original post, its successful so fay up to this point of selecting a combobox list item, have tried many sendmessage combinations to no avail. The Spy++ snip is attached to the original post

Amend : Sorry meant Vb
Sorry, but I'm afraid I don't know the answer to this.   I have dabbled in Win API programming from time to time, but it is not a regular thing for me and I am not up to date on all the API calls you might need.

   It would be helpful to know what SailWave uses for its GUI components so you know what messages are expected for that combo, but it seems like your going to need to log all the Window messaging for the combo, then carry out the operation you want to emulate manually yourself in the program.

  Your log then should show you what messages need to get sent to the combo.

Jim.
Well this is that i haven't tried ...at least fully..but i recall sometime ago i had a small experience with AutoIt which a scripting language for interactivity with applications that don't expose any kind of external access..
Even if this seems "problematic" if my memory serves me right along with the main installation of AutoIT comes a small tray tool (sorry can't remember the name) that when you "interact" with   another application gives plenty of info about the handles involved...do install it and make a try ...probably it will get you the missing information.
I will try to fire it up when i am back home to refresh my memory but give it a spin for start.
AutoIT as an autonomous solution would give you "complete" control over the 3rd party app but it does require some learning...
Also check this post that has the same situation
Thankyou John will give it a go, whatever i come up with will need to be transportable as my App is likely to be rolled out across sailing clubs far and wide I hope, but it may provide the missing info, I have been using Spy++ and I have the correct handles as far as i can see but as I dig deeper, although it takes on the appearance of a combobox, I cannot see where the list resides

Just had a quick look and I am going to pursue this further especially as the script can be compiled into an exe and called from my app or I can use the COM & dll provided and try the direct approach, will keep you posted
By the way if its data manipulation that you are after (sorry haven't used sailwave...so i don't know anything about) where does it store its data and which form...maybe its easier to go to the source...unless special calculations are involved.
I have access to the background sailwave data file which is a text file that my app builds, its the functionality and publishing element of sailwave i am hooking into.
Ok then ...no need to reinvent the wheel...
exactly, just for background info and interest, my app is a dinghy sailing race management tool that controls the starting, finishing and results of dinghy racing, therefore all competitor info and times are already recorded, What sailwave is good at is compiling individual races over a period into a series or event results, so instead of re imputting all the data again it made sense to push my data into sailwave, but sailwave then uses a complex algorithm to calculate discards etc and its that i didnt want to try and replicate, plus sailwave is used and recognised worldwide ... Make Sense :-)
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.