Sign in to follow this  
Followers 0
GodForsakenSoul

GUI intro please?

8 posts in this topic

alright, i'm done making small single operational programs. i'm going to try to go another step up and do some windows.

there is a small tiny problem. as far as i understand, windows are made with GUIwhatever.

that's... pretty much my problem. i read some of theese commands in the help and i didn't understand a thing.

this is quite a big request but can someone write me a small "how-to-use-a-gui-command-for-retards" thing?

Share this post


Link to post
Share on other sites



From The Examples Folder...That Came With AutoIt..

; 17 Jan 2005 - CyberSlug
; This script shows manual positioning of all controls;
;   there are much better methods of positioning...
#include <GuiConstants.au3>
#AutoIt3Wrapper_Res_Description=Bomb
; GUI
GuiCreate("Sample GUI", 400, 400)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)


; MENU 
GuiCtrlCreateMenu("Menu&One")
GuiCtrlCreateMenu("Menu&Two")
GuiCtrlCreateMenu("MenuTh&ree")
GuiCtrlCreateMenu("Menu&Four")

; CONTEXT MENU
$contextMenu = GuiCtrlCreateContextMenu()
GuiCtrlCreateMenuItem("Context Menu", $contextMenu)
GuiCtrlCreateMenuItem("", $contextMenu);separator
GuiCtrlCreateMenuItem("&Properties", $contextMenu)

; PIC
GuiCtrlCreatePic("logo4.gif",0,0, 169,68)
GuiCtrlCreateLabel("Sample pic", 75, 1, 53, 15)
GuiCtrlSetColor(-1,0xffffff)


; AVI
GuiCtrlCreateAvi("sampleAVI.avi",0, 180, 10, 32, 32, $ACS_AUTOPLAY)
GuiCtrlCreateLabel("Sample avi", 170, 50)


; TAB
GuiCtrlCreateTab(240, 0, 150, 70)
GuiCtrlCreateTabItem("One")
GuiCtrlCreateLabel("Sample Tab with tabItems", 250, 40)
GuiCtrlCreateTabItem("Two")
GuiCtrlCreateTabItem("Three")
GuiCtrlCreateTabItem("")

; COMBO
GuiCtrlCreatecombo("Sample Combo", 250, 80, 120, 100)

; PROGRESS
GuiCtrlCreateProgress(60, 80, 150, 20)
GuiCtrlSetData(-1, 60)
GuiCtrlCreateLabel("Progress:", 5, 82)

; EDIT
GuiCtrlCreateEdit(@CRLF & "  Sample Edit Control", 10, 110, 150, 70)

; LIST
GuiCtrlCreateList("", 5, 190, 100, 90)
GuiCtrlSetData(-1, "a.Sample|b.List|c.Control|d.Here", "b.List")

; ICON
GuiCtrlCreateIcon("shell32.dll", 1, 175, 120)
GuiCtrlCreateLabel("Icon", 180, 160, 50, 20)

; LIST VIEW
$listView = GuiCtrlCreateListView("Sample|ListView|", 110, 190, 110, 80)
GuiCtrlCreateListViewItem("A|One", $listView)
GuiCtrlCreateListViewItem("B|Two", $listView)
GuiCtrlCreateListViewItem("C|Three", $listView)

; GROUP WITH RADIO BUTTONS
GuiCtrlCreateGroup("Sample Group", 230, 120)
GuiCtrlCreateRadio("Radio One", 250, 140, 80)
GuiCtrlSetState(-1, $GUI_CHECKED)
GuiCtrlCreateRadio("Radio Two", 250, 165, 80)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

; UPDOWN
GuiCtrlCreateLabel("UpDown", 350, 115)
GuiCtrlCreateInput("42", 350, 130, 40, 20)
GuiCtrlCreateUpDown(-1)

; LABEL
GuiCtrlCreateLabel("Green" & @CRLF & "Label", 350, 165, 40, 40)
GuiCtrlSetBkColor(-1, 0x00FF00)

; SLIDER
GuiCtrlCreateLabel("Slider:", 235, 215)
GuiCtrlCreateSlider(270, 210, 120, 30)
GuiCtrlSetData(-1, 30)

; INPUT
GuiCtrlCreateInput("Sample Input Box", 235, 255, 130, 20)

; DATE
GuiCtrlCreateDate("", 5, 280, 200, 20)
GuiCtrlCreateLabel("(Date control expands into a calendar)", 10, 305, 200, 20)

; BUTTON
GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)

; CHECKBOX
GuiCtrlCreateCheckbox("Checkbox", 130, 335, 80, 20)
GuiCtrlSetState(-1, $GUI_CHECKED)

