vladedoty Posted October 8, 2009 Posted October 8, 2009 (edited) 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 October 8, 2009 by vladedoty
Yashied Posted October 8, 2009 Posted October 8, 2009 (edited) 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 October 8, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
vladedoty Posted October 8, 2009 Author Posted October 8, 2009 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?
danielkza Posted October 8, 2009 Posted October 8, 2009 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.
Yashied Posted October 8, 2009 Posted October 8, 2009 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.Oh, I forgot to write. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Yashied Posted October 8, 2009 Posted October 8, 2009 ...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? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
vladedoty Posted October 8, 2009 Author Posted October 8, 2009 $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)
Yashied Posted October 8, 2009 Posted October 8, 2009 Oh, sorry, could not see $positionx and $positiony. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
vladedoty Posted October 8, 2009 Author Posted October 8, 2009 Oh, sorry, could not see $positionx and $positiony.so is there no difference then?
Yashied Posted October 8, 2009 Posted October 8, 2009 (edited) $handleWin[$a] = WinGetHandle($WinNames[$a], "")This line is totally useless.GUICreate() returns a handle of the window. Edited October 8, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
vladedoty Posted October 9, 2009 Author Posted October 9, 2009 $handleWin[$a] = WinGetHandle($WinNames[$a], "") This line is totally useless. GUICreate() returns a handle of the window. well i tried it again and the first window moves to the correct position, however when the second window opens it doesn't move at all. along with the 3rd and fourth.
picea892 Posted October 9, 2009 Posted October 9, 2009 Make sure the windows are open before you try to move them. You might need a winwait or sleep
Malkey Posted October 9, 2009 Posted October 9, 2009 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 ;
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now