Sign in to follow this  
Followers 0
newcomer44

WinMove-function with new opened window

3 posts in this topic

Hello,

I took this (Post#8 in the thread): Cumulative Window lists (no duplicates)

and "modified" it to:

#include <Array.au3>

; Initialize tracking arrays
Global $avWinListPrevious[1][2] = [[0, ""]], $avWinListCurrent

; Monitor unique window handles
While 1
    $avWinListCurrent = WinList("[REGEXPTITLE:.+[ \- ]GIMP]", "GNU Image Manipulation Program")
    For $n = $avWinListCurrent[0][0] To 1 Step -1
   ; Check has title and visible
        If ($avWinListCurrent[$n][0] <> "") And BitAND(WinGetState($avWinListCurrent[$n][1]), 2) Then
       ; Check for already seen
            $fFound = False
            For $i = 1 To $avWinListPrevious[0][0]
                If $avWinListCurrent[$n][1] = $avWinListPrevious[$i][1] Then
                    $fFound = True
                    ExitLoop
                EndIf
            Next
            
       ; New window found
            If Not $fFound Then
                WinMove("[REGEXPTITLE:.+[ \- ]GIMP]", "GNU Image Manipulation Program", 169, 0, 893, 771 )
            EndIf
        Else
            _ArrayDelete($avWinListCurrent, $n)
        EndIf
    Next
    $avWinListCurrent[0][0] = UBound($avWinListCurrent) - 1
    $avWinListPrevious = $avWinListCurrent
    Sleep(500)
WEnd

I don't want to write to any file (what the author wanted),

but single (once) move every new opened window

or file from the "GIMP"-program with the "WinMove"-function,

so that it will be shown up on the screen at the function-setted position,

as soon as the window or file is opened.

Probably it would be better to use the "handle" of the new window in the "WinMove"-function

instead of "TITLE" and "TEXT". But I don't know how to do this.

The problem is that, if I open a GIMP-file from the program, it will be minimized to the taskbar.

That's not wanted.

If I click on the belonging taskbar-button, the window shows up, but the "WinMove"-function

from the script doesn't work any more.

I'm using GIMP with Windows XP.

I'm sorry about my bad English

Thanks in advance for Your help.

:P

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

Hello,

I took this (Post#8 in the thread): Cumulative Window lists (no duplicates)

and "modified" it to:

CODE
#include <Array.au3>

; Initialize tracking arrays

Global $avWinListPrevious[1][2] = [[0, ""]], $avWinListCurrent

; Monitor unique window handles

While 1

$avWinListCurrent = WinList("[REGEXPTITLE:.+[ \- ]GIMP]", "GNU Image Manipulation Program")

For $n = $avWinListCurrent[0][0] To 1 Step -1

; Check has title and visible

If ($avWinListCurrent[$n][0] <> "") And BitAND(WinGetState($avWinListCurrent[$n][1]), 2) Then

; Check for already seen

$fFound = False

For $i = 1 To $avWinListPrevious[0][0]

If $avWinListCurrent[$n][1] = $avWinListPrevious[$i][1] Then

$fFound = True

ExitLoop

EndIf

Next

; New window found

If Not $fFound Then

WinMove("[REGEXPTITLE:.+[ \- ]GIMP]", "GNU Image Manipulation Program", 169, 0, 893, 771)

EndIf

Else

_ArrayDelete($avWinListCurrent, $n)

EndIf

Next

$avWinListCurrent[0][0] = UBound($avWinListCurrent) - 1

$avWinListPrevious = $avWinListCurrent

Sleep(500)

WEnd

I don't want to write to any file (what the author wanted),

but single (once) move every new opened window

or file from the "GIMP"-program with the "WinMove"-function,

so that it will be shown up on the screen at the function-setted position,

as soon as the window or file is opened.

Probably it would be better to use the "handle" of the new window in the "WinMove"-function

instead of "TITLE" and "TEXT". But I don't know how to do this.

The problem is that, if I open a GIMP-file from the program, it will be minimized to the taskbar.

That's not wanted.

If I click on the belonging taskbar-button, the window shows up, but the "WinMove"-function

from the script doesn't work any more.

I'm using GIMP with Windows XP.

I'm sorry about my bad English

Thanks in advance for Your help.

:unsure:

The window handle is already in the WinList() array you saved in $avWinListCurrent at [$n][1] (see WinList() in the help file).

You could do WinSetState($avWinListCurrent[$n][1], "", @SW_RESTORE) to make sure it wasn't minimized, and this uses the handle to ID the window.

There is no point in using window Text if you have the handle, so your WinMove should be more like: WinMove($avWinListCurrent[$n][1], "", 169, 0, 893, 771)

:P

Edited by PsaltyDS

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

#3 ·  Posted (edited)

Hello PsaltyDS,

the problem is solved!

All I had to do was, to add this line : WinActivate($avWinListCurrent[$n][1], "") to the code.

After that it looks like this:

; New window found
            If Not $fFound Then
                WinActivate($avWinListCurrent[$n][1], "")
                WinMove("[REGEXPTITLE:.+[ \- ]GIMP]", "GNU Image Manipulation Program", 169, 0, 893, 771 )
            EndIf

And so it does exactly what I want.

As I see just now, You recommend in principle the same.

I also tried to use this: WinMove($avWinListCurrent[$n][1], "", 169, 0, 893, 771),

but it would also move a current window belonging to another program, if I would open such a window.

Thank You very much for Your help! http://www.autoitscript.com/forum/style_im...icons/icon1.gif

Edited by newcomer44

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