abdulrahmanok

(Just one more Question) How to detect Size of Gui and Move Buttons

18 posts in this topic

#1 ·  Posted (edited)

Hello Brothers ,  This Is an Example Script which Created by Koda :

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 712, 488, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 368, 248, 105, 41)
$Button2 = GUICtrlCreateButton("Button2", 224, 248, 105, 49)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd


I Always think how i can change the GUI size without any form designer but i didn't figure how to do this for example I want to make GUI bigger 

so i must edit this :

$Form1 = GUICreate("Form1", 712, 488, 192, 124)

to be like this :

$Form1 = GUICreate("Form1", 800, 600, 192, 124)

but it's completly diffrent of what i wanted so Is i need to try decrease  800, 600 until did it ! very difficault .

another problem that don't know how to move button to another location  :

 $Button2 = GUICtrlCreateButton("Button2", 224, 248, 105, 49)

I know this is the current location is  : (224, 248, 105, 49)  but i dont know how to write my own location without using GUI Createor

Hope Any one can help me with this and I will be waiting for any request to make it more clearer  :D

 

 

Edited by abdulrahmanok

Share this post


Link to post
Share on other sites



abdulrahmanok,

Open the Help file and look at the pages for GUICreate and GUICtrlCreateButton. There you will see what the parameters are:

GUICreate ( "title" , width , height , left , top)            ; Left and top are relative to the top left of the screen

GUICtrlCreateButton ( "text", left, top , width , height)     ; Left and top are relative to the top left of the GUI holding the control

So you adjust the relevant parameters to get the GUI and button to the required size and location.

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
50 minutes ago, Melba23 said:

abdulrahmanok,

Open the Help file and look at the pages for GUICreate and GUICtrlCreateButton. There you will see what the parameters are:

GUICreate ( "title" , width , height , left , top)            ; Left and top are relative to the top left of the screen

GUICtrlCreateButton ( "text", left, top , width , height)     ; Left and top are relative to the top left of the GUI holding the control

So you adjust the relevant parameters to get the GUI and button to the required size and location.

M23

Thanks for fast reply,I'm already know parameters what i want to know is that i need "Window Tool" To detect Coords for size and place to move?

Share this post


Link to post
Share on other sites

abdulrahmanok,

That is not at all clear - but let me try to help.

If you use the Window Info tool to determine location and size then you need to adjust the <Option - Coord mode> settings and use the "Mouse" tab to read the coordinates you choose  (you can use the "< >" arrows to see it). To locate the position of a GUI, you need to select "Screen" so that the coordinates that are shown are relative to the screen - when dealing with a control, you need to select "Window" so that the coordinates are relative the window which contains it.

Any use? If not then please explain exactly what it is you are trying to do with your GUI and button.

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
27 minutes ago, Melba23 said:

abdulrahmanok,

That is not at all clear - but let me try to help.

If you use the Window Info tool to determine location and size then you need to adjust the <Option - Coord mode> settings and use the "Mouse" tab to read the coordinates you choose  (you can use the "< >" arrows to see it). To locate the position of a GUI, you need to select "Screen" so that the coordinates that are shown are relative to the screen - when dealing with a control, you need to select "Window" so that the coordinates are relative the window which contains it.

Any use? If not then please explain exactly what it is you are trying to do with your GUI and button.

M23

Screenshot_1.png

Share this post


Link to post
Share on other sites

abdulrahmanok,

I guessed correctly - and I explained that in my previous post. You need to set the Window Info tool "Coord mode" to "Window" so that the coordinates are relative to the GUI and not the screen.

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

@Melba23

Thank You Very much I Figured it now and tomorrow I  will build my own GUI without any GUI Creator B) 

#Solved

Share this post


Link to post
Share on other sites

abdulrahmanok,

As always, delighted I could help.

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

Just One more Issue :

Please Follow Pic :

1-

Screenshot_1.png

2- 

Screenshot_2.png

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

Can you post the script?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

The height of your GUI is 200, and you moved your button to 207...it's outside of the bounds...change it to:

$idNotepad = GuiCtrlCreateButton ("Run Notepad",5,170,85,25)

