Sign in to follow this  
Followers 0
joeloyzaga

trying to build simple gui

8 posts in this topic

I'm a newb.

Im coping with QTP but am trying to get away from using the data table and parameters and want to use autoit to prompt (within a gui) for input parameters and then output to an excel spreadsheet which I read for every run. Can you tell me if there are any examples of autoit creating a gui prompting a text box entry and writing to excel spreadsheet? Tried google with no luck

I'm going to make it a pretty complicated gui but thats my issue - I'd like a starting point of creating a gui prompting for some text and outputting to a default spreadsheet (you decide) on cell col1, row1. From there on I can expand it while learning

Can anybody help?

Jow

Share this post


Link to post
Share on other sites



You can use InputBox for the promoting part ;] or you can make it much user friendly by creating a few GuiCtrlCreateInput controls and buttons and let to user to decide which cell of a row will get modified. If you've installed AutoIt already then there are a few graphical and syntactical examples available in the directory "%ProgramFiles%\AutoIt\Examples\GUI\Simple" or advanced, as you like.

Also, it's a good start to walk through the AutoIt 1-2-3 and the FAQ topics and tutorials.

Share this post


Link to post
Share on other sites

You can use InputBox for the promoting part ;] or you can make it much user friendly by creating a few GuiCtrlCreateInput controls and buttons and let to user to decide which cell of a row will get modified. If you've installed AutoIt already then there are a few graphical and syntactical examples available in the directory "%ProgramFiles%\AutoIt\Examples\GUI\Simple" or advanced, as you like.

Also, it's a good start to walk through the AutoIt 1-2-3 and the FAQ topics and tutorials.

InputBox from where? is that an example somewhere or a function?

Share this post


Link to post
Share on other sites

A function, the help file also contain example for this and almost every function. If you use SciTE editor then it's F1 to get there, or "Start -> All Programs -> AutoIt v3 -> AutoIt Help File".

Share this post


Link to post
Share on other sites

the help file is best friend in most situations...

#include <Editconstants.au3>
#Include <GUIConstants.au3>
#Include <WindowsConstants.au3>

opt ('Guioneventmode',1)

$GUI = guicreate ('EXAMPLE',100,20)
$i = guictrlcreateinput (' ',0,0,50,20,$GUI)
Guisetonevent ($GUI_EVENT_CLOSE, '_Exit')
guisetstate (@SW_Show)

While 1
sleep (100)
Wend

Func _Exit ()
Exit
EndFunc
is what your looking for i expect.. or am i wrong?

Share this post


Link to post
Share on other sites

I'm a newb.

I'm coping with QTP but am trying to get away from using the data table and parameters and want to use autoit to prompt (within a gui) for input parameters and then output to an excel spreadsheet which I read for every run. Can you tell me if there are any examples of autoit creating a gui prompting a text box entry and writing to excel spreadsheet? Tried google with no luck

I'm going to make it a pretty complicated gui but thats my issue - I'd like a starting point of creating a gui prompting for some text and outputting to a default spreadsheet (you decide) on cell col1, row1. From there on I can expand it while learning

Can anybody help?

Jow

1) instead of googling use AutoIt's forum search engine

2) for creating complex GUIs use Koda: http://www.autoitscript.com/forum/index.php?showtopic=32299

3) look at Excel standard include

Share this post


Link to post
Share on other sites

1) instead of googling use AutoIt's forum search engine

2) for creating complex GUIs use Koda: http://www.autoitscript.com/forum/index.php?showtopic=32299

3) look at Excel standard include

Ok,

This is my starting point - I've created the gui to get the user,Application,enviroments using excel as my input. Working!

Now on pressing the Ok button I create another gui called Run Defaults which I want to display over the top of last gui and I want the last gui to disappear make non visible - is it possible? Whats the best way to do this?

#include <ComboConstants.au3>
#include <Excel.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>


Local $widthCell, $msg, $iOldOpt

