nitekram

Window Manipulation

5 posts in this topic

I am trying to do something, but it appears that I am having issues with trying to get the right functions called, in the right order.

What I want to do is move a window to a certain position and then move it back, but as stated, the order appears to be an issue, as if the window is minimized, the wingetclientsize is not able to pull the info, not is the wingetpos. It appears to be able to get the size and position of the window in question is activated, but I have to activate it first, but that defeats the purpose, as once activated, the functions called to get the position and size, are not correct, as the screen is now active. I have tried to use wingetstate, to get the state first, but I am not sure how to move the window back to the original location with the right state.

If window is minimized, I want it to go back to minimized state, as well as keeping the window size the same, so if the user activates the window, the user does not have to resize it.

If the window is active and is on another screen, it appears I do not have the same issue.

Here is my attempt, but I have tried other combinations. Has anyone got an idea on how to resolve this issue?

Func MoveVNC($Move)
    CreateLogEntry("Called MoveVNC($Move) $Move = " & $Move)
    Local $aStartBar = StartBar()
    Local $bMove = False
    Local $VNC = 'NAMEOFWINDOW'
    Static $aWin_VNC_Pos = ''
    Static $iWin_VNC_State = ''
    Static $aWin_VNC_Size = ''

    #cs
        ;$aWin_VNC_Pos = WinGetPos($VNC, '')
        MsgBox('','VNC POS','')
        _ArrayDisplay(WinGetPos($VNC, ''))
        MsgBox('','VNC STATE',WinGetState($VNC, ''))
        WinActivate($VNC)
        Sleep(20)
        WinWaitActive($VNC, '', 10)
        Sleep(20)
        Local $aSize = WinGetClientSize($VNC, '')
        MsgBox('','VNC SIZE','')
        _ArrayDisplay($aSize)
    #ce


    If $Move = 'Get' Then
        Opt("WinTitleMatchMode", -1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
        If WinExists($VNC) Then
            WinActivate($VNC)
            Sleep(20)
            WinWaitActive($VNC, '', 10)
            Sleep(20)

            $aWin_VNC_Pos = WinGetPos($VNC, '')
            Sleep(20)
            ;_ArrayDisplay($aWin_VNC_Pos, '$aWin_VNC_Pos')

            $iWin_VNC_State = WinGetState($VNC, '')
            Sleep(20)

            $aWin_VNC_Size = WinGetClientSize($VNC, '')
            ;_ArrayDisplay($aWin_VNC_Size)
            ;MsgBox('','$VNC',$VNC)


            ;MsgBox('', '$iWin_VNC_State', $iWin_VNC_State)
            ;WinSetState($VNC, '', @SW_MAXIMIZE)
            ;Sleep(20)

            WinMove($VNC, '', 0, 0, 1600, 950) ;  - (3 * $aStartBar[3])
            Sleep(20)

            ;MouseClick('Left', 1764, 174)
            $bMove = True
        Else
            MsgBox($MB_TOPMOST, 'ERROR GET', 'Window ' & $VNC & ' Does not exists - VNC is not running!')
        EndIf

        If Not $bMove Then
            CreateLogEntry("MoveVNC(GET) FAILED")
            Return False
        Else
            CreateLogEntry("MoveVNC(GET) PASSED")
            Return True
        EndIf
    ElseIf $Move = 'Put' Then
        CreateLogEntry("Called MoveVNC($Move) $Move = " & $Move)
        If WinExists($VNC) Then

            ;WinSetState($VNC, '', @SW_RESTORE)
            ;If @error Then MsgBox('', '', @error)
            ;Sleep(20)
            WinMove($VNC, '', $aWin_VNC_Pos[0], $aWin_VNC_Pos[1], $aWin_VNC_Pos[2], $aWin_VNC_Pos[3])
            If @error Then MsgBox('', '', @error)
            Sleep(20)
            ;WinSetState($VNC, '', $iWin_VNC_State)
            ;If @error Then MsgBox('', 'Not setting state', @error & ' ' & $VNC)
            ;Sleep(20)
            $bMove = True
        Else
            MsgBox($MB_TOPMOST, 'ERROR PUT', 'Window ' & $VNC & ' Does not exists - VNC is not running!')
        EndIf

        If Not $bMove Then
            CreateLogEntry("MoveVNC(PUT) FAILED")
            Return False
        Else
            CreateLogEntry("MoveVNC(PUT) PASSED")
            Return True
        EndIf
    EndIf
    CreateLogEntry("    Returned from MoveVNC()")
EndFunc   ;==>MoveVNC

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites



There may be a clue in the remarks for WinGetClientSize.  It says minimized windows return 0s for the client measurements.  However non-minimized hidden windows return the correct dimensions.  You could try hiding the minimized windows then setting their state to normal after moving them off screen.  Never did it myself but there must be a way to "restore" a minimized window invisibly and move it out of the screen area without flicker.

I have never had a multi-monitor setup so I can't help with that aspect(no pun intended.)

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

So I am still testing, but there needs to be a change in the help file, unless the window is activated first, the hiding of it makes no difference - meaning you will still get ZEROs for a hidden window, which means you have to activate it first (bring window up) then Hide it?

 

I have found these, but not sure if it pertains to this, and if so, is this the type of code that Autoit is using?
http://stackoverflow.com/questions/2766709/minimized-window-position-in-wpf

http://stackoverflow.com/questions/5531548/how-to-restore-a-minimized-window-in-code-behind

 

I have created this code below, and it appears to work, though I do not like the flashing screens - using double monitors...are the links above something that will help find info for even minimized windows?

 

Func MoveVNC($Move)

    CreateLogEntry("Called MoveVNC($Move) $Move = " & $Move)
    Local $aStartBar = StartBar()
    Local $bMove = False
    Local $VNC = 'name' ;|0x052D1378
    Static $aWin_VNC_Pos = ''
    Static $iWin_VNC_State = ''
    Static $aWin_VNC_Size = ''

    If $Move = 'Get' Then
        Opt("WinTitleMatchMode", -1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
        If WinExists($VNC) Then
            $iWin_VNC_State = WinGetState($VNC, '')
            ;MsgBox('','Window State',$iWin_VNC_State)
            WinActivate($VNC, '')
            WinWaitActive($VNC, '', 10)
            If @error Then
                MsgBox(0, 'ERROR 0', 'Window timed out or does not exist')
                Return
            EndIf

            WinSetState($VNC, '', @SW_HIDE)
            $aWin_VNC_Pos = WinGetPos($VNC, '')
            Sleep(20)
            WinSetState($VNC, '', @SW_SHOW)
            WinMove($VNC, '', 0, 0, 1600, 950) ; MAX size for the VNC Client - for larger, it would have to be changed on the VNC Server
            $bMove = True
        Else
            MsgBox($MB_TOPMOST, 'ERROR GET', 'Window ' & $VNC & ' Does not exists - VNC is not running!')
        EndIf

        If Not $bMove Then
            CreateLogEntry("MoveVNC(GET) FAILED")
            Return False
        Else
            CreateLogEntry("MoveVNC(GET) PASSED")
            Return True
        EndIf
    ElseIf $Move = 'Put' Then
        CreateLogEntry("Called MoveVNC($Move) $Move = " & $Move)
        If WinExists($VNC) Then

            If $iWin_VNC_State = 23 Then ; if minimized, set size preexisting size and then minimize
                WinMove($VNC, '', $aWin_VNC_Pos[0], $aWin_VNC_Pos[1], $aWin_VNC_Pos[2], $aWin_VNC_Pos[3])
                WinSetState($VNC, '', @SW_MINIMIZE)
            Else
                ; just put the window in its previous location
                WinMove($VNC, '', $aWin_VNC_Pos[0], $aWin_VNC_Pos[1], $aWin_VNC_Pos[2], $aWin_VNC_Pos[3])
            EndIf
            $bMove = True
        Else
            MsgBox($MB_TOPMOST, 'ERROR PUT', 'Window ' & $VNC & ' Does not exists - VNC is not running!')
        EndIf
        Opt("WinTitleMatchMode")
        If Not $bMove Then
            CreateLogEntry("MoveVNC(PUT) FAILED")
            Return False
        Else
            CreateLogEntry("MoveVNC(PUT) PASSED")
            Return True
        EndIf
    EndIf
    CreateLogEntry("    Returned from MoveVNC()")
EndFunc   ;==>MoveVNC

If anyone can improve this, I would be grateful!

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

So I am still testing, but there needs to be a change in the help file, unless the window is activated first, the hiding of it makes no difference - meaning you will still get ZEROs for a hidden window, which means you have to activate it first (bring window up) then Hide it?

I was thinking more along the lines of WinSetState using @SW_RESTORE, then hiding it or moving it off screen.  The idea being it may be less of a flicker than activation.  But since I haven't had a need to do this I would have to experiment just as you are.  No real time saving there I'm afraid.

 

Edited by MilesAhead

Share this post


Link to post
Share on other sites

That really does the same thing as activating the screen (as far as I was able to see), so really no change that I noticed.

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

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

  • Similar Content

    • PeteF
      By PeteF
      Full script w/details in comments below, just in case you need to run it to see the problem.  Basically WinGetPos is incorrectly returning the W & H sizes, while at the same time correctly returning the positions. To compound the problem, I ran the same script on 2 different PCs and it gets2 different results as follows:
      Win7 Pro PC.. GUICreate used to set W:300, H:100.       WinGetPos returns W:307, H:127  (PC screen res: 1366x768)
      WinXP PC..... GUICreate used to set W:300, H:100.       WinGetPos returns W:308, H:134   (PC screen res: 1152x864)
      The bigger problem occurs when you consider I want to save the Window sizes and recreate the window at a later date. but due to this problem, each time I ran the program the Window would get larger and larger.    --pete
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; SCRIPT DESC.: Simple script here. Create & display one Window of a specific ; size & position. This Window is always ON TOP of other windows. ; User may resize the window to cover up unwanted content (as in use with a Web-Browser). ; Upon user closing the Window, DEBUG msgbox in script returns window size & position ; to be used in further development of this script. ; ; PROBLEM: If user does not resize the Window and simply clicks "X" to close the window, ; the DEBUG msgbox is reporting the wrong SIZES. It's actually the AutoIt WinGetPos ; function that is returning correct positions, but incorrectly returning the sizes. ; It should be returning 300 (W), 100 (H), but it's incorrectly returning 307 (W), 127 (H) ; _MAIN() Func _MAIN() ;Local $sFilePath = "..\GUI\logo4___.gif" Local $l_SizeWidth_1, $l_SizeHeight_1, $l_PosLeft_1, $l_PosTop_1 ; Defaults for Window 1 Size and Position $l_SizeWidth_1 = 300 $l_SizeHeight_1 = 100 $l_PosLeft_1 = 50 $l_PosTop_1 = 50 ; Create re-sizable GUI window/form that is blank with a black background and stays on TOP over over windows. Local $hGUI = GUICreate("COVER UNWANTED CONTENT", $l_SizeWidth_1, $l_SizeHeight_1, $l_PosLeft_1, $l_PosTop_1, _ $WS_OVERLAPPEDWINDOW, $WS_EX_TOPMOST) ; Black Background GUISetBkColor(0x000000) ;GUICtrlCreatePic("..\GUI\msoobe.jpg", 0, 0, 400, 100) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Create a picture control with a transparent image. ;GUICtrlCreatePic($sFilePath, 0, 0, 169, 68) ; Display the Window GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() ; CASE IF USER X's out, CLOSE THE WINDOWS & QUIT Case $GUI_EVENT_CLOSE ExitLoop ; CASE Open a second window EndSwitch WEnd ; Obtain the window(s) Size & Positions _WindowPositionAndSize($hGUI) ; Save the window(s) size & positions ; TBD ; Delete the previous GUIs and all controls. GUIDelete($hGUI) EndFunc ;==>_MAIN Func _WindowPositionAndSize($WindowID) ; Retrieve the position as well as height and width of the window. Local $aPos = WinGetPos($WindowID) ; DEBUG msgbox ; Display the array values returned by WinGetPos. MsgBox(0, "", "X-Pos: " & $aPos[0] & @CRLF & _ "Y-Pos: " & $aPos[1] & @CRLF & _ "Width: " & $aPos[2] & @CRLF & _ "Height: " & $aPos[3] ) ; DEBUG notes ; Width 300 off by a factor of.. 0.9740261 ; Height 100 off by a factor of.. 0.7874017 ; I was hoping to add in some correction factors, but thse factors ; change dramatically at different Width & Height settings. Need a better fix! EndFunc ;==>_WindowPositioAndSize  
       
    • Reizvoller
      By Reizvoller
      Func workSpaceSetup () ConsoleWrite ("workSpaceSetup" &@CRLF) $workSpace = WinGetHandle ("some site - Google Chrome") ConsoleWrite ($workSpace&@CRLF) $pos1 = WinGetPos ($workSpace) WinMove ($workSpace , "", $pos1[0] , $pos1[1] , 1366, 768, 0) EndFunc So the script is first, the error I get is second in the quote.
      This is one function of many for an app I am building but it is the first one that runs so I know there aren't other things at play here.
      The idea is to keep the window in the same space it is when the script runs but just resize it as this app is used across multiple computers with different screen resolutions.
      Could someone please elaborate upon what "Subscript used on non-accessible variable" means? 
      Oh and the variable is declared as "Global $pos1 = 0" at the top outside of any functions with the other global variables.
      Any advice would be greatly appreciated!
      -Reiz
    • momar33
      By momar33
      I am seeing a buttons position change when the following happens.
      1. GUI created at 800 x 600
      2. GUI info is stored using WinGetPos
      3. GUI changed to full-screen using WinMove
      4. Button info is stored using ControlGetPos
      5. Button is deleted
      6. Button is re-created using the stored data from item 4.
      7. GUI is restored to the info gathered in item 2.
      The button starts with this info:
      Button Left:   408 Button Top:    84 Button Width:  80 Button Height: 24   and after the events above the button has this info: Button Left:   409 Button Top:    83 Button Width:  80 Button Height: 24   Here is some code that can reproduce the issue: (press space, f, space, f, then look in the console) #Region Includes #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> #EndRegion Includes Const $HT_KEY_FULLSCREEN = "f" Const $HT_KEY_SPACE = "{SPACE}" Global $btnAddRebuy[21] Global $btnRemovePlayer[21] Global $fFullscreen = False Global $aGuiInfo Global $aGuiInfo2 Global $guiWidth = 800 Global $guiHeight = 600 #Region Dimensions for Settings Screen ; Player Global $lblPlayerTop = 60 Global $playerLabelSpace = 24 ; Add Rebuy Button Global $btnRebuyLeft = 320 Global $btnRebuyWidth = 80 Global $btnRebuyHeight = 24 ; Remove Player Global $btnRemoveLeft = 408 Global $btnRemoveWidth = 80 Global $btnRemoveHeight = 24 #EndRegion Dimensions for Settings Screen $hMain = GUICreate("Timer", $guiWidth, $guiHeight, -1, -1, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_OVERLAPPEDWINDOW,$WS_TILEDWINDOW,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS)) For $i = 1 To 5 Step 1 $btnAddRebuy[$i] = GUICtrlCreateButton("Button", $btnRebuyLeft, $lblPlayerTop + ($playerLabelSpace * $i), $btnRebuyWidth, $btnRebuyHeight) GUICtrlSetResizing($btnAddRebuy[$i], $GUI_DOCKAUTO) GuiCtrlSetState($btnAddRebuy[$i], $GUI_DISABLE) $btnRemovePlayer[$i] = GUICtrlCreateButton("Button", $btnRemoveLeft, $lblPlayerTop + ($playerLabelSpace * $i), $btnRemoveWidth, $btnRemoveHeight) ;GUICtrlSetResizing($btnRemovePlayer[$i], $GUI_DOCKAUTO) Next GUISetState(@SW_SHOW) HotKeySet($HT_KEY_FULLSCREEN, "Fullscreen") HotKeySet($HT_KEY_SPACE, "Redraw") While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop EndIf WEnd Func Fullscreen() If WinActive($hMain) Then If $fFullscreen Then ;GUISetStyle(BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_OVERLAPPEDWINDOW,$WS_TILEDWINDOW,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS), Default, $hMain) $aGuiInfo2 = WinGetPos($hMain) ConsoleWrite("******* Fullscreen *******" & @LF) ConsoleWrite("Win Left: " & $aGuiInfo2[0] & @LF) ConsoleWrite("Win Top: " & $aGuiInfo2[1] & @LF) ConsoleWrite("Win Width: " & $aGuiInfo2[2] & @LF) ConsoleWrite("Win Height: " & $aGuiInfo2[3] & @LF & @LF) ;WinMove($hMain, Default, $aGuiInfo[0], $aGuiInfo[1], $aGuiInfo[2], $aGuiInfo[3]) WinMove($hMain, Default, 238, 179, 816, 638) $fFullscreen = False $aCtrlInfo = ControlGetPos($hMain, "", $btnRemovePlayer[1]) ConsoleWrite("******* Button Info after Restored *******" & @LF) ConsoleWrite("Button Left: " & $aCtrlInfo[0] & @LF) ConsoleWrite("Button Top: " & $aCtrlInfo[1] & @LF) ConsoleWrite("Button Width: " & $aCtrlInfo[2] & @LF) ConsoleWrite("Button Height: " & $aCtrlInfo[3] & @LF & @LF) Else ;GUISetStyle($WS_POPUP, Default, $hMain) $aGuiInfo = WinGetPos($hMain) ConsoleWrite("******* Start Size *******" & @LF) ConsoleWrite("Win Left: " & $aGuiInfo[0] & @LF) ConsoleWrite("Win Top: " & $aGuiInfo[1] & @LF) ConsoleWrite("Win Width: " & $aGuiInfo[2] & @LF) ConsoleWrite("Win Height: " & $aGuiInfo[3] & @LF & @LF) WinMove($hMain, Default, 0, 0, @DesktopWidth, @DesktopHeight) $fFullscreen = True $aCtrlInfo = ControlGetPos($hMain, "", $btnRemovePlayer[1]) ConsoleWrite("******* Button Info after Fullscreened *******" & @LF) ConsoleWrite("Button Left: " & $aCtrlInfo[0] & @LF) ConsoleWrite("Button Top: " & $aCtrlInfo[1] & @LF) ConsoleWrite("Button Width: " & $aCtrlInfo[2] & @LF) ConsoleWrite("Button Height: " & $aCtrlInfo[3] & @LF & @LF) EndIf Else HotKeySet($HT_KEY_FULLSCREEN) Send($HT_KEY_FULLSCREEN) HotKeySet($HT_KEY_FULLSCREEN, "Fullscreen") EndIf EndFunc Func Redraw() Local $aCtrlInfo $aCtrlInfo = ControlGetPos($hMain, "", $btnRemovePlayer[1]) ConsoleWrite("******* Button Info before Redraw *******" & @LF) ConsoleWrite("Button Left: " & $aCtrlInfo[0] & @LF) ConsoleWrite("Button Top: " & $aCtrlInfo[1] & @LF) ConsoleWrite("Button Width: " & $aCtrlInfo[2] & @LF) ConsoleWrite("Button Height: " & $aCtrlInfo[3] & @LF & @LF) GuiCtrlDelete($btnRemovePlayer[1]) $btnRemovePlayer[1] = GUICtrlCreateButton("Button", $aCtrlInfo[0], $aCtrlInfo[1], $aCtrlInfo[2], $aCtrlInfo[3]) ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $aCtrlInfo = ControlGetPos($hMain, "", $btnRemovePlayer[1]) ConsoleWrite("******* Button Info after Redraw *******" & @LF) ConsoleWrite("Button Left: " & $aCtrlInfo[0] & @LF) ConsoleWrite("Button Top: " & $aCtrlInfo[1] & @LF) ConsoleWrite("Button Width: " & $aCtrlInfo[2] & @LF) ConsoleWrite("Button Height: " & $aCtrlInfo[3] & @LF & @LF) EndFunc Is there a way to fix this, or is the issue built in to how windows get resized?  
    • MarkRobbins
      By MarkRobbins
      I'm using WindowBlinds, VOX 2 Style. When I WinMove() the width and height show quite a bit short when measured on screen (14px!), WinGetPos() returns the proper numbers, but when attempting placement of windows this is quite a pain. Is there a solution for this other than constant compensation?

       
    • timmy2
      By timmy2
      I found >this thread started by chuber while searching for a way to get the useable desktop area (size of primary monitor desktop minus taskbar).
      My first bit of bafflement was why the code written by chuber does not match the quote of his code in the reply that follows his post.
      Since I didn't want to tackle figuring out Sysinternal's debug viewer I went with the version of his code that omits all the lines starting with "If $DEBUG_001...". (more is omitted than that but I think it's missing only comments)  I'll paste this version below. It compiles fine.
      What chuber posted is a function. So my first goal is to write a simple MsgBox that will show me the results of his function.
      When I insert a simple MsgBox to see the results of his function...
      MsgBox(0,"test",$aDesktop_Pos[0]) ...I get an error saying "Subscript used with non-Array variable.", yet he used $aDesktop_Pos as an array variable throughout his function and it's a global variable. What part of this do I not understand and how can I extract the info I'm seeking?
      Here's the code from the original thread.
      ; #cs Script: Desktop client size and Taskbar position (code snippet) Author: Bruce Huber (cbruce) AutoIt: v3.2.12.1 Date: 2008.08.13 - Original release Purpose: Determine whether the Taskbar is visible or hidden and where it is docked on the Desktop. Also calculate the available Desktop client region, accounting for any Taskbar space. #ce ; Desktop and Taskbar position information - GetDesktopAndTaskbarPos(). Global Enum $DTP_X, $DTP_Y, $DTP_W, $DTP_H Global $aDesktop_Pos, $aTaskbar_Pos Global Enum $TBDL_UNKNOWN, $TBDL_LEFT, $TBDL_RIGHT, $TBDL_TOP, $TBDL_BOTTOM Global $Taskbar_Dock_Location = $TBDL_UNKNOWN Global $Taskbar_Visible Func GetDesktopAndTaskbarPos() ; Get the Desktop size - which includes the Taskbar space, if the Taskbar is visible. $aDesktop_Pos = WinGetPos( "Program Manager") ; Get the Taskbar size. $aTaskbar_Pos = WinGetPos( "[Class:Shell_TrayWnd]") ; Determine if Taskbar is taking up space on the Desktop. If ( $aTaskbar_Pos[$DTP_X] > -3) And ( $aTaskbar_Pos[$DTP_Y] > -3) And ( $aTaskbar_Pos[$DTP_X] < ( $aDesktop_Pos[$DTP_W] - 5)) And ( $aTaskbar_Pos[$DTP_Y] < ( $aDesktop_Pos[$DTP_H] - 5)) Then ; Taskbar is Visible. $Taskbar_Visible = True ; Calculate the parameters of the AVAILABLE Desktop client region. If ( $aTaskbar_Pos[$DTP_X] < 1) and ( $aTaskbar_Pos[$DTP_Y] > 0) and ( $aTaskbar_Pos[$DTP_W] > $aTaskbar_Pos[$DTP_H]) Then ; Taskbar is on the BOTTOM. $Taskbar_Dock_Location = $TBDL_BOTTOM ; We need to adjust the Desktop Height. $aDesktop_Pos[$DTP_H] = $aTaskbar_Pos[$DTP_Y] - 1 ElseIf ( $aTaskbar_Pos[$DTP_X] < 1) and ( $aTaskbar_Pos[$DTP_Y] < 1) and ( $aTaskbar_Pos[$DTP_W] < $aTaskbar_Pos[$DTP_H]) Then ; Taskbar is on the LEFT. $Taskbar_Dock_Location = $TBDL_LEFT ; We need to adjust the Desktop X and Width. $aDesktop_Pos[$DTP_X] = $aTaskbar_Pos[$DTP_X] + $aTaskbar_Pos[$DTP_W] + 1 $aDesktop_Pos[$DTP_W] = $aTaskbar_Pos[$DTP_X] - 1 ElseIf ( $aTaskbar_Pos[$DTP_X] > 0) and ( $aTaskbar_Pos[$DTP_Y] < 1) and ( $aTaskbar_Pos[$DTP_W] < $aTaskbar_Pos[$DTP_H]) Then ; Taskbar is on the RIGHT. $Taskbar_Dock_Location = $TBDL_RIGHT ; We need to adjust the Desktop Width. $aDesktop_Pos[$DTP_W] = $aTaskbar_Pos[$DTP_X] - 1 ElseIf ( $aTaskbar_Pos[$DTP_X] < 1) and ( $aTaskbar_Pos[$DTP_Y] < 1) and ( $aTaskbar_Pos[$DTP_W] > $aTaskbar_Pos[$DTP_H]) Then ; Taskbar is on the TOP. $Taskbar_Dock_Location = $TBDL_TOP ; We need to adjust the Desktop Y and Height. $aDesktop_Pos[$DTP_Y] = $aTaskbar_Pos[$DTP_Y] + $aTaskbar_Pos[$DTP_H] + 1 $aDesktop_Pos[$DTP_H] = $aTaskbar_Pos[$DTP_Y] - 1 Else ; Where the heck has the Taskbar gone? $Taskbar_Dock_Location = $TBDL_UNKNOWN EndIf Else ; Taskbar is Hidden. $Taskbar_Visible = False EndIf #cs $aDesktop_Pos now contains parameters that only define the AVAILABLE Desktop client region. This will be the entire Desktop if the Taskbar is hidden. Otherwise, the region will be the Desktop area minus the Taskbar area. $Taskbar_Dock_Location now specifies WHERE, on the Desktop, that the Taskbar is docked. #ce EndFunc ; GetDesktopAndTaskbarPos() ; I realize there's> a post in another thread that uses a different approach to finding the data I seek but all I need are "x,y,h,w" and I can't figure out how to extact that info from the script provided in that code (copy pasted below).  This is humbling.
      Global Const $MONITOR_DEFAULTTONULL = 0x00000000 Global Const $MONITOR_DEFAULTTOPRIMARY = 0x00000001 Global Const $MONITOR_DEFAULTTONEAREST = 0x00000002 Global Const $CCHDEVICENAME = 32 Global Const $MONITORINFOF_PRIMARY = 0x00000001 $hMonitor = GetMonitorFromPoint(0, 0) ;$hMonitor = GetMonitorFromPoint(-2, 0) ;$hMonitor = GetMonitorFromPoint(@DesktopWidth, 0) If $hMonitor <> 0 Then Dim $arMonitorInfos[4] If GetMonitorInfos($hMonitor, $arMonitorInfos) Then _ Msgbox(0, "Monitor-Infos", "Rect-Monitor" & @Tab & ": " & $arMonitorInfos[0] & @LF & _ "Rect-Workarea" & @Tab & ": " & $arMonitorInfos[1] & @LF & _ "PrimaryMonitor?" & @Tab & ": " & $arMonitorInfos[2] & @LF & _ "Devicename" & @Tab & ": " & $arMonitorInfos[3]) EndIf Exit Func GetMonitorFromPoint($x, $y) $hMonitor = DllCall("user32.dll", "hwnd", "MonitorFromPoint", _ "int", $x, _ "int", $y, _ "int", $MONITOR_DEFAULTTONULL) Return $hMonitor[0] EndFunc Func GetMonitorInfos($hMonitor, ByRef $arMonitorInfos) Local $stMONITORINFOEX = DllStructCreate("dword;int[4];int[4];dword;char[" & $CCHDEVICENAME & "]") DllStructSetData($stMONITORINFOEX, 1, DllStructGetSize($stMONITORINFOEX)) $nResult = DllCall("user32.dll", "int", "GetMonitorInfo", _ "hwnd", $hMonitor, _ "ptr", DllStructGetPtr($stMONITORINFOEX)) If $nResult[0] = 1 Then $arMonitorInfos[0] = DllStructGetData($stMONITORINFOEX, 2, 1) & ";" & _ DllStructGetData($stMONITORINFOEX, 2, 2) & ";" & _ DllStructGetData($stMONITORINFOEX, 2, 3) & ";" & _ DllStructGetData($stMONITORINFOEX, 2, 4) $arMonitorInfos[1] = DllStructGetData($stMONITORINFOEX, 3, 1) & ";" & _ DllStructGetData($stMONITORINFOEX, 3, 2) & ";" & _ DllStructGetData($stMONITORINFOEX, 3, 3) & ";" & _ DllStructGetData($stMONITORINFOEX, 3, 4) $arMonitorInfos[2] = DllStructGetData($stMONITORINFOEX, 4) $arMonitorInfos[3] = DllStructGetData($stMONITORINFOEX, 5) EndIf Return $nResult[0] EndFunc