Jump to content
Sign in to follow this  
RegularGuy

How do I create a wizard-like GUI

Recommended Posts

RegularGuy

I have been trying to figure out the best way (practice) of preforming this task. I am still new to this all (auto it as well as programming) and I need some help. I'm creating a wizard that prompts the user for several peices of information and then returns an answer.

I have included this sample code of the method that I've begun using but I would like some feedback as to what I could do differently, because I know there is a better way that what I have here.

Global $GuiHeight = 400
Global $GuiWidth = 350
Global $ButtonWidth1 = 100
GLobal $NavButton = 75
Global $Centered = $GuiWidth/2-$ButtonWidth1/2
Global $NavCentered = $GuiWidth/2-$NavButton/2
GLobal $Left = 10
Global $Bottom = $GuiHeight-25-$Left
Global $Right = $GuiWidth-$NavButton-$Left

_Inception()

Func _Inception()
    Local $GuiDescription = "You're getting sleepy"
    GUICreate("",$GuiWidth,$GuiHeight)
    GUICtrlCreateLabel($GuiDescription,$Left,10)
    Local $cancel = GUICtrlCreateButton("Cancel", $Left, $Bottom,$NavButton)
    local $next = GUICtrlCreateButton("Next", $Right, $Bottom, $NavButton)
    GUICtrlCreateLabel("Level 1",$GuiWidth/2,$GuiHeight/2)

    GUISetState()

While 1
  Local $msg = GUIGetMsg()
  Switch $msg

     Case -3
        Exit

     Case $cancel
        Exit

     Case $next
        GUIDelete()
        _Inception2()

    EndSwitch
WEnd

EndFunc

Func _Inception2()
Local $GuiDescription = "Follow the White Rabbit."
GUICreate("",$GuiWidth,$GuiHeight)
GUICtrlCreateLabel($GuiDescription,$Left,10)
Local $cancel = GUICtrlCreateButton("Cancel", $Left, $Bottom,$NavButton)
Local $back = GUICtrlCreateButton("Back", $NavCentered,$Bottom,$NavButton)
local $next = GUICtrlCreateButton("Next", $Right, $Bottom, $NavButton)
GUICtrlCreateLabel("Level 2",$GuiWidth/2,$GuiHeight/2)
local $Button1 = Guictrlcreatebutton("Test 1",$Left,40,100)
local $Button2 = Guictrlcreatebutton("Test 2",$Centered,40,100)
local $Button3 = Guictrlcreatebutton("Test 3",$Right-25,40,100)

GUISetState()

While 1
  Local $msg = GUIGetMsg()
  Switch $msg

     Case -3
        Exit

     Case $cancel
        Exit

     Case $back
        GUIDelete()
        _Inception()

     Case $next
        GUIDelete()
        _Inception3()

  EndSwitch
WEnd

EndFunc

Func _Inception3()
Local $GuiDescription = "You are Fast asleep"
GUICreate("",$GuiWidth,$GuiHeight)
GUICtrlCreateLabel($GuiDescription,$Left,10)
Local $cancel = GUICtrlCreateButton("Cancel", $Left, $Bottom,$NavButton)
Local $back = GUICtrlCreateButton("Back", $NavCentered,$Bottom,$NavButton)
GUICtrlCreateLabel("Level 3",$GuiWidth/2,$GuiHeight/2)
local $Button1 = Guictrlcreatebutton("Test 1",$Left,100,100)
local $Button2 = Guictrlcreatebutton("Test 2",$Centered,70,100)
local $Button3 = Guictrlcreatebutton("Test 3",$Right-25,100,100)

GUISetState()

While 1
  Local $msg = GUIGetMsg()
  Switch $msg

     Case -3
         Exit

     Case $cancel
          Exit

     Case $back
        GUIDelete()
        _Inception2()

    EndSwitch
WEnd

EndFunc

Again, I know there is a better way.

Ideally, I liked what Valuater did in his Autoit 1-2-3 program where there was one window that changed as you hit next. I just don't know how to create something like that or, what I should even be looking for in order to study how to create that.

Thank you in advance!

EDIT> Edited code for clarity

Edited by RegularGuy

Share this post


Link to post
Share on other sites
ProgAndy

What about something like this?

#include<WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

Global $hStepGUIS[3]

$hGUI = GUICreate("MainGUI", 400, 400)
GUISetOnEvent(-3, "_Main_Exit")