Edited by jdelaney
1 person likes this

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#12 ·  Posted

12 hours ago, jdelaney said:

The height of your GUI is 200, and you moved your button to 207...it's outside of the bounds...change it to:

$idNotepad = GuiCtrlCreateButton ("Run Notepad",5,170,85,25)

Ty that's Actually  Did What I want but I just want to know how you got Correct corods ?  because I coudn't find it with Window Info Tool.

@Subz

This is the Code:

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create a button control.
    Local $idNotepad = GUICtrlCreateButton("Run Notepad", 5,170, 85, 25)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    Local $iPID = 0

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

            Case $idNotepad
                ; Run Notepad with the window maximized.
                $iPID = Run("notepad.exe", "", @SW_SHOWMAXIMIZED)

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)

    ; Close the Notepad process using the PID returned by Run.
    If $iPID Then ProcessClose($iPID)
EndFunc   ;==>Example

but like I said I want to know how to get these Coords to create another Buttons in Specific Places.

Share this post


Link to post
Share on other sites

#13 ·  Posted

abdulrahmanok,

it is not the Window Info tool that will give you the answer - it is simple maths.

If your GUI is created with a size of 300x200, then your controls must fit with in that area - so any button with a "height" parameter of 25 must have a "top" parameter of at most 175 so be completely visible (200 - 25 = 175). Similarly, if the button has a "width" parameter of 85, it must have a "left" parameter of at most 215 (300 - 85 = 215).

Clearer now?

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

#14 ·  Posted

@Melba23 

Ty very much For your efforts but sorry because I'm Totally confused now 

After set window info tool to Window mood and get X,Y Should i calc it like this :

$x=175 , Y= 208

GUI Size - X,Y: 300-175=125    300-200 =100 

Then the desired value will be my current position ?

    Local $idNotepad = GUICtrlCreateButton("Run Notepad", 125, 100, 85, 25)

 

Share this post


Link to post
Share on other sites

#15 ·  Posted

abdulrahmanok,

No, you have misunderstood.

Using simple estimation allows you to determine the position of controls without using the Window Info tool. In that case you need to determine the position by eye:

+---------------------------------+ GUI code (300, 200)
|                                 |
|                                 |
|   +----+                        | Control code approximately (20, 80, 50, 50)
|   |    |                        |
|   +----+                        |
|                                 |
|                                 |
+---------------------------------+

The simple calculations that I showed just above make sure the control is visible - the control cannot be placed at more than (250, 150, 50, 50):

(300 - 50 = 250 & 200 - 50 = 150)

If you do use the Windows Info tool, then you can use the position values directly:

+---------------------------------+ GUI code (300, 200)
|   |                             |
|   v                             |
|   +----+                        | Window Info tool gives marked position at top left as 20, 80
|   |    |                        |
|   +----+                        |
|                                 |
|                                 |
+---------------------------------+

So you create the control at (20, 80, 50, 50)

Any clearer?

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

#16 ·  Posted (edited)

Get coords via the script with ControlGetPos...output with _array_display.

Edit: a little tired, misread your question.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#17 ·  Posted

On 2/2/2017 at 11:23 PM, Melba23 said:

Any clearer?

 

Thanks for your Patience...

+---------------------------------+ GUI code (300, 200)
|   |                             |
|   v                             |
|   +----+                        | Window Info tool gives marked position at top left as 20, 80
|   |    |                        |
|   +----+                        |
|                                 |
|                                 |
+---------------------------------+

I tried hard to understand this but i cant figure how u got (20,80) ....:(

Share this post


Link to post
Share on other sites

#18 ·  Posted

abdulrahmanok,

That is the position within the GUI where you wish to create the control and which you found with the cursor of the Window Info tool.  Once your GUI is created, move the cursor of the tool to the position where you want to locate the control and read the position given by the tool - then create the control at that position.

The 2 methods I suggested in my previous post are essentially identical - in the first you guess a the position (which takes a bit of experience but is quicker), while in the second you use the Window Info tool to get a precise reading of the position. In both cases, once you have the required coordinates you create the control at that position.

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