LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Autoit WINLIST does not provide all windows or variant data conversion programming error????

Solved!
Go to solution

My goal is to get the WINDOW NAMES (string data array), task list application items, for all open applications, so I can programmatically close any I don’t want running.  I would think using what I have shown should work fine converting the variant data to string.  However, as shown, only the window name for the calling vi is returned.  Maybe AUTOIT has a problem because the number of windows detected (returned array[0][0]) always seems to show 1 no matter how many applications I am running.  I tried anything and everything I could find on NI site, but no solution yet.  BTW, now windows are hidden, etc.

 

If no title and text is given then all top-level windows are returned.

The array returned is two-dimensional and is made up as follows:
$array[0][0] = Number of windows returned
$array[1][0] = 1st window title
$array[1][1] = 1st window handle (HWND)

...
$array[n][0] = nth window title
$array[n][1] = nth window handle (HWND)

 

I know calls to LVWUTIL32.DLL works fine but I would really like to use Autoit and understand what the problem is.  As and option, can anyone provide working vi that calls user32.dll directly to get the WINDOW NAMES (string data array) for all open applications.

autoit winlist.JPG

Shannon F
0 Kudos
Message 1 of 4
(4,912 Views)

The variant to data conversion seems to be working properly, since the rest of the data is coming out alright.  It's got the correct dimensions and the text isn't all garbage, so I think that part's ok.  I'm not very familiar with AutoIT, but from what you were saying it seems to be only recognizing 1 active window.  Can you get it to exhibit this same behavior when calling it from another programming language?  This would be a good test to see if the problem is with AutoIT or with LabVIEW. 

0 Kudos
Message 2 of 4
(4,863 Views)

Out of town til Monday...will try then

 

THANKS KYLE!

Shannon F
0 Kudos
Message 3 of 4
(4,849 Views)
Solution
Accepted by topic author sfleming

Figured it out a ways back, just forgot to post.

 

http://www.autoitscript.com/autoit3/docs/functions/WinList.htm

 

"Parameters

title [optional] The title of the window to read.
text [optional] The text of the window to read.

 

Return Value

Returns an array of matching window titles and handles.

 

Remarks

If no title and text is given then all top-level windows are returned."

 

"title" is not optional as stated on Autoit site.  Also, The Autoit instructions was also misleading as the funciton lists all processes too, not just open window names.


This was discussed on the site after searching in the RIGHT places:

http://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm

and http://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm

Use the "AutoItSetOption"  (REGEXPTITLE = [:alnum:]) with  "WinList", then look for visibile windows (to eliminate background processes).

 

I was actually looking for multiple instances so all I did was wire the first part of the window name (example would be to wire "notepad" to find all instances).  This turned out to be a simpler method than when I was using user32.dll call for application task list and then parsed through data to find particular windows.

 

Since I didn't need to go the full mile for getting the whole task list, I just wrote quick test code....messy, but worked fine.  If anyone happens upon this or needs the code, I will gladly spend a few minutes to clean up and post.  It just doesn't seem like anyone else is using this function and it may not be worth my time.

 

Thanks for your earlier reply/interest in helping!

 

 

Shannon F
0 Kudos
Message 4 of 4
(4,747 Views)