$hStepGUIS[0] = GUICreate("Step1", 400, 370, 0, 0, $WS_CHILD, $WS_EX_CONTROLPARENT, $hGUI)
GUICtrlCreateButton("&Next", 10, 10, 100, 100)
GUICtrlSetOnEvent(-1, "Step1_Next")


$hStepGUIS[1] = GUICreate("Step2", 400, 370, 0, 0, $WS_CHILD, $WS_EX_CONTROLPARENT, $hGUI)
GUICtrlCreateButton("&Next", 200, 10, 100, 100)
GUICtrlSetOnEvent(-1, "Step2_Next")

$hStepGUIS[2] = GUICreate("Step3", 400, 370, 0, 0, $WS_CHILD, $WS_EX_CONTROLPARENT, $hGUI)
GUICtrlCreateButton("&Back To Start", 200, 200, 100, 100)
GUICtrlSetOnEvent(-1, "Step3_Next")


SwitchToStep(0)
GUISetState(@SW_SHOW, $hGUI)

While 1
    Sleep(100)
WEnd


Func Step1_Next()
    MsgBox(0, "", "Step1 Finished")
    SwitchToStep(1)
EndFunc

Func Step2_Next()
    MsgBox(0, "", "Step 2 stopped")
    SwitchToStep(2)
EndFunc

Func Step3_Next()
    MsgBox(0, "", "Go to beginning now")
    SwitchToStep(0)
EndFunc


Func SwitchToStep($step)
    Local $max = UBound($hStepGUIS) - 1
    If $step < 0 Or $step > $max Then Return SetError(1, 0, 0)
    For $i = 0 To $max
        If $i = $step Then
            GUISetState(@SW_SHOW, $hStepGUIS[$i])
            GUISwitch($hStepGUIS[$i])
        Else
            GUISetState(@SW_HIDE, $hStepGUIS[$i])
        EndIf
    Next
    Return 1
EndFunc

Func _Main_Exit()
    Exit
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
RegularGuy

Thank you for the post, sorry I didn't respond sooner. This is great for moving forward, could you please demonstrate how you would move backwards? ex. move from step 3 back to step two.

Also, would you recommend this for a wizard that has like 50 different GUI's (or at least different input pages)? That is about the amount that I am looking at creating

Share this post


Link to post
Share on other sites
guinness

Are you sure an 'installer like application' is the best route to take? Even Windows doesn't have that amount of pages to install the operating system.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
ProgAndy

Thank you for the post, sorry I didn't respond sooner. This is great for moving forward, could you please demonstrate how you would move backwards? ex. move from step 3 back to step two.

Also, would you recommend this for a wizard that has like 50 different GUI's (or at least different input pages)? That is about the amount that I am looking at creating

I showed only the next-Button, the Back-Button will be implemented the same way. Using SwitchToStep you can jump to any step you want.

For a 50-Page GUI, I would recommend an additional TreeView on the left side where you can manually jump to the pages

PS: An example of what I mean from monodevelop: http://monodevelop.com/@api/deki/files/189/=OptionsDialogReorg.png

Edited by ProgAndy
  • Like 1

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
acidman

The easiest way is to create a parent Gui and a bunch of child gui's, which in this case you just Hide and show them when moving to the next Child therefore you can just show Them again if you need to Go back The treeview idea was a good one, but instead of all that code Just use

For the "next" Buttons

Guisetstate($ChildGui1, @sw_hide) 
Guisetstate($ChildGui2, @sw_Show)

And for The "Back Buttons"

Guisetstate($ChildGui1, @sw_Show) 
Guisetstate($ChildGui2, @sw_Hide)

This way you don't need to use all that code, plus its easier to understand.

Edited by ac1dm4nner

[u]My dream is to have a dream...[/u]

Share this post


Link to post
Share on other sites
acidman

The method I showed you when using a treeview you could aswell hide the current Child Gui And Jump to the selected Child Gui, best practises are often the ones we had to practice again and again.


[u]My dream is to have a dream...[/u]

Share this post


Link to post
Share on other sites
Melba23

ac1dm4nner,

There is an "Edit" button on your posts - start using it please. :oops:

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
ProgAndy

The easiest way is to create a parent Gui and a bunch of child gui's, which in this case you just Hide and show them when moving to the next Child therefore you can just show Them again if you need to Go back The treeview idea was a good one, but instead of all that code Just use

For the "next" Buttons

Guisetstate($ChildGui1, @sw_hide)
Guisetstate($ChildGui2, @sw_Show)

And for The "Back Buttons"

Guisetstate($ChildGui1, @sw_Show)
Guisetstate($ChildGui2, @sw_Hide)

