Jump to content

_arraysort Doesnt Sort Window Handles


Recommended Posts

hello anybody can help me with this, i want so sort an array with window handles but it doesnt work, only if i save them as strings (but then i cant use WinActive with this handle anymore!!)

here's the sample code (also in the attachment)

#include <Array.au3>
$var = WinList("A")
Dim $len = $var[0][0]

Dim $HANDLES[1]
Dim $STRING_HANDLES[1]
For $i = 1 To $len      
    _ArrayAdd($HANDLES, $var[$i][1])
    _ArrayAdd($STRING_HANDLES, "" & $var[$i][1])
Next

_ArrayDelete($HANDLES, 0)
_ArrayDelete($STRING_HANDLES, 0)

Dim $msg = ""
$msg = $msg & "Handles: "
$msg = $msg & _ArrayToString($HANDLES, " ")
_ArraySort( $HANDLES )
$msg = $msg & @CRLF
$msg = $msg & "  sorted: "
$msg = $msg & _ArrayToString($HANDLES, " ")
$msg = $msg & @CRLF & @CRLF

$msg = $msg & "StringHandles: "
$msg = $msg & _ArrayToString($STRING_HANDLES, " ")
$msg = $msg & @CRLF
_ArraySort( $STRING_HANDLES )
$msg = $msg & "         sorted: "
$msg = $msg & _ArrayToString($STRING_HANDLES, " ")
$msg = $msg & @CRLF

MsgBox(0, "_ArraySort", $msg)
Link to comment
Share on other sites

i know that window handles are a special type and thus the > < operators dont seem to work in the _ArraySort method, am i right?

i can make a work around with a 2 dimensional array and sort by the dim that holds the strings, and then use the handle-dimension... or you implement the <> for handles ;P

Link to comment
Share on other sites

i know that window handles are a special type and thus the > < operators dont seem to work in the _ArraySort method, am i right?

i can make a work around with a 2 dimensional array and sort by the dim that holds the strings, and then use the handle-dimension... or you implement the <> for handles ;P

why do you need to sort an array of window handles? i think your best bet would be to use WinList to generate your two dimensional array, then sort by the title dimension rather than the handle dimension.
Link to comment
Share on other sites

why do you need to sort an array of window handles? i think your best bet would be to use WinList to generate your two dimensional array, then sort by the title dimension rather than the handle dimension.

coz i want to switch through the windows in the same order they were opened, i did use a 2dim array already and it works, but they can also just implement the operators >< for window handle type... :)

Link to comment
Share on other sites

coz i want to switch through the windows in the same order they were opened, i did use a 2dim array already and it works, but they can also just implement the operators >< for window handle type... :)

i'm pretty sure i've seen code by valik that does what you're looking for... do a search of the forum for z-order and you may find what you're looking for
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...