Jump to content

Using WinList in Word VBA


Recommended Posts

I am currently using Autoit's "WinList" function in an Autoit script, I fully understand it.

Autoit provides a nice Library for Word VBA so that Some of Autoit's functions can be used within a MSWord VBA script, some of which I am using.

I have a use for Autoit's "WinList" function which has been provided by AutoIt in their Library for MSWord VBA scripting. The WinList function Creates an array when run. MSWord VBA does not seem to allow this. To create an array in VBA you have to first DIM it, and this does not seem to work for the WinList function.

For example:

Dim AutoIt As New AutoItX3Lib.AutoItX3

MyArray= Autoit(WinList)  produces an error, whether I dim the array or not. 

It seems that AutoIt has provided a function for VBA that cant be used ??

Can someone figure out a way to use WinList within Word VBA?

Thanks

 

Link to post
Share on other sites

Hello. All COM AutoIt functions exposed are no 100% functional. The return value from Winlist seems to be no compatible with vba (It could be done but it would need some memory+Api advanced stuff) So consider to use a VBA alternative or write your own WinList Function using windows API.

 

Saludos

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By XGamerGuide
      I'm trying to call WinList() with a handle. That should be possible:
      But I only get back an 2d array that looks like this:
      ---------
      0 |
      (That means no window was found.)
      It's not the window or the handle. When I call other functions like WinExists() or WinGetHandle() it works.
      Is it because of me, the description in the reference or because of Autoit who makes a mistake?
      No, because of the rest of my program I don't want to use WinGetTitle() because the format of WinList() has to be kept. Alternatively, I could create a 2d array myself, but it should also work with WinList() ... I hope.
    • By AndyK70
      I'm trying to fill a ListView with all normal viewable windows to act with them.
      First I tried with WinList:
      Local $aWinList = WinList("[REGEXPTITLE:(?i)(.+)]") Local $aTmp, $iID ;~ _ArrayDisplay($aWinList) For $i = $aWinList[0][0] To 1 Step -1 ; going backwards not disturbing the index while cycling through and deleting some If StringStripWS( $aWinList[$i][0], 3) == "" Or _ Not BitAND(WinGetState($aWinList[$i][1]), $WIN_STATE_VISIBLE) Or _ BitAND(WinGetState($aWinList[$i][1]), $WIN_STATE_MINIMIZED ) Then _ArrayDelete($aWinList, $i) Else ; Window has a Title and is "visible" $aTmp = WinGetPos($aWinList[$i][1]) If $aTmp[0] < -1000 Or $aTmp[1] < -1000 Then ; Window is minimized or tray icon _ArrayDelete($aWinList, $i) EndIf EndIf Next $aWinList[0][0] = UBound($aWinList)-1 ; getting actual # of windows ; Each row is now [ID]=> [Title], [hWnd] But it keeps getting Windows which are definitely not there at least not visible:

      Those windows "Rechner", "Einstellungen", "Netflix", "Microsoft Store", ... are not there!?! 
      It should list only the first three windows, which are real.
      I even tried it with _WinAPI_ UDF:
      $hWnd = _WinAPI_GetForegroundWindow() ; Add items _GUICtrlListView_BeginUpdate($idListview) If $hWnd <> 0 Then $iI = 0 Do If _WinAPI_IsWindow($hWnd) And _WinAPI_IsWindowVisible Then _GUICtrlListView_AddItem($idListview, WinGetTitle($hWnd)) _GUICtrlListView_AddSubItem($idListview, $iI, $hWnd, 1) $iI += 1 $hWnd = _WinAPI_GetWindow($hWnd, $GW_HWNDNEXT) EndIf Until $hWnd = 0 EndIf But it is the same...
       
      How can i distinguish those invisible windows from normal ones?
      PS: I'm using Windows 10, maybe it is important to know?
    • By cappy2112
      Hi,
       
      It's been a while since I've used AutoIt, but I'm having fun with it again.
      I'm running on Windows 7 Pro, 64_bit. with AutoIt 3.3.14.2+ 
       
      In my program, I've called Winlist(), so that I can get a list of all windows on the system.
      I then iterate through the titles, and attempt to copy the title & handle of Windows I'm specifically interested in.
      While this seems to be a very easy task, I'm having a strange problem copying the title & handle of the two windows that I'm interested in.
      In the For loop:
      For $i = 1 To $AllWindowsCount ConsoleWrite() displays the expected Title & handle, from the WindowsDupe array, so it appears that the copy from the $AllWindows array
      works as expected.
      However, when
      _ArrayDisplay($WindowsDupe) is called after the for loop, $WindowsDupe is empty.
       
      I wasn't able to find any functions in the help file, for copying entire arrays or certain elements, so I thought I would just copy them manually, as seen in the for loop.
      What am I doing wrong with the WindowsDupe array?
       
      Thanks
       
      Thanks
       
      My code is attached.
      ListWindows2.au3
    • By JohnNash
      So the code I use is as follows:
      Local $InstancesList = WinList("[REGEXPTITLE:(?i)(.*Paint.*|.*WinAmp.*)]")
      And then if this number changes, I do something. But once in a while I SEE a new window paint being opened but nothing happens. 
      So I added logs and printed the InstancesList and saw it did not pick up the new paint. 
      Now I also added a WinList with Class to doublecheck, but still now and then it fails. So I was wondering if this is a known problem, and whether there are alternatives of workarounds.
       
    • By JohnNash
      Hi, I use winlist to count the amount of instances of a specific window (in combination with a reg expression). Over multiple runs, it seems that it fails 1 in a hundred times more or less.                                   Any idea how/why? And are there alternatives to use as a backup/check?
       
                                                                                                                                                                                                                                                                                                                                                                      
       
×
×
  • Create New...