Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: WinPlace WinPlaceGet WinPlaceSet WinPosition Center @NoResize No Resize 1000x1000 Width Height Window Position Coordinates X Y Upper Lower
;Center Window Without Resizing partialwinname = "~Notepad" Run( 'notepad.exe','') ;Get width and height of window pos = WinPosition(partialwinname) ux = ItemExtract(1,pos,",") uy = ItemExtract(2,pos,",") lx = ItemExtract(3,pos,",") ly = ItemExtract(4,pos,",") width = lx -ux height = ly - uy ;calculate center based on 1000x1000 virtual screen centerUX = Int( (1000 - width) / 2.0 ) centerUY = Int( (1000 - height) / 2.0) centerLY = centerUX+width centerLY = centerUY+height newpos = centerUX : " " : centerUY : " " : centerLY : " " : centerLY WinPlaceSet( @NORMAL, partialwinname, newpos ) ;Or ;newpos = centerUX : "," : centerUY : "," : @NoResize : "," : @NoResize ;WinPlace( %newpos%, partialwinname ) Exit
Sample using an array
strWinName = "Untitled - Notepad" arrCoord = Arrayize (WinPlaceGet (@NORMAL, strWinName), " ") intLenX = arrCoord[2] - arrCoord[0] intLenY = arrCoord[3] - arrCoord[1] intPosX = (1000 - intLenX) / 2 intPosY = (1000 - intLenY) / 2 blnResult = WinPlace (intPosX, intPosY, intPosx + intLenX, intPosY + intLenY, strWinName)
Article ID: W18457
Filename: Center Window Without Resizing.txt
File Created: 2012:04:23:09:23:50
Last Updated: 2012:04:23:09:23:50