Dim $sPathAUT = 'C:\Data\AUT.xls'
Dim $sPathUSERS = 'C:\Data\USERS.xls'
Dim $sPathENVS = 'C:\Data\ENVS.xls'
Dim $oExcel1 = _ExcelBookOpen($sPathAUT, 0)
Dim $oExcel2 = _ExcelBookOpen($sPathUSERS, 0)
Dim $oExcel3 = _ExcelBookOpen($sPathENVS, 0)
Dim $aArrayAUT = _ExcelReadSheetToArray($oExcel1)
Dim $aArrayUSER = _ExcelReadSheetToArray($oExcel2)
Dim $aArrayENVS = _ExcelReadSheetToArray($oExcel3)
_ExcelBookClose($oExcel1, 0)
_ExcelBookClose($oExcel2, 0)
_ExcelBookClose($oExcel3, 0)
Dim $sStr = ''
For $i = 1 To $aArrayAUT[0][0]
    For $j = 1 To $aArrayAUT[0][1]
        If $aArrayAUT[$i][$j] <> "" Then $sStr &= $aArrayAUT[$i][$j] & '|'
    Next
Next
$sStr = StringTrimRight($sStr, 1)

Dim $sStr2 = ''
For $i = 1 To $aArrayUSER[0][0]
    For $j = 1 To $aArrayUSER[0][1]
        If $aArrayUSER[$i][$j] <> "" Then $sStr2 &= $aArrayUSER[$i][$j] & '|'
    Next
Next
$sStr2 = StringTrimRight($sStr2, 1)

Dim $sStr3 = ''
For $i = 1 To $aArrayENVS[0][0]
    For $j = 1 To $aArrayENVS[0][1]
        If $aArrayENVS[$i][$j] <> "" Then $sStr3 &= $aArrayENVS[$i][$j] & '|'
    Next
