Sign in to follow this  
Followers 0
FinalVersion

Window Changes

4 posts in this topic

The following script is suppose to wait for you to change the active window, and then resize it. If you can tell me what's wrong, I'd appreciate it.

$aList = WinList()
Local $sActiveWindow

For $i = 1 To $aList[0][0]
    If WinGetState($aList[$i][0]) = 8 Then
        $sActiveWindow = $aList[$i][0]
        ConsoleWrite($sActiveWindow)
    EndIf
Next

While 1
    $aList = WinList()
    For $x = 1 To $aList[$x][0]
        If WinGetState($aList[$x][0]) = 8 Then
            If Not $sActiveWindow = $aList[$x][0] Then
                WinMove("[active]", "", 50, 50, @DesktopWidth - 100, @DesktopHeight - 125)
                ExitLoop
            EndIf
        EndIf
    Next
WEnd

Share this post


Link to post
Share on other sites



Try displaying the window states to see your problem:

$aList = WinList()
For $i = 1 To $aList[0][0]
    $iState = WinGetState($aList[$i][0])
    ConsoleWrite($i & ":  Title = " & $aList[$i][0] & "; Hwnd = " & $aList[$i][1] & "; State = " & $iState & @LF)
Next

How many 8's do you see?

:(


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

Share this post


Link to post
Share on other sites

Oh, well I tried using BitAND and BitOR, but neither worked. How can I solve this?

$aList = WinList()
Local $sActiveWindow

For $i = 1 To $aList[0][0]
    $iState = WinGetState($aList[$i][0])
    If BitAND($iState, 8) Then
        $sActiveWindow = $aList[$i][0]
        ConsoleWrite($sActiveWindow)
    EndIf
Next

While 1
    $aList = WinList()
    For $x = 1 To $aList[$x][0]
        If WinGetState($aList[$x][0]) = 8 Then
            If Not $sActiveWindow = $aList[$x][0] Then
                WinMove("[active]", "", 50, 50, @DesktopWidth - 100, @DesktopHeight - 125)
                ExitLoop
            EndIf
        EndIf
    Next
WEnd

Share this post


Link to post
Share on other sites

So, didn't your first For/Next loop work correctly with the BitAnd()? You could make it more reliable by using the Hwnd (window handle) instead of the title, which is $aList[$i][1] vice $aList[$i][0]. There might be multiple windows with the same title, but every window has a unique Hwnd, so it is the preferred way to ID a window.

Your second For/Next loop is all screwed up, but only because you didn't fix it like the first.

:(


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

Share this post


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
Sign in to follow this  
Followers 0