Jump to content

How to create multiple GUI (for newb)


Recommended Posts

  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Its possible to make "box" or whatever in GUI window where you can add text and save it. Next time i open GUI text will be here saved

$sInput = GUICtrlCreateInput ( "text", left, top [, width [, height [, style [, exStyle]]]] )

$sReadInput = GUICtrlRead($sInput)

Throw it into an INI file, and reload the text from the ini.

IniWrite()

IniRead()

Edited by mechaflash213
Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to post
Share on other sites

Thank you. It will take some time to do that and understand some sentences... can you show me short example where is everything together? i dont know hot to "Throw it into an INI file, and reload the text from the ini.". Thanks

Edited by Edgaras
Link to post
Share on other sites

Thus the links I provided?

#include

;Ini Vars
$pathIni = @DesktopDir & "/mecha.ini"
$sIniSection = "Saved"
$sIniKey = "Input"
$sSavedInput = IniRead($pathIni, $sIniSection, $sIniKey, False)

;Make the Gui
$GuiMain = GUICreate("Test", 150, 100)
$sInput = GUICtrlCreateInput("Insert Input", 5, 5, 140, 40)
If Not ($sSavedInput = "False") Then GUICtrlSetData($sInput, $sSavedInput)
$bExitSave = GUICtrlCreateButton("Exit and Save Input", 5, 50, 140, 40)

;Activate Gui
GUISetState(@SW_SHOW, $GuiMain)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $bExitSave ;Exit and Save Button is pressed
            $sReadInput = GUICtrlRead($sInput) ;Read the user's input
            IniWrite($pathIni, $sIniSection, $sIniKey, $sReadInput) ; Save the user's input to the ini file
            Exit
    EndSwitch
WEnd

There's a working standalone example. If you can't figure it out from there... then sir I believe you can haz needing more help than I can haz giving u

Edited by mechaflash213
Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to post
Share on other sites

There's a working standalone example. If you can't figure it out from there... then sir I believe you can haz needing more help than I can haz giving u

I think everyone would agree this is enough information for you to put it together yourself. Quit being lazy and just get to work.

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to post
Share on other sites

Edgaras,

People that have replied here have provided you with enough information to get you started, above and beyond what is normally required. Do what I do/did, use the Help file, it's been proven to help people. Good luck.

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

Link to post
Share on other sites

How to stop working function? For example in GUI is 2buttons. One is Start other Stop. When i hit start code is for example

Func on_start()
While 1
Run("calc")
WEnd
EndFunc

so it opens calculator million times (idk if its right example) and how i can make On_stop function? When i would click stop button it stops on_start function. By the way im doing it with link opener for sreenshots in internet. So on start is ~10links and i want to stop opening links when i click that button.

I tried to solve it myself but didnt found anything or it just wont work. I tried _Ieaction($oIE,"stop") but it just dont do anything.

Edited by Edgaras
Link to post
Share on other sites
  • Moderators

Edgaras,

You do not need a While...WEnd loop here. Just decide if you want to wait until you close Calculator and then use Run or RunWait. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to post
Share on other sites
  • Moderators

Edgaras,

Why do you want an infinite loop to start Calulator? ;)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$cButton = GUICtrlCreateButton("Calc", 10, 10, 80, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton
            ; Disable the GUI so that you cannot press the button again
            GUISetState(@SW_DISABLE, $hGUI)
            ; Run Calc and wait until it finishes
            RunWait("Calc.exe")
            ; Reenable the GUI 
            GUISetState(@SW_ENABLE, $hGUI)
    EndSwitch
WEnd

There is no need for an infinite loop and so no need to interrupt it. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to post
Share on other sites

... Calculator is example. In your example you show me only one button. But i need 2. Again, i use on_button func. So it calls OnEvent GUI? For exmp clicking 1st button opens different things like calc, notepad, mword, IE and so on. And while computer/script is opening these things i want to hit stop button and stop script which opens calc etc.

Its like with hotkeys from helpfile clicking pause it pauses script or terminates with esc. But i dont need to stop all GUI with bunch of buttons just that working function

Edited by Edgaras
Link to post
Share on other sites
  • Moderators

Edgaras,

For exmp clicking 1st button opens different things

And how do you expect to AutoIt to do that? How do you tell it what app to open? ;)

i want to hit stop button and stop script which opens calc

And what do you mean by this? Opening an app is a single action - you cannot "stop" it but you can close the app once it is open. :)

What about posting the code you do have rather then me writing snippets which may or may not help. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to post
Share on other sites

I dont have full code right now. I will try to create short GUI example.

#include <guiconstantsex.au3>
#include  <crypt.au3>
#include <ie.au3>
Opt("GUIOnEventMode", 1)
Global $hGUI2, $hButton2
Home()
Func Home()
     $hGUI1 = GUICreate("Opener", 200, 200, 100, 100)
     GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Main")
     $hButton1 = GUICtrlCreateButton("Start", 10, 10, 80, 30)
     GUICtrlSetOnEvent(-1, "On_Button1")
     $hButton2 = GUICtrlCreateButton("Stop", 10, 60, 80, 30)
     GUICtrlSetOnEvent(-1, "On_Button2")
     GUISetState()
     While 1
         Sleep(10)
     WEnd