Next
$sStr3 = StringTrimRight($sStr3, 1)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Rundata Selection Criteria", 633, 447, 289, 213)
$Group1 = GUICtrlCreateGroup("User Profile Selection", 8, 0, 585, 105)
GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
GUICtrlCreateGroup("1", -99, -99, 1, 1)
GUISetBkColor(0xA6CAF0)
;$Label1 = GUICtrlCreateLabel("   Please Select ", 16, 18, 216, 18)
;GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
;GUICtrlSetColor(-1, 0x000080)
$Label1 = GUICtrlCreateLabel("Application to test", 16, 36, 216, 18)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$AUT = GUICtrlCreateCombo("AUT", 32, 56, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlSetData($AUT, $sStr )

$Label2 = GUICtrlCreateLabel("Please Select User", 158, 36, 128, 18)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$USER = GUICtrlCreateCombo("USER", 158, 56, 115, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlSetData($USER, $sStr2 )

$Label3 = GUICtrlCreateLabel("Please Select Environment", 295, 24, 128, 36)
GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0x000080)
$ENVS = GUICtrlCreateCombo("ENVS", 295, 56, 115, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlSetData($ENVS, $sStr3 )
$OK = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)
GUISetState()
#EndRegion ### END Koda GUI section ###

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

        Case $Label1
        Case $AUT
            $Display = GUICtrlRead($AUT)
            MsgBox(0x40, 'Combo Box Items', GUICtrlRead($AUT))

        Case $USER
            $Display1 = GUICtrlRead($USER)
            MsgBox(0x40, 'Combo Box Items', GUICtrlRead($USER))
        Case $ENVS 
            $Display1 = GUICtrlRead($ENVS)
            MsgBox(0x40, 'Combo Box Items', GUICtrlRead($ENVS))
        Case $OK
            MsgBox(0x40, 'Pressed Button - can I create a new gui?', "can I create a new gui?")
            #Region ### START Koda GUI section ### Form=E:\Autoit-workarea\DET1.kxf
            $Form1 = GUICreate("Run Defaults", 634, 448, 289, 213)
            GUISetBkColor(0xA6CAF0)
            $Group1 = GUICtrlCreateGroup("Global Details", 32, 8, 489, 57)
            GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
            $Fullname = GUICtrlCreateLabel("Full Name", 48, 32, 60, 17)
            $Input1 = GUICtrlCreateInput("Full Name", 112, 32, 121, 21)
            $Label1 = GUICtrlCreateLabel("DET User Id", 248, 32, 73, 17)
            $Input2 = GUICtrlCreateInput("DET User Id", 344, 32, 121, 21)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $Group2 = GUICtrlCreateGroup("Course Offering Creation", 32, 80, 593, 113)
            GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
            $Year = GUICtrlCreateLabel("Year", 40, 104, 30, 17)
            $Combo1 = GUICtrlCreateCombo("Year", 80, 104, 33, 25)
            $Semester = GUICtrlCreateLabel("Semester", 120, 104, 59, 17)
            $Semeste = GUICtrlCreateCombo("Semester", 192, 104, 73, 25)
            $Label2 = GUICtrlCreateLabel("Course No", 272, 104, 64, 17)
            $Course = GUICtrlCreateCombo("Course No", 344, 104, 65, 25)
            $Label3 = GUICtrlCreateLabel("Location No", 40, 144, 70, 17)
            $Location = GUICtrlCreateCombo("Location No\", 120, 144, 89, 25)
            $Label4 = GUICtrlCreateLabel("Offer Type", 232, 144, 65, 17)
            $Combo2 = GUICtrlCreateCombo("Offer Type", 304, 144, 65, 25)
            $Label5 = GUICtrlCreateLabel("Offer Code", 392, 144, 67, 17)
            $Offer = GUICtrlCreateInput("Offer Code", 480, 144, 121, 21)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $OK2 = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)
            GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

I'm a newb.

Im coping with QTP but am trying to get away from using the data table and parameters and want to use autoit to prompt (within a gui) for input parameters and then output to an excel spreadsheet which I read for every run. Can you tell me if there are any examples of autoit creating a gui prompting a text box entry and writing to excel spreadsheet? Tried google with no luck

I'm going to make it a pretty complicated gui but thats my issue - I'd like a starting point of creating a gui prompting for some text and outputting to a default spreadsheet (you decide) on cell col1, row1. From there on I can expand it while learning

Can anybody help?

Jow

This what I'm up to is there any way to just resize the first gui to fit the second half of the secong gui?

;region Script Settings

;<scriptSettings xmlns="http://tempuri.org/ScriptSettings.xsd">

; <scriptPackager>

; <process>autoit3.exe</process>

; <arguments />

; <extractdir>%TEMP%</extractdir>

; <files />

; <usedefaulticon>true</usedefaulticon>

; <showinsystray>false</showinsystray>

; <altcreds>false</altcreds>

; <efs>true</efs>

; <ntfs>true</ntfs>

; <local>false</local>

; <abortonfail>true</abortonfail>

; <product />

; <version>1.0.0.1</version>

; <versionstring />

; <comments />

; <includeinterpreter>false</includeinterpreter>

; <forcecomregistration>false</forcecomregistration>

; <consolemode>false</consolemode>

; <EnableChangelog>false</EnableChangelog>

; <AutoBackup>false</AutoBackup>

; <snapinforce>false</snapinforce>

; <snapinshowprogress>false</snapinshowprogress>

; <snapinautoadd>0</snapinautoadd>

; <snapinpermanentpath />

; </ScriptPackager>

;</ScriptSettings>

;endregion

#include <ComboConstants.au3>

#include <Excel.au3>

#include <GuiConstantsEx.au3>

#include <WinAPI.au3>

#include <WindowsConstants.au3>

#include <StaticConstants.au3>

#include <GDIPlus.au3>

#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

Local $widthCell, $msg, $iOldOpt

Dim $Display1 = ""

Dim $sPathAUT = 'C:\Data\AUT.xls'

Dim $sPathUSERS = 'C:\Data\USERS.xls'

Dim $sPathENVS = 'C:\Data\ENVS.xls'

Dim $oExcel1 = _ExcelBookOpen($sPathAUT, 0)

Dim $oExcel2 = _ExcelBookOpen($sPathUSERS, 0)

Dim $oExcel3 = _ExcelBookOpen($sPathENVS, 0)

Dim $aArrayAUT = _ExcelReadSheetToArray($oExcel1)

Dim $aArrayUSER = _ExcelReadSheetToArray($oExcel2)

Dim $aArrayENVS = _ExcelReadSheetToArray($oExcel3)

_ExcelBookClose($oExcel1, 0)

_ExcelBookClose($oExcel3, 0)

Dim $cellcount = 0

Dim $sCellValue = ''

For $i = 1 to 256

$sCellValue = _ExcelReadCell($oExcel2, $i, 1)

If $sCellValue = '' Then

;MsgBox(0x40, 'Cell count is ', $i)

$cellcount = $i

$i = 256

EndIf

Next

$cellcount = $cellcount - 1

Dim $sStr = ''

For $i = 1 To $aArrayAUT[0][0]

For $j = 1 To $aArrayAUT[0][1]

If $aArrayAUT[$i][$j] <> "" Then $sStr &= $aArrayAUT[$i][$j] & '|'

Next

Next

$sStr = StringTrimRight($sStr, 1)

Dim $sStr2 = ''

For $i = 1 to $cellcount

$sStr2 &= _ExcelReadCell($oExcel2, $i, 1) & '|'

Next

_ExcelBookClose($oExcel2, 0)

;Dim $sStr2 = ''

;For $i = 1 To $aArrayUSER[0][0]

; For $j = 1 To $aArrayUSER[0][1]

; If $aArrayUSER[$i][$j] <> "" Then $sStr2 &= $aArrayUSER[$i][$j] & '|'

; Next

;Next

$sStr2 = StringTrimRight($sStr2, 1)

Dim $sStr3 = ''

For $i = 1 To $aArrayENVS[0][0]

For $j = 1 To $aArrayENVS[0][1]

If $aArrayENVS[$i][$j] <> "" Then $sStr3 &= $aArrayENVS[$i][$j] & '|'

Next

Next

$sStr3 = StringTrimRight($sStr3, 1)

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Rundata Default Selection", 633, 447, 289, 213)

$Group1 = GUICtrlCreateGroup("User Profile Selection", 8, 0, 585, 105)

GUICtrlSetFont(-1, 10, 400, 0, "Verdana")

GUICtrlCreateGroup("1", -99, -99, 1, 1)

GUISetBkColor(0xA6CAF0)

;$Label1 = GUICtrlCreateLabel(" Please Select ", 16, 18, 216, 18)

;GUICtrlSetFont(-1, 9, 800, 0, "Verdana")

;GUICtrlSetColor(-1, 0x000080)

$Label1 = GUICtrlCreateLabel("Application to test", 16, 36, 216, 18)

GUICtrlSetFont(-1, 9, 800, 0, "Verdana")

GUICtrlSetColor(-1, 0x000080)

$AUT = GUICtrlCreateCombo("", 32, 56, 75, 25)

GUICtrlSetFont(-1, 8, 400, 0, "Verdana")

GUICtrlSetData($AUT, $sStr )

$Label2 = GUICtrlCreateLabel("Please Select User", 158, 36, 128, 18)

GUICtrlSetFont(-1, 9, 800, 0, "Verdana")

GUICtrlSetColor(-1, 0x000080)

$USER = GUICtrlCreateCombo("", 158, 56, 115, 25)

GUICtrlSetFont(-1, 8, 400, 0, "Verdana")

GUICtrlSetData($USER, $sStr2 )

$Label3 = GUICtrlCreateLabel("Please Select Environment", 295, 24, 128, 36)

GUICtrlSetFont(-1, 9, 800, 0, "Verdana")

GUICtrlSetColor(-1, 0x000080)

$ENVS = GUICtrlCreateCombo("", 295, 56, 115, 25)

GUICtrlSetFont(-1, 8, 400, 0, "Verdana")

GUICtrlSetData($ENVS, $sStr3 )

$Checkbox1 = GUICtrlCreateCheckbox("Online?", 415, 56, 97, 17)

GUICtrlSetFont(-1, 8, 400, 0, "Verdana")

$OK = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)

