Sign in to follow this  
Followers 0
momar33

Wandering Button (When Gui set to Fullscreen and Button is Redrawn)

6 posts in this topic

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?
 

Share this post


Link to post
Share on other sites



momar33,

Why not use the correct GUICtrlResizing mode (you can set it globally using Opt) and then just hide/show the button rather then deleting/recreating it? That would save a lot of code and keep it in the correct place. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I am using $GUI_DOCKAUTO in my actual program, but removed it for simplification.

With $GUI_DOCKAUTO set, this still happens just slightly differently.

The code posted is the result of weeding out unnecessary code.

Hiding/Showing will not work for me. I change the button color which makes the button "Windows Classic Style", I redraw the button to get the 3d button back.

What I am doing is using a colored button to show a more prominent tab focus.

(Down button changes the focus (and background color) of the next button down, then redraws the button that previously had focus).

Share this post


Link to post
Share on other sites

momar33,

Because of a bug deep in the core code (and therefore very unlikely ever to be fixed) colouring buttons is not a good idea in AutoIt - they trap the ENTER key for a start and lose styles for another. :(

Whenever I need to highlight a button I place a slightly larger label underneath it (and disable it to prevent Autoit getting confused and actioning neither) and then change the colour of that label when required. That way the button remains "standard" and perfectly useable. Here is a short example:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$cLabel_1 = GUICtrlCreateLabel("", 8, 8, 84, 34)
GUICtrlSetState($cLabel_1, $GUI_DISABLE)
$cButton_1 = GUICtrlCreateButton("One", 10, 10, 80, 30)

$cLabel_2 = GUICtrlCreateLabel("", 8, 48, 84, 34)
GUICtrlSetState($cLabel_2, $GUI_DISABLE)
GUICtrlSetBkColor($cLabel_2, 0xFF0000)
$cButton_2 = GUICtrlCreateButton("Two", 10, 50, 80, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton_1
            GUICtrlSetBkColor($cLabel_1, 0xFFFFFF)
            GUICtrlSetBkColor($cLabel_2, 0xFF0000)
        Case $cButton_2
            GUICtrlSetBkColor($cLabel_2, 0xFFFFFF)
            GUICtrlSetBkColor($cLabel_1, 0xFF0000)
    EndSwitch
WEnd
Any use? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

M23,

I had actually thought about that method at one time, but for whatever reason decided against it.  (or it may have been a backup idea)

I will likely use that method if I can't figure out the issue in the OP.

Do you have any idea what is causing the issue in the OP?

It doesn't appear to be an issue with my code, but I was kinda hoping it was and I just missed it.

Thanks,

M33

Share this post


Link to post
Share on other sites

momar33,

 

Do you have any idea what is causing the issue in the OP?

Not really. GUI resizing and storing control coordinates for redrawing is always fraught with difficulty - which is why I tend to go for the hide/show method and let AutoIt look after control position and size for me. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

  • Similar Content

    • keelaji
      By keelaji
      Hello,
      first of all i searched in the forum but i didn't found any solution to my problem.
      I am using windows 10.
      I made a script that is supposed to change the title to the active window, resize it to the smallest size possible (should be around 800 x 600) and move to (0, 0).
      I can change the title but i fail to do the other 2 tasks.
      i use wingettitle [active] copied from the F1 help tool (and this works), i i put the title in a variable and than i use
      winsettitle ($variable, "one") (this works too)
      winmove ("one", 0, 0, 800, 600) (doesn't do anything)
      i also tried
      local $x = winget ( "one")
      msgbox (0, "", $x) (i get a completely white box so i suppose winget can't have any data about my window ??)
      any suggestion ?
    • thoms
      By thoms
      Hello Forum,
      As said in the title, I'm searching a way to disable all tabstops in a GUI. My GUI includes 15 buttons and 3 edit controls.
      My questions:
      - is there a way to disable all tabstops at a time
      - is there a way to list all controls of a GUI and then disable tabstops one by one
      - or should I use the following line after each button creation:
      _WinAPI_SetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE), BitNOT($WS_TABSTOP))) Thanks in advance for your valuable help!
      Thoms
      Edit: or maybe disable TAB key? I don't remember how to do!
    • AppSoftwareVld
      By AppSoftwareVld
      Hello,
       
      I need this for a project and I don't find a method for the next problem.
      I want when I click a button to create a variable ("$variable1") so if I press one more time to create one more ("$variable2") and create more and more how many times you press the button.
       
      Do you have an idea ? 
      Thank you for your attention !
    • rte7
      By rte7
      Hello. We work with the BMC Remedy site to manage incidents and would like to automate the processes of clicking through this button code:
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a> I use firefox with mozrepl and autoit with include FF.au3
      I need your help
      I read the topic https://www.autoitscript.com/forum/topic/95595-ffau3-v0601b-10/ but I could not run the code from the listed commands
      ...
      It is necessary to press the button and from the list of the menu of cahorsations to select the item = "zone of trust abonent"
      Screen # 1 http://joxi.ru/52aJK7bh4a7ypA or below.
      1) Press button
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a>
      2) After pressing the button, I need to choose in this menu of 4 items to select an item called "zone of trust abonent", Screen # 2 - http://joxi.ru/p27gwQKHo71VQ2
      html code table items
      <table class="MenuTable" cellpadding="0" cellspacing="0" style="width: 179px;"> <tbody class="MenuTableBody"> <tr class="MenuTableRow"> <td class="MenuEntryName" nowrap="">zone of trust abonent</td> <td class="MenuEntryNoSub" arvalue="zone of trust abonent"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust operator"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust third operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust third operator"></td></tr> <tr class="MenuTableRow"><td class="MenuEntryNameHover" nowrap="">No settings</td> <td class="MenuEntryNoSubHover" arvalue="No settings"></td> </tr> </tbody> </table>
       
       
      More in detail, I choose from the menu item "zone of trust abonent" Screen # 3 - http://joxi.ru/GrqVq4ZIQEPW4m

       
      3) The choice is made, Screen # 4 http://joxi.ru/v297w6aC3PovLr
      <textarea class="text sr " wrap="off" id="arid_WIN_0_1000002488" cols="20" maxlen="60" style="top:21; left:0; width:179; height:21;" armenu="CFG:PRC:CategoryHPD-Res-T1-Q" mstyle="2" arautoc="1" arautocmb="1" arautocak="0" arautoctt="400" rows="1"> </textarea>
       
      It's all. I would be very grateful to you =) !!!!!!!!!!
      Here are more detailed codes in the attachment. 
      button1.txt
      menu - table.txt
      all.txt
    • Nareshm
      By Nareshm
      I create message box but i dont know how to add button action when i click it.

      Help for : Add script for Button : Left, Right, Right Finger
      example when i press Left finger button do Case $idNotepad
                      $iPID = WinActivate ( " :PS :: Version - 2.8.0.0  - [eFS Bill]")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:btnReset]", "{esc}")
                              ControlClick ( " :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]")
                              ControlSend(" :DS  - eF:: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "^v")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "{enter}")
      How to add like above ?
                    
                                                                sorry for my bad english