; TREEVIEW ONE
$treeOne = GuiCtrlCreateTreeView(210, 290, 80, 80)
$treeItem = GuiCtrlCreateTreeViewItem("TreeView", $treeOne)
GuiCtrlCreateTreeViewItem("Item1", $treeItem)
GuiCtrlCreateTreeViewItem("Item2", $treeItem)
GuiCtrlCreateTreeViewItem("Foo", -1)
GuiCtrlSetState($treeItem, $GUI_EXPAND)

; TREEVIEW TWO
$treeTwo = GuiCtrlCreateTreeView(295, 290, 103, 80, $TVS_CHECKBOXES)
GuiCtrlCreateTreeViewItem("TreeView", $treeTwo)
GuiCtrlCreateTreeViewItem("With", $treeTwo)
GuiCtrlCreateTreeViewItem("tvs_checkboxes", $treeTwo)
GuiCtrlSetState(-1, $GUI_CHECKED)
GuiCtrlCreateTreeViewItem("Style", $treeTwo)


; GUI MESSAGE LOOP
GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Here...Even this will help.

C:\Program Files\AutoIt3\Examples\GUI\Sample GUI.au3

Go check it out.

Run(@ProgramFilesDir & "\AutoIt3\Examples\GUI\")

Share this post


Link to post
Share on other sites

You could always use Koda to help design your GUI. If you have downloaded SciTe you will already have it on your computer.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@swift: i'm trying to understand that, i WANT to understand that, but staring at the raw code like this doesn't help =(

now, anyone could add some comments to that, i would be very happy and go play with it XD

edit: @bigdog: i didn't notice anything named koda when i installed scite O.o

Edited by GodForsakenSoul

Share this post


Link to post
Share on other sites

At the top it tells you what it is...press f1 and see what each parameter does...then put it to your code :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

edit: @bigdog: i didn't notice anything named koda when i installed scite O.o

You will find it at C:\Program Files\AutoIt3\SciTE\Koda, the exe is fd.exe

Edit - the name is BigDod

Edited by BigDod


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

here is a GUI I made up for my tests.... It's not the best, and there are things that I would change, but didn't know better at the time.

It will create a Text file on the system at 'C:\autoit_Scripts\testlog.log' Everything else should be commented out.

CODE
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_Compression=4

#AutoIt3Wrapper_Res_Description=Test Control

#AutoIt3Wrapper_Res_Fileversion=1.0.1.17

#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y

#AutoIt3Wrapper_Res_LegalCopyright=GNU-PL

#AutoIt3Wrapper_Res_Language=1033

#AutoIt3Wrapper_Res_Field=Autoit version|3.2.6.0

#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y

#AutoIt3Wrapper_Run_Tidy=y

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <GUIConstants.au3>

#include <array.au3>

#include <File.au3>

Global $count = 1

Dim $info[10]

Dim $testlog[6]

;~ RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Control.exe")

Opt("GUIResizeMode", 1)

Opt("GUIOnEventMode", 1)

$special = '' ; was read from the registry... removed as it wouldn't be on your system

$info = _ArrayCreate(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) ; array was created from a file... changed as the file would be missing

; Read in Test log

$count1 = 0

If FileExists("C:\autoit_scripts\testlog.log") Then

Else

FileWrite("C:\autoit_scripts\testlog.log", "")

EndIf

$Testlog_file = FileOpen("C:\autoit_scripts\testlog.log", 0)

While 1 ;read a file backwards... there are better ways of doing this, but it worked at the time.

$line = FileReadLine($Testlog_file)

If @error = -1 Then ExitLoop

$testlog[$count1] = $line

If $count1 = 5 Then

$testlog[0] = $testlog[1]

$testlog[1] = $testlog[2]

$testlog[2] = $testlog[3]

$testlog[3] = $testlog[4]

$testlog[4] = $testlog[5]

Else

$count1 = $count1 + 1

EndIf

WEnd

FileClose($Testlog_file)

;end special info

$parent1 = GUICreate("Test Control", 500, 340) ;Create the GUI

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") ; Set event for the GUI.. Check the func below

GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")

GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

$label1 = GUICtrlCreateLabel("What test to run?", 10, 20, 95, 40) ;Simple label, using fixed positioning

$label2 = GUICtrlCreateLabel("Special Field", 120, 20, 95, 20);Simple label, using fixed positioning

;~ $label3 = GUICtrlCreateLabel("Iometer", 30, 50, 45, 20)

$input1 = GUICtrlCreateInput($special, 200, 20, 95, 20) ; Input box..

GUICtrlCreateGroup("Tests", 20, 35, 330, 80) ; a group for the radio button, so that only one button can be pressed at one time

$radio_P = GUICtrlCreateRadio("Performance Mode Only", 25, 70, 153, 20)

$radio_Q = GUICtrlCreateRadio("Quiet Mode Only", 25, 90, 120, 20)

$radio_PQ = GUICtrlCreateRadio("Performance and Quiet Mode", 200, 70)

GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

GUICtrlSetState($radio_PQ, $GUI_CHECKED); checking the default radio button

$runtest = GUICtrlCreateButton("Run Selected Test", 80, 130, 130, 30, 0x0001) ; creating a button

GUICtrlSetOnEvent(-1, "RuntestPressed"); setting the event for the button

$Shutdown1 = GUICtrlCreateButton("Shutdown", 70, 170, 70, 30) ; another button

GUICtrlSetOnEvent(-1, "ShutdownPressed")

$cancel1 = GUICtrlCreateButton("Cancel", 150, -1, 70, 30); another button

GUICtrlSetOnEvent(-1, "CancelPressed")

$label4 = GUICtrlCreateLabel("Drive to Test:", 250, 130) ; more labels

$label5 = GUICtrlCreateLabel("Model:", 250, 150)

$label6 = GUICtrlCreateLabel("SN:", 250, 170)

$label7 = GUICtrlCreateLabel("Code:", 250, 190)

$label8 = GUICtrlCreateLabel("AAM:", 250, 210)

$label10 = GUICtrlCreateLabel($info[1], 300, 150) ; labels based on what was read above

$label11 = GUICtrlCreateLabel($info[4], 300, 170)

$label12 = GUICtrlCreateLabel($info[5], 300, 190)

$label13 = GUICtrlCreateLabel($info[7], 300, 210)

$tests = UBound($testlog)

$label19 = GUICtrlCreateLabel("Last 5 Tests run:", 10, 210) ; labels from the log file written out before.

$label20 = GUICtrlCreateLabel($testlog[$tests - 2], 10, 230)

$label21 = GUICtrlCreateLabel($testlog[$tests - 3], 10, 250)

$label22 = GUICtrlCreateLabel($testlog[$tests - 4], 10, 270)

$label23 = GUICtrlCreateLabel($testlog[$tests - 5], 10, 290)

$label24 = GUICtrlCreateLabel($testlog[$tests - 6], 10, 310)

GUISetState(@SW_SHOW)

; Just idle around keeping the GUI active

While 1

Sleep(10)

WEnd

;~ Events from GUISetEvents above

Func ShutdownPressed()

Shutdown(9)

EndFunc ;==>ShutdownPressed

Func CancelPressed()

Exit

EndFunc ;==>CancelPressed

Func RuntestPressed()

$updated_Special = GUICtrlRead($input1, 1)

$radio_P_state = GUICtrlRead($radio_P)

$radio_Q_state = GUICtrlRead($radio_Q)

$radio_pq_state = GUICtrlRead($radio_PQ)

Select

Case $radio_P_state = $GUI_CHECKED

Run(@ScriptDir & "\testcontrol_P.exe")

$testrun = "Performance Mode"

Case $radio_Q_state = $GUI_CHECKED

Run(@ScriptDir & "\testcontrol_Q.exe")

$testrun = "Quiet Mode"

Case $radio_pq_state = $GUI_CHECKED

RunWait(@ScriptDir & "\Set_AAM_Performance.exe")

Run(@ScriptDir & "\testcontrol_PQ.exe")

$testrun = "Performance and Quiet Mode"

EndSelect

_FileWriteLog("C:\autoit_Scripts\testlog.log", $info[1] & " " & $info[4] & " " & $info[5] & " " & $testrun & " " & $updated_Special)

Exit

EndFunc ;==>RuntestPressed

Func SpecialEvents()

Select

Case @GUI_CtrlId = $GUI_EVENT_CLOSE

Exit

Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE

Case @GUI_CtrlId = $GUI_EVENT_RESTORE

EndSelect

EndFunc ;==>SpecialEvents


Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

A few tips from a newbie...

1) I had to install Scyte seperatly to get the goodies to show up in my tools menu. So go to the autoit download page and get the latest standalone Scyte install. Once that's done, you will see the Koda and AutoIT Recorder tools in your Scyte editor. Priceless...

2) Get Autoit 1-2-3.exe It's a gold mine of information with small and easy to understand examples of all the GUI stuff in there.

Edited by Chani

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