GUISetState()

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Label1

Case $AUT

$Display = GUICtrlRead($AUT)

;MsgBox(0x40, 'Combo Box AUT ', $Display)

Case $USER

$Display1 = GUICtrlRead($USER)

;MsgBox(0x40, 'Combo Box User ', $Display1)

Case $ENVS

$Display2 = GUICtrlRead($ENVS)

;MsgBox(0x40, 'Combo Box User ', $Display1)

;MsgBox(0x40, 'Combo Box Items', GUICtrlRead($ENVS))

;MsgBox(0x40, 'Combo Box ENVS ', $Display2)

Case $Checkbox1

$Checkboxin1 = GUICtrlRead($Checkbox1)

if $Checkboxin1 = 1 Then

MsgBox(0x40, 'Check Box is on', $Checkboxin1 ,10)

MsgBox(0x40, 'please make sure browsers are turned off', $Checkboxin1 ,10)

endif

Case $OK

;MsgBox(0x40, 'Pressed Button - can I create a new gui?', "I create a new gui?")

;MsgBox(0x40, 'These are values retrieved', "AUT " & $Display & " USER " & $Display1 & " ENVS " & $Display2)

#Region ### START Koda GUI section ### Form=E:\Autoit-workarea\DET1.kxf

;GUICtrlSetState(-1, $GUI_DISABLE + $GUI_HIDE )