This way you don't need to use all that code, plus its easier to understand.

That is exactly what my code is doing. I just manage the child GUIs in an array and use a function to switch between them.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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  

  • Similar Content

    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
    • xtcislove
      By xtcislove
      Hello, 
      i have a Problem with  _WinAPI_SetLayeredWindowAttributes, everything is working as excepted if u are on Windows 7.

      But if u are on Windows 10 the transparent background of a control is not clickable anymore. 

      Could someone help?

      Please see example below, put cmd.jpg into the same folder as Example.au3

      Please see trigger.jpg to see which sections are not clickable in Windows 10 (the red dots, the green dots are clickable) on Windows 7 the red ones and green ones are clickable.
       
      The same problem occurs if i use 
       
       
      Example.au3


    • WilliamasKumeliukas
      By WilliamasKumeliukas
      Hello everyones reading this post,
      I'm struggling at resizing properly my radio buttons to fit long text inside without affecting others radio buttons and also adjust position of them relative to the string.
      I tried with _StringSize UDF but I guess im too tired to figure out how to use it correctly..
      I also tried: _Control_SetWidth2Text I found on this forum, it work aslong im not maximizing GUI (radio text is gone when I maximize and maximize is a must)
       
      here is the code example, I hope someone can figure out (sorry if guictrlsetpos is not included in the example, I know thats probably the way to go but I wanted to make sure there is nothing better before use it)
      Thank you
       
      Br,
      ~WilliamasKumeliukas
       
      #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <Array.au3> #include <StringConstants.au3> #include <FileConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <EditConstants.au3> #include <GUIListBox.au3> #include <ButtonConstants.au3> #include <ProgressConstants.au3> #include <ColorConstants.au3> #include <AutoitConstants.au3> #include <Misc.au3> #include <WinAPIReg.au3> #include <WinAPI.au3> #Region Opt's Opt("GUIResizeMode", 802) #EndRegion Opt's Global $q = "INTRO LINE" & @CRLF & @CRLF & "description of everything until user press start." Global $file = @TempDir & "\test.p" destroy() Global $msg, $score = 0, $rate, $com, $total = 0, $cfile, $cq, $i = 0, $time = 0, $min = 0, $sec = 0, $hour = 0, $qf, $ii = 0 Main() Func Main() Global $iGUIInitSize = 550 #Region GUI Opt("GUICloseOnEsc", 1) Global $gui = GUICreate("example", 1124, 550,-1 ,-1, BitOR($WS_MAXIMIZEBOX , $WS_MINIMIZEBOX)) Global $gui_size = WinGetClientSize($gui) Global $iFontSize = Int(2 * (.25 + (8 * $gui_size[0] / $iGUIInitSize))) / 2 Global $options = GUICtrlCreateMenu("&Options") Global $guide = GUICtrlCreateMenuItem("Guide", $options) Global $restart = GUICtrlCreateMenuItem("Restart", $options) Global $about = GUICtrlCreateMenuItem("About", $options) Global $exit = GUICtrlCreateMenuItem("Exit", $options) Global $extra = GUICtrlCreateMenu("Extras") Global $creator = GUICtrlCreateMenu("CQB", $extra ) Global $new = GUICtrlCreateMenuItem("custom QP", $creator) Global $load = GUICtrlCreateMenuItem("CQ", $creator ) Global $timer = GUICtrlCreateLabel("", 752, 472, 294, 30, $WS_BORDER) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetFont(-1, $iFontSize) GUICtrlSetState($timer, $GUI_HIDE) Global $info = GUICtrlCreateLabel( $q, 200, 20, 700, 200, $SS_CENTER ) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) $fi = GUICtrlSetFont($info, $iFontSize) Global $a = GUICtrlCreateRadio("A)", 100, 210, $WS_EX_CLIENTEDGE) $fa = GUICtrlSetFont($a, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($a, 16) Global $b = GUICtrlCreateRadio("B)", 100, 310 , $WS_EX_CLIENTEDGE) $fb = GUICtrlSetFont($b, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($b, 16) Global $c = GUICtrlCreateRadio("C)", 750, 210 , $WS_EX_CLIENTEDGE) $fc = GUICtrlSetFont($c, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($c, 16) Global $d = GUICtrlCreateRadio( "D) ", 750, 310, $WS_EX_CLIENTEDGE) $fd = GUICtrlSetFont($d, 15) GUICtrlSetResizing (-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($d, 16) Global $sign = GUICtrlCreateLabel( $file, 420, 480, -1, -1, BitOR ( $SS_CENTER, $WS_BORDER ) ) GUICtrlSetResizing ( -1, BitOR ( $GUI_DOCKHCENTER, $GUI_DOCKVCENTER ) ) GUICtrlSetFont($sign, 12) Global $yb = GUICtrlCreateRadio("True", 200, 420, 200, 50, $BS_PUSHLIKE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER,$GUI_DOCKSIZE)) GUICtrlSetFont($yb, 15) GUICtrlSetState($yb, 32) Global $nb = GUICtrlCreateRadio("False", 700, 420, 200, 50, $BS_PUSHLIKE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER, $GUI_DOCKSIZE)) GUICtrlSetFont($nb, 15) GUICtrlSetState($nb, 32) Global $start = GUICtrlCreateButton("Start", 20, 20, 100, 50, $SS_CENTER, $WS_EX_CLIENTEDGE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) GUICtrlSetFont($start, 12) Global $valid = GUICtrlCreateButton("Confirm", 20, 20, 100, 50, $SS_CENTER, $WS_EX_CLIENTEDGE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) GUICtrlSetFont($valid, 12) GUICtrlSetState($valid, 32) GUISetState(@SW_SHOW) #EndRegion GUI While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Switch MsgBox(4096 + 4, "Warning", "Are you sure to exit?") Case 6 AdlibUnRegister("timer") If Not $qf = "" Then FileClose($file) EndIf Exit Case 7 ContinueLoop EndSwitch Case $start ;AdlibRegister("timer") ;Global $qf = StringSplit(StringStripWS(FileRead($file), 6), @CRLF, 0) ;qloop($file) GUICtrlSetData($a, "A) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($b, "B) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($c, "C) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($d, "D) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") Case $restart MsgBox(4096, "Warning", 'Normally, your suposed to start something before restarting it.') ContinueLoop Case $new ;GUISetState(@SW_HIDE, $gui) ;_CustomNew() ContinueLoop Case $load ;_CustomLoad() Case $about ;_About() EndSwitch WEnd EndFunc ;Main() Func timer() If $time = 0 Then Global $time = TimerInit() Global $diff = TimerDiff($time) Global $sec = Int(Mod($diff / 1000, 60)) Global $min = Int(Mod($diff / 60000, 60)) Global $hour = Int($diff / 3600000) If $sec < 10 Then $sec = "0" & $sec If $min < 10 Then $min = "0" & $min If $hour < 10 Then $hour = "0" & $hour GUICtrlSetData($timer, "Temps: " & $hour & ":" & $min & ":" & $sec) EndFunc ;==>timer Func destroy() If FileExists($file) Then FileDelete($file) EndIf DirCreate(@TempDir & "\About") FileInstall("C:\test.txt", $file) EndFunc ;==>destroy  
    • xtcislove
      By xtcislove
      Hello,

      im searching like 6 hours and i didnt found the right solution.

      Im trying to build a treeview from a directory and its subfolders etc.

      This function give me right treeview, but i cant color each item seperated.

       
      #include <GuiTreeView.au3> $hGui = GUICreate("Demo1", 600, 400) $hTreeView = _GUICtrlTreeView_Create($hGui, 10, 10, 580, 380) GUISetState() _GUICtrlTreeView_BeginUpdate($hTreeView) ListFiles_ToTreeView(@ScriptDir, 0) _GUICtrlTreeView_EndUpdate($hTreeView) Do Until GUIGetMsg() = -3 Func ListFiles_ToTreeView($sSourceFolder, $hItem) Local $sFile ; Force a trailing \ If StringRight($sSourceFolder, 1) <> "\" Then $sSourceFolder &= "\" ; Start the search Local $hSearch = FileFindFirstFile($sSourceFolder & "*.*") ; If no files found then return If $hSearch = -1 Then Return ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Now run through the contents of the folder While 1 ; Get next match $sFile = FileFindNextFile($hSearch) ; If no more files then close search handle and return If @error Then ExitLoop ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Check if a folder If @extended Then ; If so then call the function recursively ListFiles_ToTreeView($sSourceFolder & $sFile, _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile)) Else ; If a file than write path and name _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile) EndIf WEnd ; Close search handle FileClose($hSearch) EndFunc ;==>ListFiles_ToTreeView
      So i am searching for the exact same function just with
      GUICtrlCreateTreeViewItem
      instead of 
      _GUICtrlTreeView_AddChild
       
      Ps: i have a folder structure where i like to color each item green if a file only exist once and red if it exist more than once.

      Could someone help?
       
      Solution:

       
       
×