Jump to content

Custom Control roadblock...


Recommended Posts

I have an issue that may have already been discussed elsewhere; if that's the case, then please accept my apologies and just steer me in the right direction.

Here's my problem:

I am using AutoIt v3.2.4.1 to write a script to test the integration between IBM RAD6 and Borland StarTeam. In theory, it shouldn't be very complicated: all I need to do is open RAD6, and set a couple of properties on different panels. Things have been going along reasonably well -- right up to the point that I encountered the "Customize Perspective" panel. The panel uses several non-standard, custom controls, which the AutoIt Window Info utility labels as "SysListView32" controls. The critical one looks like a list of checkboxes.

The Good News is that I can send keystrokes to these controls, such as TAB and DOWN and SPACE .

The Bad News is that neither the ControlCommand nor the ControlListView instructions work on these things. I can't read the imbedded text on these critters, or the labels, so I can't manage a list of items that is bound to differ from desktop-to-desktop.

So, I have decided that I have put enough forehead dents in my file cabinent, and am asking for help. Has anyone encountered this situation, or a similar scenario, before?

Also, what's the best way to probe a TreeView control and look at the contents before changing individual items? Again, these critters are buried within both RAD6 and StarTeam, and I haven't had any luck whatsoever accessing the TreeView control.

Thanx!

Link to comment
Share on other sites

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I am using AutoIt v3.2.4.1 to write a script to test the integration between IBM RAD6 and Borland StarTeam. In theory, it shouldn't be very complicated: all I need to do is open RAD6, and set a couple of properties on different panels. Things have been going along reasonably well -- right up to the point that I encountered the "Customize Perspective" panel. The panel uses several non-standard, custom controls, which the AutoIt Window Info utility labels as "SysListView32" controls. The critical one looks like a list of checkboxes.

ListView controls are a little...different.

Here are some pointers from PaulIA and eltorro.

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

ListView controls are a little...different.

Here are some pointers from PaulIA and eltorro.

:rolleyes:

Thanx for your help. Very encouraging. However, what follows are the usual rafter of dumb questions:

(1) Is Auto3Lib file a seperate library, or a reference for the contents of the C:\Program Files\AutoIt3\Include directory?

(2) May I presume that I am going to need to Include one or more AU3 files at the start of my script?

(3) Where did Warpi's "_ListView_ClickItem()" command from -- and are there other goodies there like it?

Link to comment
Share on other sites

Thanx for your help. Very encouraging. However, what follows are the usual rafter of dumb questions:

(1) Is Auto3Lib file a seperate library, or a reference for the contents of the C:\Program Files\AutoIt3\Include directory?

(2) May I presume that I am going to need to Include one or more AU3 files at the start of my script?

(3) Where did Warpi's "_ListView_ClickItem()" command from -- and are there other goodies there like it?

Download PaulIA's Auto3Lib. It has its own installer, and the directory will have its own help file. You will be including the appropriate file, like #include <A3L_ListView.au3>.

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Well, I've hit another brick wall. Using the Window Info utility, it shows me that the ControlID for these SysListView32 controls is assigned each time the program runs. Since there are three SysListView32 controls on the panel, and each is assigned a different ControlID every time, I am having trouble providing the _ListView_FindInText() function (and its peers) with a proper $hWnd value.

Any suggestions?

Link to comment
Share on other sites

Well, I've hit another brick wall. Using the Window Info utility, it shows me that the ControlID for these SysListView32 controls is assigned each time the program runs. Since there are three SysListView32 controls on the panel, and each is assigned a different ControlID every time, I am having trouble providing the _ListView_FindInText() function (and its peers) with a proper $hWnd value.

Any suggestions?

From the mind of the mighty SmOke_N: _CtrlGetByPos()

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

From the mind of the mighty SmOke_N: _CtrlGetByPos()

:whistle:

Looks interesting. I'm rather confused by the references to the "Client Coords", though. Looking at the code provided, I, too, would have used the AutoIt Window Info data.

So, here's what I'm looking at presently:

(1) Get the coords for each SysListView32 control....somehow.

(2) Call the _CtrlGetByPos() function (courtesy of SmOke_N) to get the ControlID for each SysListView32 control.

(3) Use these ControlID values in the _ListView_FindInText() function (and its peers).

Does that sound about right?

Happy 4th of July, everyone!! :lmao:

Edited by JeffHarris
Link to comment
Share on other sites

