Jump to content

Recommended Posts

Posted

Hi everybody :)
I tried a new way to move/resize AutoIt controls interactively while a script is running, without subclassing the controls. Also the main GUI is resizable. For example the script 'Move controls through Mask #2.au3" found in the attached zip file produces the following output (Windows 11) displaying about 20 AutoIt controls :

W11-MovecontrolsthroughMask2imageA.jpg.d12b13a810f8efc919f547f8657f8b80.jpg

When you hover over a control (eventually after clicking on it) then the control color changes (to red in the pic below) and the cursor shape too : it may be a cursor shape that moves the control (like in the pic below) or the usual cursors to resize the control (i.e. when you hover over a border or a corner of the control) :

W11-MovecontrolsthroughMask2imageB.jpg.701729df6a9b21f7e1e40271d6f55daa.jpg

This is done by covering temporarily the control with a "Mask" (bad name) which corresponds to a red popup transparent GUI : what you move/resize in fact is the popup GUI, which moves/resizes at same time the underlying control.

When you're done with moving/resizing your controls, then you go back to your script, by right clicking the GUI to display its GUI context menu, clicking on its item to change this...

W11-MovecontrolsthroughMask2imageC.png.e2cdc7eccdab3160866683fa61724f4e.png

...to that

W11-MovecontrolsthroughMask2imageD.png.27c56acb4fd86fee3937f33e3caf3c94.png

This will remove the GUI background grid (or background pic), your controls will now react as you want them to, and your GUI will be displayed with the background color you choosed for it (if any) for example in this script :

GUISetBkColor(0x808080) ; grey

All final sizes and positions are stored in a text file (named "Move controls through Mask #2.coord") that is updated when you close your GUI. After that, when you run the script again, the GUI and its controls got their positions/sizes restored accordingly.

Now some points that should be improved (thanks for sharing your ideas about how to improve)

1) Concerning the file "Move controls through Mask #2.coord"

; USER'S PARAMETERS (change here)
Local $bCreateGrid = 1 ; GUI Background from GDI+ grid (1) OR from external image (0)
...

If you change $bCreateGrid from 1 to 0 (or from 0 to 1) then you should delete the .coord file to recreate a fresh new one. It shouldn't happen too often because we don't spend our time changing this parameter. Also $bCreateGrid = 1 seems the best option as it adapts itself to any @DesktopWidth & @DesktopHeight. Thanks @UEZ for the help with the function _CreateGrid()

2) Hovering over an Updown control :
* When you use the native "AutoIt Window Info tool" (or Yashied's control viewer) you can hover over an updown control (the 2 up/down arrows on the right) OR hover over the buddy window (the Edit control on the left) but you can't hover over both at same time (i.e. updown control + buddy Edit control). You can try this behavior on the script while the controls are locked. So far so good.

* When you use GUIGetCursorInfo() which is the most important part in the script, then it's different. As soon as you hover over the buddy window (the Edit control), then both controls are "merged" (i.e. updown control + buddy Edit control) as shown in the following pic :

UpDownissue.png.f5cdd7e0caac8351b30225645cf1b089.png

The worse part is : as soon as both parts are selected at same time, then the Edit control width shrinks. If you repeat the operation a couple of times, the Edit control is apparently no more there as seen in the above pic. Here is what we read on msdn (UpDown control styles) :

UDS_ALIGNLEFT / UDS_ALIGNRIGHT : [...] The width of the buddy window is decreased to accommodate the width of the up-down control.

So I guess this is what happens in the script (because GUIGetCursorInfo() merges both controls ?) but I don't know for now how to solve this... except by deleting the file "Move controls through Mask #2.coord", which is not a good solution.

3) Hovering over a Tab control :
Do you have an idea on how to move any control found in any TabItem when the Tab control is moved/resized ?

4) The optional child window $hChild :
I Made it movable but not resizable. Added it just to test controls inside it (to make sure the controls ate confined inside it while the cursor tries to drag them outside the borders of the child window) . For now, when you resize the main GUI, there is no code to move the child window accordingly, but it could be scripted in a further release.

Finally, if you want to test the script without the save/restore coords part, then just comment out these 3 lines in the script :

; #include "_SaveCoord.au3"
; _SaveCoord(1)
; _SaveCoord(2)

There are 4 files in the attached zip file :
* Move controls through Mask #2.au3 (the main script)
* _SaveCoord.au3
* Grid 1920x1080.png (to test the GUI background based on a pic and not on a GDI+ grid)
* Torus.png (pic control tested on a child window)

Have a great day :bye:

Move controls through Mask.zip

 

"I think you are searching a bug where there is no bug... don't listen to bad advice."

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
×
×
  • Create New...