Jump to content

How do I make an array of windows move into correct positioning?


vladedoty
 Share

Recommended Posts

i have and array of window names and would like them to move into the correct x and y positions on my screen

I use the WinMove function but doesn't seem to be helping much.

It won't move any of the windows.

Is there a more effective way to write the code or use a different function?

Here is an example:

#include <array.au3>

Global $WinNames[4]
Global $handleWin[4]
Global $a, $winNum
Global $positionx[4]
Global $positiony[4]

$positionx[0] = "0"
$positiony[0] = "0"
$positionx[1] = "478"
$positiony[1] = "0"
$positionx[2] = "0"
$positiony[2] = "478"
$positionx[3] = "218"
$positiony[3] = "0"

$WinNames[0] = GUICreate("hello", 200, 400)
$WinNames[1] = GUICreate("hello", 100, 200)
$WinNames[2] = GUICreate("hello", 300, 400)
$WinNames[3] = GUICreate("hello", 300, 500)

For $a = 0 to 3
$winNum = WinGetTitle($WinNames[$a], "")
$handleWin[$a] = WinGetHandle($WinNames[$a], "")
WinMove($handleWin[$a], "", $positionx[$a], $positiony[$a])
Next
Edited by vladedoty
Link to comment
Share on other sites

With something like this.

Dim $aPos[4][2] = [[0, 0], [478, 0], [0, 478], [218, 0]]
Dim $aWnd[4]

$aWnd[0] = GUICreate("hello", 200, 400)
$aWnd[1] = GUICreate("hello", 100, 200)
$aWnd[2] = GUICreate("hello", 300, 400)
$aWnd[3] = GUICreate("hello", 300, 500)

...

For $i = 0 To UBound($aWnd) - 1
    WinMove($aWnd[$i], "", $aPos[$i][0], $aPos[$i][1])
Next

EDIT:

For $i = 0 To UBound($aWnd) - 1
Edited by Yashied
Link to comment
Share on other sites

With something like this.

Dim $aPos[4][2] = [[0, 0], [478, 0], [0, 478], [218, 0]]
Dim $aWnd[4]

$aWnd[0] = GUICreate("hello", 200, 400)
$aWnd[1] = GUICreate("hello", 100, 200)
$aWnd[2] = GUICreate("hello", 300, 400)
$aWnd[3] = GUICreate("hello", 300, 500)

...

For $i = 0 To UBound($aWnd)
    WinMove($aWnd[$i], "", $aPos[$i][0], $aPos[$i][1])
Next

Thx for the quick resonse

but how is this any different?

Link to comment
Share on other sites

With something like this.

Dim $aPos[4][2] = [[0, 0], [478, 0], [0, 478], [218, 0]]
Dim $aWnd[4]

$aWnd[0] = GUICreate("hello", 200, 400)
$aWnd[1] = GUICreate("hello", 100, 200)
$aWnd[2] = GUICreate("hello", 300, 400)
$aWnd[3] = GUICreate("hello", 300, 500)

...

For $i = 0 To UBound($aWnd)
    WinMove($aWnd[$i], "", $aPos[$i][0], $aPos[$i][1])
Next

Be careful with arrays: their indexes are 0-based, which means you must use UBound($array)-1, or you'll end up with a fatal error.
Link to comment
Share on other sites

Link to comment
Share on other sites

...but how is this any different?

$positionx[0] = "0"
$positiony[0] = "0"
$positionx[1] = "478"
$positiony[1] = "0"
$positionx[2] = "0"
$positiony[2] = "478"
$positionx[3] = "218"
$positiony[3] = "0"

Think of it what are you doing?

Link to comment
Share on other sites

$positionx[0] = "0"
$positiony[0] = "0"
$positionx[1] = "478"
$positiony[1] = "0"
$positionx[2] = "0"
$positiony[2] = "478"
$positionx[3] = "218"
$positiony[3] = "0"

Think of it what are you doing?

Well the thing is that all $positionx and $positiony elements are input boxes.

so something like this so they will always change based on the users input

Global $x1Txt = GUICtrlCreateInput("0", 255, 299, 33, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
Global $x2Txt = GUICtrlCreateInput("0", 255, 323, 33, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
Global $y1Txt = GUICtrlCreateInput("0", 327, 299, 33, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
Global $y2Txt = GUICtrlCreateInput("201", 327, 323, 33, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))

$positionx[0] = ControlGetText($mainGui, "", $x1Txt)
$positiony[0] = ControlGetText($mainGui, "", $y1Txt)
$positionx[1] = ControlGetText($mainGui, "", $x2Txt)
$positiony[1] = ControlGetText($mainGui, "", $y2Txt)
Link to comment
Share on other sites

Link to comment
Share on other sites

i have and array of window names and would like them to move into the correct x and y positions on my screen

I use the WinMove function but doesn't seem to be helping much.

It won't move any of the windows.

Is there a more effective way to write the code or use a different function?

Here is an example:

#include <array.au3>

Global $WinNames[4]
Global $handleWin[4]
Global $a, $winNum
Global $positionx[4]
Global $positiony[4]

$positionx[0] = "0"
$positiony[0] = "0"
$positionx[1] = "478"
$positiony[1] = "0"
$positionx[2] = "0"
$positiony[2] = "478"
$positionx[3] = "218"
$positiony[3] = "0"

$WinNames[0] = GUICreate("hello", 200, 400)
$WinNames[1] = GUICreate("hello", 100, 200)
$WinNames[2] = GUICreate("hello", 300, 400)
$WinNames[3] = GUICreate("hello", 300, 500)

For $a = 0 to 3
$winNum = WinGetTitle($WinNames[$a], "")
$handleWin[$a] = WinGetHandle($WinNames[$a], "")
WinMove($handleWin[$a], "", $positionx[$a], $positiony[$a])
Next

This example appears to work.

;
#include <array.au3>

Global $aHandleWin[4]
Global $a
Global $aPositionX[4]
Global $aPositionY[4]

$aPositionX[0] = "0"
$aPositionY[0] = "0"
$aPositionX[1] = "478"
$aPositionY[1] = "0"
$aPositionX[2] = "0"
$aPositionY[2] = "478"
$aPositionX[3] = "218"
$aPositionY[3] = "0"

$aHandleWin[0] = GUICreate("hello", 200, 400)
GUISetState(@SW_SHOW)
$aHandleWin[1] = GUICreate("hello", 100, 200)
GUISetState(@SW_SHOW)
$aHandleWin[2] = GUICreate("hello", 300, 400)
GUISetState(@SW_SHOW)
$aHandleWin[3] = GUICreate("hello", 300, 500)
GUISetState(@SW_SHOW)

For $a = 0 To 3
    WinMove($aHandleWin[$a], "", $aPositionX[$a], $aPositionY[$a], Default, Default, 5)
Next

While GUIGetMsg() <> -3
WEnd
;
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...