Ok, I figured out what the "Client Coords" meant (duh...), and running the _CtrlGetByPos() function is working as advertised. :lmao:

BUT: Using the ClassNameNN returned from the function does not seem to work for subsequent operations, like _ListView_GetItemCount(). Here's what I mean:

CODE

Func Determine_ControlIDs()

; Alter the method used to match window titles: 4 = Advanced mode...

AutoItSetOption ("WinTitleMatchMode", 4)

; Extract the ClassNameNN from the window's first SysListView32 control...

Global $Control_To_Interact_With_Is = _CtrlGetByPos('classname=SysListView32', '', 212, 164, 3)

If IsArray($Control_To_Interact_With_Is) Then

For $i = 1 To UBound($Control_To_Interact_With_Is) - 1

MsgBox(4096, "Debugging...", "Array contents: " & $Control_To_Interact_With_Is[$i] & ", Array index: " & $i)

Next

EndIf

; Reset the method used to match window titles: 2 = Match any substring in the title

AutoItSetOption ("WinTitleMatchMode", 2)

$listtotal = _ListView_GetItemCount($Control_To_Interact_With_Is[1])

MsgBox(4096, "Debugging...", "The total number of items in the control is " & $listtotal)

EndFunc

Every time I run this, the _ListView_GetItemCount returns zero. I've gotten similar results with such functins as _ListView_FindText().

So: What the heck am I doing wrong? Any suggestions? :whistle:

Edited by JeffHarris
Link to comment
Share on other sites

Ok, I figured out what the "Client Coords" meant (duh...), and running the _CtrlGetByPos() function is working as advertised. :lmao:

BUT: Using the ClassNameNN returned from the function does not seem to work for subsequent operations, like _ListView_GetItemCount(). Here's what I mean:

CODE

Func Determine_ControlIDs()

; Alter the method used to match window titles: 4 = Advanced mode...

AutoItSetOption ("WinTitleMatchMode", 4)

; Extract the ClassNameNN from the window's first SysListView32 control...

Global $Control_To_Interact_With_Is = _CtrlGetByPos('classname=SysListView32', '', 212, 164, 3)

If IsArray($Control_To_Interact_With_Is) Then

For $i = 1 To UBound($Control_To_Interact_With_Is) - 1

MsgBox(4096, "Debugging...", "Array contents: " & $Control_To_Interact_With_Is[$i] & ", Array index: " & $i)

Next

EndIf

; Reset the method used to match window titles: 2 = Match any substring in the title

AutoItSetOption ("WinTitleMatchMode", 2)

$listtotal = _ListView_GetItemCount($Control_To_Interact_With_Is[1])

MsgBox(4096, "Debugging...", "The total number of items in the control is " & $listtotal)

EndFunc

Every time I run this, the _ListView_GetItemCount returns zero. I've gotten similar results with such functins as _ListView_FindText().

So: What the heck am I doing wrong? Any suggestions? :whistle:

I don't think you want the class name of the control in there for the window title (first parameter):

; Alter the method used to match window titles: 4 = Advanced mode...
     AutoItSetOption ("WinTitleMatchMode", 4)  
    
     ; Extract the ClassNameNN from the window's first SysListView32 control...
     Global $Control_To_Interact_With_Is = _CtrlGetByPos('classname=SysListView32', '', 212, 164, 3)

Change 'classname=SysListView32' to the window title.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I don't think you want the class name of the control in there for the window title (first parameter):

; Alter the method used to match window titles: 4 = Advanced mode...
     AutoItSetOption ("WinTitleMatchMode", 4)  
    
     ; Extract the ClassNameNN from the window's first SysListView32 control...
     Global $Control_To_Interact_With_Is = _CtrlGetByPos('classname=SysListView32', '', 212, 164, 3)

Change 'classname=SysListView32' to the window title.

:whistle:

No change. I get valid data back from the _CtrlGetByPos(), but using that data in other functions is not working.

:lmao:

Link to comment
Share on other sites

No change. I get valid data back from the _CtrlGetByPos(), but using that data in other functions is not working.

:lmao:

Well, show us an example of code it doesn't work in... a short demo script, with just enough code to demo what doesn't work will take you very far toward a solution...

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Well, show us an example of code it doesn't work in... a short demo script, with just enough code to demo what doesn't work will take you very far toward a solution...

:whistle:

:lmao: Ok....

CODE

Func Customize_Perpsective()

; Open the "Customize Perspective" within RAD6...

