Zisly
Intermediate OT User
- Joined
- Jun 9, 2008
- Messages
- 7,338
- Reaction score
- 120
This is my fourth tutorial!
Ok, we went trough how to create a simple GUI in the last tutorial.
So now we play a bit with the GUI we created.
Remember comments are started by a ';'
Ok here is the code to the GUI we will use
Ok, that is the code we will use.
Now we will modify it a bit.
Ok, as you can see I have added 2 lines of code, the first one is nothing to explain,really just read the comment.
But I will explain line 2.
So, what we do here is; when you click on the button a message box will appear telling you what text there is in the input.
First we make the a message box, with the parameter '0' and the title 'Tutorial'
then we add the text the box should have, which is 'Text of input : ".
Now as you can see there is a '&' sign, if you might not know what it means
but it just means plus,and.
Now you will see something new
Whats this does, is; it reads/gets the text from a control, in this case '$Input1'
Not really much more to explain about it, it just returns the text/value of a control.
So now you know how to read controls.
Now when we are at getting text/values why not explain how to obtain text from another window?
For this we will use WinGetText("","")
So, now we will modify the code from before.
Ok, the code is very similar from the one before.
When you click on the button a message box will appear (just as the other example) but this time we don't use 'GuiCtrlRead' we use 'WinGetText', so I will explain it.
The 'WinGetText' function retrieves the text from a specific window, this case "Untitled -" which is the from a new file in notepad.
So "WinGetText("Untitled -","")" will get all text that the window has and then
put the text after "Text from the window : " in the message box.
If you want, you can specifie what text to get from the window( ex
Now it will get the "gg" text, check out the help file on how you can use this
Ok, I hope you have understood the tutorial
If you are unsure about something, just ask!
PS: Tutorial was written long time ago.
Add rep if you found this useful!
Ok, we went trough how to create a simple GUI in the last tutorial.
So now we play a bit with the GUI we created.
Remember comments are started by a ';'
Ok here is the code to the GUI we will use
Code:
; Include the needed libraries
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
; create GUI window with the size of 269*99
$Form1 = GUICreate("Test Gui", 269, 99, 193, 115)
; create input control
$Input1 = GUICtrlCreateInput("", 72, 16, 121, 21)
; create a button which says "Hit Me"
$Button1 = GUICtrlCreateButton("Hit Me", 96,56, 75, 25, 0)
; set the GUI to to show, so you can see it
GUISetState(@SW_SHOW)
While 1 ; loop until expression is false
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE ; if the user clicks on X (closes the window)
Exit ; the script will exit.
EndSwitch
WEnd; end of loop
Ok, that is the code we will use.
Now we will modify it a bit.
Code:
While 1 ; loop until expression is false
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE ; if the user clicks on X (closes the window)
Exit ; the script will exit.
Case $button1 ; the the user clicks on the button
MsgBox(0,"Tutorial","Text of input : " & GUICtrlRead($Input1)) ; promp a message box telling you what text the input controls has
EndSwitch
WEnd; end of loop
Ok, as you can see I have added 2 lines of code, the first one is nothing to explain,really just read the comment.
But I will explain line 2.
So, what we do here is; when you click on the button a message box will appear telling you what text there is in the input.
First we make the a message box, with the parameter '0' and the title 'Tutorial'
then we add the text the box should have, which is 'Text of input : ".
Now as you can see there is a '&' sign, if you might not know what it means
but it just means plus,and.
Now you will see something new
Code:
]GUICtrlRead($Input1)
Whats this does, is; it reads/gets the text from a control, in this case '$Input1'
Not really much more to explain about it, it just returns the text/value of a control.
So now you know how to read controls.
Now when we are at getting text/values why not explain how to obtain text from another window?
For this we will use WinGetText("","")
So, now we will modify the code from before.
Code:
While 1 ; loop until expression is false
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE ; if the user clicks on X (closes the window)
Exit ; the script will exit.
Case $button1 ; the the user clicks on the button
MsgBox(0,"TUTORIAL", "Text from the window : " & WinGetText("Untitled -","")) ; get text from the window with the title "Untitled"
EndSwitch
WEnd; end of loop
Ok, the code is very similar from the one before.
When you click on the button a message box will appear (just as the other example) but this time we don't use 'GuiCtrlRead' we use 'WinGetText', so I will explain it.
The 'WinGetText' function retrieves the text from a specific window, this case "Untitled -" which is the from a new file in notepad.
So "WinGetText("Untitled -","")" will get all text that the window has and then
put the text after "Text from the window : " in the message box.
If you want, you can specifie what text to get from the window( ex
Code:
"WinGetText("Untitled -","gg")
Ok, I hope you have understood the tutorial
If you are unsure about something, just ask!
PS: Tutorial was written long time ago.
Add rep if you found this useful!