Zisly
Intermediate OT User
- Joined
- Jun 9, 2008
- Messages
- 7,338
- Reaction score
- 120
As people wanted me to write more tutorials I will do so
But before we start you should get Koda, if you don't already got it that is.
You can get it from HERE
So this time we will go thought: gui creation,#include and some other things
So now we will start with the #include.
#include simply means that you will include a prewriten library of functions.
Now lets create your first gui.
open FD.exe which is located in AutoIt3\SciTE\Koda
When the program first pops up you will see grey window in the middle of the screen, that is the gui.
You can drag it and so on to get the desired height and width.
Above that window you can see some gui controls, ex: label,input, check boxes.
So take 1 input box and place it where you want on the gui, and take 1 button and also place it on the gui
Now click: Tools and then run form, now the code will be generated and appear in Scite.
I will put out some comments in the code to help you.
Remember! comments start with ';'
My code:
Ok, as you can see there are now 4 included library's which are needed to this to work.
Now I will explain:
As I could not think of a good way to explain variables I toke the explanation from the help file
"A variable is just a place to store data in memory so that it can be accessed quickly.
Think of it as a mailbox in memory that you can put information in or take information out of.
For example you might create a variable to store the number a user's response to a question,
or the result to a math equation."
Now I will explain in my way again.
A variable must always start with a '$' and it cannot contain spaces, but you can use _ , ex; $my_name_is
So what we did here was to assign $Forml as the gui window.
Which was
Ok, I will "explain" the litle code above.
[GUICreate("TITLE", WIDTH,HEIGHT,LEFT,TOP)
Where it now says title is where you put the windows title name, followed by width and height.
Left and top is where the window will appear when created.
Ok, that was the gui window now we will go thought the rest of the gui controls.
GUICtrlCreateInput("TEXT", 72,16,121,21)
This is almost the same as the gui explanation, so I will just explain the difference.
Where it now says "TEXT", that's what text should be shown, as in this case we don't want any text from the beginning
we will just delete it, then it will look like this:
Now lets move on to the button.
GUICtrlCreateButton("Button1", 96,56,75,25,0)
It's almost like the input control, except the last part ( the 0 ) but as I wont explain Styles we will jump over this.
That sets the gui to shown, else we won't be able to see the gui.
Ok, that was the gui window and control, now let's move on to the rest.
First line is "While 1" which I wont explain.
Now line 2,$nMsg is assigned to GUIGetMsg(), which will, hum.. let's say get event (ex: button was pressed).
The Switch will switch $nMsg] and wait for a GUI related expressions.
Now I will explain "Case" which is very simple.
If the event followed by case is true then statement underneath case will be executed , in this case we have
"$GUI_EVENT_CLOSE" which means that the user pressed X (window was closed.)
And underneath we got "Exit" which will exit the script.
Now the last lines.
"EndSwitch" which will end the swich, and "Wend" which will end the loop."
Ok, so I hope you understood what this tutorial, if you didn't understand something just ask
I will make a new tutorial where we will use this GUI later.
If you think it's use full give reputation please!
But before we start you should get Koda, if you don't already got it that is.
You can get it from HERE
So this time we will go thought: gui creation,#include and some other things
So now we will start with the #include.
#include simply means that you will include a prewriten library of functions.
Now lets create your first gui.
open FD.exe which is located in AutoIt3\SciTE\Koda
When the program first pops up you will see grey window in the middle of the screen, that is the gui.
You can drag it and so on to get the desired height and width.
Above that window you can see some gui controls, ex: label,input, check boxes.
So take 1 input box and place it where you want on the gui, and take 1 button and also place it on the gui
Now click: Tools and then run form, now the code will be generated and appear in Scite.
I will put out some comments in the code to help you.
Remember! comments start with ';'
My code:
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 269, 99,193,115)
$Input1 =GUICtrlCreateInput("Input1",72,16,121,21)
$Button1 = GUICtrlCreateButton("Button1",96,56,75,25,0)
GUISetState(@SW_SHOW) ;; set the gui state to show so you can see it
#EndRegion ### END Koda GUI section ###
While1 ;;; start of loop[/COLOR]
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE ;;; if the window is close, ex: the uses clicked X the script will do the action underneath
Exit ;;; Will exit the script
EndSwitch
WEnd ;;; end of loop
Ok, as you can see there are now 4 included library's which are needed to this to work.
Now I will explain:
Code:
$Form1 = GUICreate("Form1", 269, 99,193,115)
"A variable is just a place to store data in memory so that it can be accessed quickly.
Think of it as a mailbox in memory that you can put information in or take information out of.
For example you might create a variable to store the number a user's response to a question,
or the result to a math equation."
Now I will explain in my way again.
A variable must always start with a '$' and it cannot contain spaces, but you can use _ , ex; $my_name_is
So what we did here was to assign $Forml as the gui window.
Which was
Code:
]GUICreate("Form1", 269, 99,193, 115)
[GUICreate("TITLE", WIDTH,HEIGHT,LEFT,TOP)
Where it now says title is where you put the windows title name, followed by width and height.
Left and top is where the window will appear when created.
Ok, that was the gui window now we will go thought the rest of the gui controls.
GUICtrlCreateInput("TEXT", 72,16,121,21)
This is almost the same as the gui explanation, so I will just explain the difference.
Where it now says "TEXT", that's what text should be shown, as in this case we don't want any text from the beginning
we will just delete it, then it will look like this:
Code:
GUICtrlCreateInput("",72,16,121,21)
Now lets move on to the button.
GUICtrlCreateButton("Button1", 96,56,75,25,0)
It's almost like the input control, except the last part ( the 0 ) but as I wont explain Styles we will jump over this.
Code:
GUISetState(@SW_SHOW) ;;; set the gui state to show so you can see it
Ok, that was the gui window and control, now let's move on to the rest.
Code:
While 1 ;;; start of loop
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE ;;; if the window is close, ex: the uses clicked X the script will do the action underneath[/COLOR]
Exit ;;;; Will exit the script
EndSwitch
WEnd ;;; end of loop
Now line 2,$nMsg is assigned to GUIGetMsg(), which will, hum.. let's say get event (ex: button was pressed).
The Switch will switch $nMsg] and wait for a GUI related expressions.
Now I will explain "Case" which is very simple.
If the event followed by case is true then statement underneath case will be executed , in this case we have
"$GUI_EVENT_CLOSE" which means that the user pressed X (window was closed.)
And underneath we got "Exit" which will exit the script.
Now the last lines.
"EndSwitch" which will end the swich, and "Wend" which will end the loop."
Ok, so I hope you understood what this tutorial, if you didn't understand something just ask
I will make a new tutorial where we will use this GUI later.
If you think it's use full give reputation please!
Last edited: