-
Jul 27th, 2020, 02:33 AM
#1
Thread Starter
New Member
[VB2008 Express] API to determine selected ListBox item in an external application
-
Jul 27th, 2020, 04:57 AM
#2
Re: [VB2008 Express] API to determine selected ListBox item in an external applicatio
Originally Posted by aporokizzu
Hello, this is my first post- I hope somebody can help.
First of all, I am using Visual Basic 2008 Express.
I am trying to write a Helper Utility for an application called RPG Maker MV, so in the application there is a ListBox and I am trying to determine which Item is currently highlighted:
Looking at the application in UI Spy, the ListBox is a "tree" LocalizedControlType and doesn't appear to have a ClassName:
The RPG Maker MV main Window has a ClassName- "Qt5QWindowOwnDCIcon":
So I am able to write a function that detects the hWnd of that:
Code:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Function RMMVGetWindow()
Dim hWnd As Long
hWnd = FindWindow("Qt5QWindowOwnDCIcon", vbNullString)
Return hWnd
End Function
But that's where my know-how ends. I do not know how to proceed from here, especially since the ListBox / "tree" doesn't have a ClassName.
Would anybody know if there is a FindChildByControlType() or something similar that I could use to get the ListBox / "tree"'s hWnd?
And then, after that, how do I extract which item is highlighted? Do I need to use SendMessage()?
I'll appreciate any advice that I can get... thanks in advance!
Hello Aporokizzu. Welcome to the forum!
You might want to look at this page: https://docs.microsoft.com/en-us/win...trol-reference. Also, there are a few programs on my Github page (see my signature) that deal with interacting with an external application's controls.
yours,
Peter Swinkels
-
Jul 27th, 2020, 05:28 AM
#3
Thread Starter
New Member
Re: [VB2008 Express] API to determine selected ListBox item in an external applicatio
Originally Posted by Peter Swinkels
Hello Aporokizzu. Welcome to the forum!
You might want to look at this page: https://docs.microsoft.com/en-us/win...trol-reference. Also, there are a few programs on my Github page (see my signature) that deal with interacting with an external application's controls.
yours,
Peter Swinkels
Peter Swinkels, thank you for your welcome and response- I appreciate the link you gave me to the Tree View Control Reference and the self-promotion of your Git repository... I might just be a bit thick but, it doesn't really seem to answer my question!
Let me try again-
I need to be able to get the hWnd of the Tree View Control in the RPG Maker MV application, which is difficult because (as I explained in my OP) the class name of the Tree View Control (according to UI Spy) is just a blank string.
So, I am asking, again, is there anyway to do a FindChildByControlType() using API so that I can use the parent hWnd (which I am able detect because I know the parent's class is "Qt5QWindowOwnDCIcon") and "ControlType.tree" (which I know is the Tree View's ControlType thanks to UI Spy) so I can determine the hWnd of the Tree View Control? (How does UI Spy determine that it is "ControlType.Tree"?)
Secondly, once I've determined the Tree View's hWnd- what is the best way (using API) to determine which item is currently selected?
I look forward to any and will be appreciative of any relevant answers to my query.
Thanks!
-
Jul 27th, 2020, 09:21 AM
#4
Re: [VB2008 Express] API to determine selected ListBox item in an external applicatio
Originally Posted by aporokizzu
Would anybody know if there is a FindChildByControlType() or something similar that I could use to get the ListBox / "tree"'s hWnd?
There are other utilities you can use which will display the hWnds of all windows. Maybe that "UI Spy" does? Just didn't see an hWnd for the selected item. But in this case it may not matter anyway.
If there is no classname, then there is no hWnd to be used. All Windows have a classname. You may be looking at some custom windowless control, don't know. Can't be sure from what I'm looking at.
-
Jul 27th, 2020, 10:32 AM
#5
Thread Starter
New Member
Re: [VB2008 Express] API to determine selected ListBox item in an external applicatio
Originally Posted by LaVolpe
There are other utilities you can use which will display the hWnds of all windows. Maybe that "UI Spy" does? Just didn't see an hWnd for the selected item. But in this case it may not matter anyway.
If there is no classname, then there is no hWnd to be used. All Windows have a classname. You may be looking at some custom windowless control, don't know. Can't be sure from what I'm looking at.
LaVolpe- thank you for your reply... but again, this doesn't answer my question.
I am sure that there are other utilities that can display the hWnd of the Tree View object, but the point is to have the Visual Basic 2008 program that I am trying to write determine its hWnd.
So, I am asking, if there is a way- given that I can use a function to determine the hWnd of the object's parent- that I can search through all the objects within that parent hWnd by using their ControlType... that way if the ControlType matches "tree", my program will know that this is the object being searched for and return that object's hWnd.
Also, it clearly does have a hWnd otherwise it wouldn't show up in UI Spy in the first place.
Again, I am hoping that somebody who is knowledgeable in the subject can provide a relevant answer.
What API function is UI Spy using to determine the ControlType of the objects?
Thanks!
-
Jul 27th, 2020, 11:52 AM
#6
Re: [VB2008 Express] API to determine selected ListBox item in an external applicatio
Also, it clearly does have a hWnd otherwise it wouldn't show up in UI Spy in the first place.
Then it has a classname. All windows are created from registered classes (globally or locally). If it has an hWnd, then that UI Spy tool isn't working properly.
The API GetClassName can be used to retrieve the class of any hWnd.
As for enumerating all the windows on any top level window, there are APIs for that too. Maybe look for examples using EnumChildWindows
What API function is UI Spy using to determine the ControlType of the objects?
Don't know, maybe the documentation will tell you. I'm not even sure what ControlType is in the context of that tool. For example: ControlType.Window? What does that even mean? All controls are windows, unless they are windowless.
Edited: Don't know if that is the Microsoft UI Spy tool or not. If it is, then it uses UIAutomation[xxxx] family of DLLs. And if that's the same tool, then this is a note from Microsoft: "The UI Spy tool is obsolete and no longer available. Developers should use other tools such as Inspect.exe that are available in the Windows Software Development Kit (SDK)"
Last edited by LaVolpe; Jul 27th, 2020 at 12:06 PM.
-
Jul 27th, 2020, 12:36 PM
#7
Re: [VB2008 Express] API to determine selected ListBox item in an external applicatio
Originally Posted by aporokizzu
Peter Swinkels, thank you for your welcome and response- I appreciate the link you gave me to the Tree View Control Reference and the self-promotion of your Git repository... I might just be a bit thick but, it doesn't really seem to answer my question!
Let me try again-
I need to be able to get the hWnd of the Tree View Control in the RPG Maker MV application, which is difficult because (as I explained in my OP) the class name of the Tree View Control (according to UI Spy) is just a blank string.
So, I am asking, again, is there anyway to do a FindChildByControlType() using API so that I can use the parent hWnd (which I am able detect because I know the parent's class is "Qt5QWindowOwnDCIcon") and "ControlType.tree" (which I know is the Tree View's ControlType thanks to UI Spy) so I can determine the hWnd of the Tree View Control? (How does UI Spy determine that it is "ControlType.Tree"?)
Secondly, once I've determined the Tree View's hWnd- what is the best way (using API) to determine which item is currently selected?
I look forward to any and will be appreciative of any relevant answers to my query.
Thanks!
You’re welcome. And yes, I admit to being guilty of self promotion. However I wouldn’t have recommended it unless I believed there would be something that really might help you. Did you actually look before dismissing it as just self promotion?
yours,
Peter Swinkels
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
|