WinMenuSelectItem("J2EE - IBM Rational Software Development Platform", "", "&Window", "Customi&ze Perspective..." )

; Focus upon the "Customize Perspective" panel...

WinWait("Customize Perspective", "")

WinActivate("Customize Perspective", "")

; The default tab is "Shortcuts", but we need to be on the "Commands" tab...

Send("+{TAB}{RIGHT}")

; Alter the method used to match window titles: 4 = Advanced mode...

AutoItSetOption ("WinTitleMatchMode", 4)

; Extract SysListView32 ClassNameNN (option "0" for the $iReturnType parameter ...

Global $Control_To_Interact_With_Is = _CtrlGetByPos("classname=SysListView32", "", 212, 164, 0)

; Reset the method used to match window titles: 2 = Match any substring in the title...

AutoItSetOption ("WinTitleMatchMode", 2)

; Determine how many items are visible in the SysListView32 control...

$listtotal = _ListView_GetItemCount ($Control_To_Interact_With_Is[1])

MsgBox(4096, "Debugging...", "Result of the ListView_GetItemCount is " & $listtotal)

; Determine if there are any "StarTeam" items visible anywhere in the SysListView32 control...

$var = _ListView_FindInText($Control_To_Interact_With_Is[1], "StarTeam", -1, True)

MsgBox(4096, "Debugging...", "Result of the search of the Available command group for literal 'StarTeam' is " & $var)

EndFunc

There is more to it, like actually examining the "StarTeam" items to make sure they are checked, but you get the idea. Edited by JeffHarris
Link to comment
Share on other sites

:lmao: Ok....

There is more to it, like actually examining the "StarTeam" items to make sure they are checked, but you get the idea.

This still looks wrong to me:

; Extract SysListView32 ClassNameNN (option "0" for the $iReturnType parameter ...
    Global $Control_To_Interact_With_Is = _CtrlGetByPos("classname=SysListView32", "", 212, 164, 0)oÝ÷ Øe¢,º'·jëʬyé­¡·®²)àiÊ'¶º%rV¬²)ìµæ¡ûa{§v7öÇ%jË-¢Ê^r'ò¶°whÀ l¢'ò¢éh¢F­Jc¤xÝý±Ê{*.®·­º¹Þuªëk'(ק¶ËzkhmëÚ®&æ§týz-²êÞ­¶­æ§±)ã]Ù÷ö×(g§¶¬r^~ÁRßsÒ¢ÚòÙbëaËh±ç¢*.j· zÛbÚrL!jܨºØbF®¶­s`²WG&7B74Æ7EfWs3"6Æ74æÖTäâ÷FöâgV÷C³gV÷C²f÷"FRb33c¶&WGW&åGR&ÖWFW"ââà vÆö&Âb33c´6öçG&öÅõFõôçFW&7EõvFô2Òô7G&ÄvWD'÷2gV÷C¶6Æ76æÖSÕ74Æ7EfWs3"gV÷C²ÂgV÷C²gV÷C²Â#"ÂcB bW'&÷"FVà ×6t&÷bÂgV÷C´W'&÷"gV÷C²ÂgV÷C´W'&÷"g&öÒô7G&ÄvWD'÷2ÂW'&÷"ÒgV÷C²fײW'&÷" VÇ6P ô'&F7Æb33c´6öçG&öÅõFõôçFW&7EõvFô2ÂgV÷C´FV'Vs¥ô7G&ÄvWD'÷2gV÷C² VæD

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Well, that was interesting: I get a separate window displayed ("Debug:_CtrlGetByPos")...must be what a GUICtrl looks like. Cool! :whistle: Anyway, what I am seeing is:

Row Col 0

[0] 2

[1] SWT_Window01

That's it. Now, anticipating that you would want to see the Window title used, I changed the code and ran it again, and got this:

Row Col 0

[0] 2

[1] SWT_Window01

Yes, the results were identical...

Before, I was getting back values that were somewhat more substantial....but then, I was using the "3" option instead of the "0" option for the $iReturnType parameter. So, just for giggles, I went back to the "3" option. For the "classname=SysListView32" test, I received this...

Row Col 4

[0] 4

[1] 66244

[2] SWT_Window013

[3] 0x000102C4

...and for the Window title test, I received this...

Row Col 4

[0] 4

[1] 590846

[2] SWT_Window01

[3] 0x000903FE

So, what does it all mean?

Link to comment
Share on other sites

I'm confused. You still seem to be working with control ClassNames where WinTitle should be, and getting what looks like a window ClassName back for your control ClassName.

I don't get it... :whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I'm confused. You still seem to be working with control ClassNames where WinTitle should be, and getting what looks like a window ClassName back for your control ClassName.

I don't get it... :lmao:

Welcome to my world. I've been trying different combinations and keep getting the same results:

CODE

Func Debugging()

; Alter the method used to match window titles: 4 = Advanced mode...

AutoItSetOption ("WinTitleMatchMode", 4)

;------------------------------------------------------------------------------------

MsgBox(4096, "Debugging...", "Using the classname=SysListView32 option...")

;------------------------------------------------------------------------------------

; Extract SysListView32 ClassNameNN (option "3" for the $iReturnType parameter)...

Global $Control_To_Interact_With_Is = _CtrlGetByPos("classname=SysListView32", "", 212, 164, 3)

If @error Then

MsgBox(16, "Error", "Error from _CtrlGetByPos(), @error = " & @error)

Else

_ArrayDisplay($Control_To_Interact_With_Is, "Debug:_CtrlGetByPos")

EndIf

; Determine how many items are visible in the SysListView32 control...

$listtotal = _ListView_GetItemCount ($Control_To_Interact_With_Is[1])

MsgBox(4096, "Debugging...", "Result of the ListView_GetItemCount is " & $listtotal)

; Determine if there are any "StarTeam" items visible anywhere in the SysListView32 control...

$var = _ListView_FindInText($Control_To_Interact_With_Is[1], "StarTeam", -1, True)

MsgBox(4096, "Debugging...", "Result of the search of the Available command group for literal 'StarTeam' is " & $var)

;------------------------------------------------------------------------------------

MsgBox(4096, "Debugging...", "Using the Window title option...")

;------------------------------------------------------------------------------------

; Extract SysListView32 ClassNameNN (option "3" for the $iReturnType parameter)...

Global $Control_To_Interact_With_Is = _CtrlGetByPos("Customize Perspective", "", 212, 164, 3)

If @error Then

MsgBox(16, "Error", "Error from _CtrlGetByPos(), @error = " & @error)

Else

_ArrayDisplay($Control_To_Interact_With_Is, "Debug:_CtrlGetByPos")

EndIf

; Determine how many items are visible in the SysListView32 control...

$listtotal = _ListView_GetItemCount ($Control_To_Interact_With_Is[1])

MsgBox(4096, "Debugging...", "Result of the ListView_GetItemCount is " & $listtotal)

; Determine if there are any "StarTeam" items visible anywhere in the SysListView32 control...

$var = _ListView_FindInText($Control_To_Interact_With_Is[1], "StarTeam", -1, True)

MsgBox(4096, "Debugging...", "Result of the search of the Available command group for literal 'StarTeam' is " & $var)

; Reset the method used to match window titles: 2 = Match any substring in the title...

AutoItSetOption ("WinTitleMatchMode", 2)

EndFunc

I get the same results for both variants. (I would insert an emoticon here for head-banging-desk or pulling-wads-of-hair, but I haven't found any...) :whistle: Edited by JeffHarris
Link to comment
Share on other sites

  • Moderators

I wrote the function long ago, let's see if I can remember what this output is:

[0] 4

[1] 66244 = Control ID (HOLY COW!)

[2] SWT_Window013 = ClassNameNN

[3] 0x000102C4 = Control Handle

Just looking at the above, I don't know any (off the top of my head) list views that have that ClassNameNN, are you even sure you have the right control?

Another suggestion may be so simple as to just set focus on the that particular control if you are sure that's the right control (I usually use ControlHide() when I play with the tough ones to test)

I would suggest using yet another one of my functions... http://www.autoitscript.com/forum/index.ph...c=32781&hl=

I would get all the controls on the GUI, then loop through them 1 at a time with my _list_view function, console write the results, if at the end of the loop, none of the controls returned anything, then you may be faced with the cold hard truth of not being able to automate this particular option. The other side, the positive side, would be that one of the controls gave you a result, and thus you would have the correct ClassNameNN then to work with.

I don't have anything to test it, so this is only my 2 cents worth (hope you don't need change :lmao: ).

@PsaltyDS - Did you bring me to this thread to see I don't comment my code much... If that was the case... if you read anything I ever write, I usually state that anyway ;) ... but in this case, I thought I had dummy proofed that code with the header :whistle:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...