EndFunc  
Func On_Button1()
_IECreate("http://www.google.com")
_IECreate("http://www.autoitscript.com/forum/topic/139886-how-to-create-multiple-gui-for-newb/page__st__20")
_IECreate("http://www.autoitscript.com")
_IECreate("http://www.autoitscript.com/forum")
EndFunc  
Func On_Close_Main()
     Exit
EndFunc

Func On_Button2()
;so i dont know how to stop previous function
EndFunc

When 1st function starts i want to stop it when i want or i have to stop. Never know when i will need to stop as my computer slow. Same with infinitive loop.

Edited by Edgaras
Link to post
Share on other sites
  • Moderators

Edgaras,

That shows why posting some code is always a good idea - now we can see why you might want to interrupt the function. ;)

And here is how you can do it:

#include <GUIConstantsEx.au3>
#include <IE.au3>

Opt("GUIOnEventMode", 1)

Global $fStart_IECreation = False, $hButton1

Home()

While 1
    Sleep(10)
    ; Should we start?
    If $fStart_IECreation = True Then
        _IECreation()
    EndIf
WEnd

Func Home()
    $hGUI1 = GUICreate("Opener", 200, 200, 100, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Main")
    $hButton1 = GUICtrlCreateButton("Start", 10, 10, 80, 30)
    GUICtrlSetOnEvent(-1, "On_Button1")
    $hButton2 = GUICtrlCreateButton("Stop", 10, 60, 80, 30)
    GUICtrlSetOnEvent(-1, "On_Button2")
    GUISetState()
EndFunc   ;==>Home

Func On_Button1()
    ; Set the flag to show we should start
    $fStart_IECreation = True
EndFunc   ;==>On_Button1

Func _IECreation()
    ; Prevent multiple presses
    GUICtrlSetState($hButton1, $GUI_DISABLE)
    ;_IECreate("http://www.google.com")
    ; Simulate IECreate function
    ConsoleWrite("IECreate 1" & @CRLF)
    Sleep(5000)
    ; Check to see if we should stop
    If $fStart_IECreation = False Then
        ConsoleWrite("Stopping" & @CRLF)
        Return
    EndIf
    ;_IECreate("http://www.autoitscript.com/forum/topic/139886-how-to-create-multiple-gui-for-newb/page__st__20")
    ConsoleWrite("IECreate 2" & @CRLF)
    Sleep(5000)
    If $fStart_IECreation = False Then
        ConsoleWrite("Stopping" & @CRLF)
        Return
    EndIf
    ;_IECreate("http://www.autoitscript.com")
    ConsoleWrite("IECreate 3" & @CRLF)
    Sleep(5000)
    If $fStart_IECreation = False Then
        ConsoleWrite("Stopping" & @CRLF)
        Return
    EndIf
    ;_IECreate("http://www.autoitscript.com/forum")
    ConsoleWrite("IECreate 4" & @CRLF)
    Sleep(5000)
    $fStart_IECreation = False
    ; Re-enable button
    GUICtrlSetState($hButton1, $GUI_DISABLE)
EndFunc   ;==>_IECreation

Func On_Close_Main()
    Exit
EndFunc   ;==>On_Close_Main

Func On_Button2()
    ; Set the flag to show we should stop
    $fStart_IECreation = False
EndFunc   ;==>On_Button2

You might like to read the Interrupting a running function tutorial in the Wiki to see other ways you can do the same thing - it is not as simple as you might think. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to post
Share on other sites
  • Moderators

Edgaras,

Also it will be possible to stop loops?

Of course - look at the examples in the Wiki tutorial which use loops to illustrate how to do it. :)

You are correct that it is a little hard to understand, but do try to follow the code along with the tutorial - I wrote it to help those learning some of the more difficult elements of AutoIt. And, of course, you can always ask if you have any questions - that is why we are here after all. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to post
Share on other sites

Just found out how to make with loop in easy way. I made while loop in ur _iecreation

Func _IECreation()
While 1
;<-------------- here goes comands what to do.
    ConsoleWrite("IECreate 1" & @CRLF)   ; still dont know what this means
    If $fStart_IECreation = False Then
        ConsoleWrite("Stopping" & @CRLF)
        Return
    EndIf
;<-------------- here goes comands what to do.
    ConsoleWrite("IECreate 2" & @CRLF)
;
    If $fStart_IECreation = False Then
        ConsoleWrite("Stopping" & @CRLF)
        Return
    EndIf
;<-------------- here goes comands what to do.
    ConsoleWrite("IECreate 3" & @CRLF)
   ;
    If $fStart_IECreation = False Then
        ConsoleWrite("Stopping" & @CRLF)
        Return
    EndIf
;<-------------- here goes comands what to do.
    ConsoleWrite("IECreate 4" & @CRLF)
   ;

   WEnd
EndFunc

And placed codes for "start" and "stop" buttons. Wait wait I just saw that there is possible to cut half code ;)

EDIT :

Func _IECreation()
While 1
;script goes here
    If $fStart_IECreation = False Then
        ConsoleWrite("Stopping" & @CRLF)
        Return
    EndIf
;and here
    ConsoleWrite("IECreate 4" & @CRLF)
   WEND
EndFunc

These ConcoleWrite do something?

Edited by Edgaras
Link to post
Share on other sites
  • Moderators

Edgaras,

Why do you want a loop there? If you put a loop in the function, then you will just run multiple instances of each _IECreate statement - which I am sure you do not want. What exactly are you trying to do here? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...