$Form2 = GUICreate("Run Defaults", 634, 448, 289, 213)

GUISetBkColor(0xA6CAF0)

$Group1 = GUICtrlCreateGroup("Global Default Details", 32, 8, 489, 57)

GUICtrlSetFont(-1, 10, 400, 0, "Verdana")

$Fullname = GUICtrlCreateLabel("Full Name", 48, 32, 60, 17)

$Input1 = GUICtrlCreateInput($Display1, 112, 32, 121, 21)

$oExcel2 = _ExcelBookOpen($sPathUSERS, 0)

$aArrayUSER = _ExcelReadSheetToArray($oExcel2)

Dim $sDetIdValue = ''

For $i = 1 to 256

;MsgBox(0x40, 'Read this DETID',_ExcelReadCell($oExcel2, $i, 1) & _ExcelReadCell($oExcel2, $i, 2))

;MsgBox(0x40, 'This is Display1 ', $Display1 )

If _ExcelReadCell($oExcel2, $i, 1) = $Display1 Then

;MsgBox(0x40, 'This is what was read ', _ExcelReadCell($oExcel2, $i, 1) )

;MsgBox(0x40, 'This is Display1 ', $Display1 )

$sDetIdValue = _ExcelReadCell($oExcel2, $i, 2)

EndIf

If _ExcelReadCell($oExcel2, $i, 1) = '' Then

;MsgBox(0x40, 'Cell count is ', $i)

$cellcount = $i

$i = 256

EndIf

Next

$cellcount = $cellcount - 1

_ExcelBookClose($oExcel2, 0)

$hForm1 = GUICtrlGetHandle($Form1)

;GUIDelete();

$Label1 = GUICtrlCreateLabel("DET User Id", 248, 32, 73, 17)

$Input2 = GUICtrlCreateInput($sDetIdValue, 344, 32, 121, 21)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group2 = GUICtrlCreateGroup("Course Offering Creation", 32, 80, 593, 113)

GUICtrlSetFont(-1, 10, 400, 0, "Verdana")

$Year = GUICtrlCreateLabel("Year", 40, 104, 30, 17)

$Combo1 = GUICtrlCreateCombo("Year", 80, 104, 33, 25)

$Semesterlabel = GUICtrlCreateLabel("Semester", 120, 104, 59, 17)

$Semester = GUICtrlCreateCombo("Semester", 192, 104, 73, 25)

$Label2 = GUICtrlCreateLabel("Course No", 272, 104, 64, 17)

$Course = GUICtrlCreateCombo("Course No", 344, 104, 65, 25)

$Label3 = GUICtrlCreateLabel("Location No", 40, 144, 70, 17)

$Location = GUICtrlCreateCombo("Location No\", 120, 144, 89, 25)

$Label4 = GUICtrlCreateLabel("Offer Type", 232, 144, 65, 17)

$Combo2 = GUICtrlCreateCombo("Offer Type", 304, 144, 65, 25)

$Label5 = GUICtrlCreateLabel("Offer Code", 392, 144, 67, 17)

$Offer = GUICtrlCreateInput("Offer Code", 480, 144, 121, 21)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$OK2 = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $OK2

MsgBox(0x40, 'Pressed Ok2', "I can now process the input params?")

Exit

EndSwitch

WEnd

#EndRegion ### END Koda GUI section ###

EndSwitch

WEnd

Func _Update_ListBox()

_GUICtrlListBox_BeginUpdate($hListBox)

_GUICtrlListBox_ResetContent($hListBox)

_GUICtrlListBox_InitStorage($hListBox, 100, 4096)

;_GUICtrlListBox_AddString ($hListBox, "")

For $i = 1 To $aArray[0]

_GUICtrlListBox_AddString ($hListBox, $aArray[$i])

Next

_GUICtrlListBox_EndUpdate($hListBox)

EndFunc

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