Jump to content

Recommended Posts

Ok, I have been trying to make a window list with the new DLL calls, but I am a bit stumped.

Any chance of a simple DDL call to do it?

Playing around, I came across this just for fun bit of code. Funny to see all the different handles lying around. I put the stop in because I realised it would take a long time.

wasn't a lot after 60000 anyhow...

AutoItSetOption("WinTitleMatchMode", 4);2 = Match any substring in the title

$x = DLLCall("user32.dll","hwnd","GetDesktopWindow")
$x = DLLCall("user32.dll","hwnd","GetWindow","hwnd",$x[0],"int",5)
While 1
$x = DLLCall("user32.dll","hwnd","GetWindow","hwnd",$x[0],"int",2)
If WinGetTitle("handle="&$x[0])<>"" Then MsgBox(1,$x[0],WinGetTitle("handle="&$x[0]) )
   If String($x[0]) = "00000000" Then ExitLoop
Wend

Updated the code after I saw how to actually use Getwindow.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to post
Share on other sites

Nice

I was way off, I didn't realize it was returning an array when I used them, lol

AutoItSetOption("WinTitleMatchMode", 4);2 = Match any substring in the title

$h = GetWindowHandles()
$dataout=""
For $i = 1 to $h[0]
$title=WinGetTitle("handle="&$h[$i])
 $dataout=$dataout&$h[$i]&"--->"&$title& @CRLF
Next
MsgBox(1,"Windows",$dataout)

Func GetWindowHandles()
 $GW_HWNDNEXT = 2
 $GW_CHILD = 5
 Dim $List[1]
 $List[0]=0

 $x = DLLCall("user32.dll","hwnd","GetDesktopWindow")
 if @error Then Return $List
 $x = DLLCall("user32.dll","hwnd","GetWindow","hwnd",$x[0],"int",$GW_CHILD)
 if @error Then Return $List

 While 1
   $x = DLLCall("user32.dll","hwnd","GetWindow","hwnd",$x[0],"int",$GW_HWNDNEXT)
   if @error Then ExitLoop
   If String($x[0]) = "00000000" Then ExitLoop
   If BitAnd(WinGetState($x[0]),2) Then
      $ub = Ubound($List)
      Redim $List[$ub+1]
      $List[$ub]=$x[0]
      $List[0]=$ub
   EndIf
 WEnd  
 Return $List
EndFunc

AutoIt3, the MACGYVER Pocket Knife for computers.

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.

×
×
  • Create New...