Jump to content

GUI beginner attempt, cash register


Recommended Posts

I will google and find sites

On the forum, use the forum search feature.

No I'm not evil, we don't code for you otherwise you will never know how to learn by yourself and find the answers you're looking for.

Futhermore, you are lucky to have a VERY helpful helpfile.

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

On the forum, use the forum search feature.

No I'm not evil, we don't code for you otherwise you will never know how to learn by yourself and find the answers you're looking for.

Futhermore, you are lucky to have a VERY helpful helpfile.

Br, FireFox.

 

I was joking.

But this is f***** ridiculus what a difference is to make a script with 2 GUI-s and 3 GUI-s.

I'm so mad...

;
;
;
;
;
; IMPORTANT: Has 7 GUI-s:
; 1. GUI 1 is just to start
; 2. GUI 2 is the main window where products should be chosen
; 3. GUI 3 is where all the non-alcoholic drinks are
; 4. GUI 4 is where all alcoholic drinks are
; 5. GUI 5 IS A GUI WITH VARIABLE INPUT, for quantity, and price
; 6. GUI 6 is where a new product should be entered
; 7. GUI 7 is where a person can see the storehouse wares (to know for example, which items to order)

; This is the INI file we will write to.  It will be created on the Desktop.
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

Global Const $SS_CENTER = 1
Global Const $SS_CENTERIMAGE = 1



Local $sIni = @DesktopDir & "\AutoIt-Test.ini"

Local $Section = "Coca Cola"
Local $Code = "018719"
Local $Quantity = "312"; It would be best to keep intergers from strings.
Local $QuantityType = "0,25l Bottles"; It would be best to keep intergers from strings.


; Demonstrate creating a new section using a string as input.
IniWrite($sIni, $Section, "Code", $Code)
IniWrite($sIni, $Section, "Quantity", $Quantity)
IniWrite($sIni, $Section, "QuantityType", $QuantityType)

#include <GUIConstantsEx.au3>
Global $colors_green = 0x00FF00
Global $colors_yellow = 0xFFFF00
Global $colors_red = 0xFF0000
Global $colors_black = 0x000000



;GUI_1:
$GUI_1= GUICreate("BEN", 400, 300, Default, Default) ;==> draws GUI
GUISetBkColor(0x000000)
GUISetFont(14, 400, "", "Cambria")

;GUI_1_buttons:
$GUI_1_start= GUICtrlCreateButton("Ulaz", 20, 25, 360, 120)
GUICtrlSetFont(-1, 40, 800)
GUICtrlSetBkColor(-1, $colors_green)

$GUI_1_exit= GUICtrlCreateButton("Izlaz", 20, 155, 360, 120)
GUICtrlSetFont(-1, 40, 800)
GUICtrlSetBkColor(-1, $colors_yellow)



GUISetState()



;GUI_2:
$GUI_2= GUICreate("Main window", 1800, 900, Default, Default, $GUI_1)
GUISetBkColor($colors_black)
GUISetFont(14, 400, "", "Cambria")

;GUI_2_buttons:
$no_alcohol = GUICtrlCreateButton("Non-alcohol", 20, 20, 200, 200)
GUICtrlSetFont(-1, 16, 800)
GUICtrlSetBkColor(-1, $colors_green)

$alcohol = GUICtrlCreateButton("Alcohol", 240, 20, 200, 200)
GUICtrlSetFont(-1, 16, 800)
GUICtrlSetBkColor(-1, $colors_green)

$storehouse = GUICtrlCreateButton ("Storehouse", 1260, 20, 300, 300)
GUICtrlSetFont (-1, 16, 800)
GUICtrlSetBkColor (-1, $colors_green)

$finish = GUICtrlCreateButton("Finish", 40, 740, 1720, 80)



;GUI_7:
;$GUI_storehouse = GUICreate("Storehouse", 1400, 900, Default, Default, $GUI_2) ;==> draws GUI
;GUISetBkColor(0x000000)
;GUISetFont(14, 400, "", "Cambria")

;GUI_7_buttons:
;$exit_storehouse = GUICtrlCreateButton("Exit", 20, 20, 200, 200)
;GUICtrlSetFont(-1, 16, 800)
;GUICtrlSetBkColor(-1, $colors_green)

#cs ;GUI_2_labels:
GUICtrlCreateLabel("I", 200, 10, 450, 100)
GUICtrlSetFont(-1, 16, 800)
GUICtrlSetColor(-1, $colors_green)

GUICtrlCreateLabel("Wares", 45, 60, 450, 50)
GUICtrlSetFont(-1, 12, 800)
GUICtrlSetColor(-1, $colors_green)

GUICtrlCreateLabel("Prices", 350, 60, 450, 50)
GUICtrlSetFont(-1, 12, 800)
GUICtrlSetColor(-1, $colors_green)

;GUICtrlCreateLabel("2:", 490, 20, 450, 100)
;GUICtrlSetFont(-1, 20, 800)
;GUICtrlSetColor(-1, $colors_green)

;GUI_2_combos+inputs:
Global $checkbox_1 = GUICtrlCreateCheckbox("", 10, 105, 20, 20)
Global $item_1 = GUICtrlCreateCombo("1", 40, 100, 300, Default) ; create first item
GUICtrlSetData(-1, "2|3|4|5|6|7|8|", "1") ; add other item snd set a new default
GUICtrlSetFont(-1, 12, 600)
Global $quantity_1= GUICtrlCreateInput( '', 345, 100, 160, 31)
GUICtrlSetLimit(-1,10)
#ce GUICtrlSetFont(-1, 12, 600)


;GUI_2_buttons:


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            If WinActive($GUI_1) Then Exit
            If WinActive($GUI_2) Then
                GUISetState(@SW_HIDE, $GUI_2)
                GUISetState(@SW_ENABLE, $GUI_1)
                WinActivate($GUI_1)
            ;If WinActive($GUI_3)
                ;GUISetState(@SW_HIDE, $GUI_3)
                ;GUISetState(@SW_HIDE, $GUI_2)
                ;GUISetState(@SW_ENABLE, $GUI_1)
            EndIf
        Case $GUI_1_start
            GUISetState(@SW_DISABLE, $GUI_1)
            GUISetState(@SW_HIDE, $GUI_1)
            GUISetState(@SW_ENABLE, $GUI_2)
            GUISetState(@SW_SHOW, $GUI_2)
            WinActivate($GUI_2)
        Case $GUI_1_exit
            Exit
        Case $storehouse
            _gui_storehouse()
            ;GUISetState (@SW_HIDE, $GUI_2)
            ;GUISetState(@SW_ENABLE, $GUI_storehouse)
            ;GUISetState(@SW_SHOW, $GUI_storehouse)
            ;WinActivate($GUI_storehouse)
            ;Switch GUIGetMsg()
                ;Case $exit_storehouse
                    ;GUISetState(@SW_HIDE, $GUI_storehouse)
                    ;GUISetState(@SW_SHOW, $GUI_2)
                    ;WinActivate ($GUI_2)
            ;EndSwitch
        ;Case $finish
            ;$exit_confirm= MsgBox(4, "Confirm finish", "Print the bill?")
            ;Switch $exit_confirm
                ;Case $exit_confirm = 6
                    ;Exit
                ;Case $exit_confirm = 7
                    ;Exit
            ;EndSwitch
            Exit
    EndSwitch
WEnd


Func _gui_storehouse()
    $GUI_storehouse = GUICreate("Storehouse", 1400, 900, Default, Default) ;==> draws GUI
    GUISetBkColor(0x000000)
    GUISetFont(14, 400, "", "Cambria")

    $exit_storehouse = GUICtrlCreateButton("Exit", 20, 20, 200, 200)
    GUICtrlSetFont(-1, 16, 800)
    GUICtrlSetBkColor(-1, $colors_green)

    GUISetState()
EndFunc

I think there is no bread for me here, for now I will continue to pay the programmer 300 EUR per year for my program.

I think I will uninstall AutoIt and try something easier to learn to code, Visual Basic or PHP, and then return when I'm better at programming.

Edited by CroatianPig

YES, I know I ask facepalm questions.

YES, I know you asked the God why I had to register to the forum where normal people are.

YES, I know everything!

Link to comment
Share on other sites

Here is the example I made for managing multiple GUIs:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
 
Example()
 
Func Example()
    ; Create a GUI.
    Local $hGUI1 = GUICreate("Example GUI1")
    ; Create a button.
    Local $iButton1 = GUICtrlCreateButton("Button1", 10, 10, 80, 22)
    ; Display the GUI
    GUISetState(@SW_SHOW, $hGUI1)
 
    ; Create a GUI.
    Local $hGUI2 = GUICreate("Example GUI2", 300, 300)
    ; Create a button.
    Local $iButton2 = GUICtrlCreateButton("Button2", 10, 10, 80, 22)
    ; Display the GUI
    GUISetState(@SW_SHOW, $hGUI2)
 
    ; Initialize a Local variable.
    Local $aMsg = 0
 
    While 1
        ; Assign to $aMsg the advanced GUI messages.
        $aMsg = GUIGetMsg(1)
 
        ; Switch from GUIs
        Switch $aMsg[1]
            Case $hGUI1
                ; The event comes from the GUI1
 
                ; Switch from event ID
                Switch $aMsg[0]
                    Case $GUI_EVENT_CLOSE
                        ExitLoop
                    Case $iButton1
                        MsgBox($MB_SYSTEMMODAL, "", "Button1 clicked.")
                EndSwitch
            Case $hGUI2
                ; The event comes from the GUI2
 
                ; Switch from event ID
                Switch $aMsg[0]
                    Case $GUI_EVENT_CLOSE
                        GUIDelete($hGUI2)
                    Case $iButton2
                        MsgBox($MB_SYSTEMMODAL, "", "Button2 clicked.")
                EndSwitch
        EndSwitch
 
        ; Avoid high CPU usage.
        Sleep(10)
    WEnd
 
    ; Delete the previous GUIs and all controls.
    GUIDelete($hGUI1)
EndFunc   ;==>Example
Br, FireFox.
Link to comment
Share on other sites

THIS is a joke.

 

I joke often, but not this time. I never blame anyone else. I say openly I'm too retarded for this, whether atm or chronically.

May I ask why you think it's a joke?

:-)

YES, I know I ask facepalm questions.

YES, I know you asked the God why I had to register to the forum where normal people are.

YES, I know everything!

Link to comment
Share on other sites

The syntax of the Visual Basic/PHP is harder to understand for a beginner than autoit, but try you will see.

hm, whoever I don't see what you will do with PHP as you are using a GUI here.

 

Yes, my friend who does websites etc, told me that php is "all in the browser", but I thought if I could scroll the page, I could practically put endless number or windows, tables, inputs, labels, buttons...

And replace the GUI with a giant offline webpage.

But no idea, it's too complicated anyway. 

I underestimated programming quite alot.

I rock at maths and physics, but this is much more, and I become an emo kid when something trivial is blocking me.

 

But now I have an idea, which could be 10 times easier to make for a person like myself.

I could make a GUI with scrollbars that could have size, let's say: 1800 pixels horizontal and 10 000 pixels vertical, to avoid loops which are in looping loops, and all inside a loop.

The warehouse, inputs, etc, etc, etc could be all in 1 GUI. 

Would that be too demanding for processors nowadays? With colors, fonts...

Edited by CroatianPig

YES, I know I ask facepalm questions.

YES, I know you asked the God why I had to register to the forum where normal people are.

YES, I know everything!

Link to comment
Share on other sites

And for a problem that seemed simple at a first sight, people are very kind here to help you; this topic has nonetheless reached 6 pages.

 

Yes, I have only best words for everyone here, 10 people or so helped alot.

As I said, I would never blame anyone else for my own fails.

YES, I know I ask facepalm questions.

YES, I know you asked the God why I had to register to the forum where normal people are.

YES, I know everything!

Link to comment
Share on other sites

 

Here is the example I made for managing multiple GUIs:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
 
Example()
 
Func Example()
    ; Create a GUI.
    Local $hGUI1 = GUICreate("Example GUI1")
    ; Create a button.
    Local $iButton1 = GUICtrlCreateButton("Button1", 10, 10, 80, 22)
    ; Display the GUI
    GUISetState(@SW_SHOW, $hGUI1)
 
    ; Create a GUI.
    Local $hGUI2 = GUICreate("Example GUI2", 300, 300)
    ; Create a button.
    Local $iButton2 = GUICtrlCreateButton("Button2", 10, 10, 80, 22)
    ; Display the GUI
    GUISetState(@SW_SHOW, $hGUI2)
 
    ; Initialize a Local variable.
    Local $aMsg = 0
 
    While 1
        ; Assign to $aMsg the advanced GUI messages.
        $aMsg = GUIGetMsg(1)
 
        ; Switch from GUIs
        Switch $aMsg[1]
            Case $hGUI1
                ; The event comes from the GUI1
 
                ; Switch from event ID
                Switch $aMsg[0]
                    Case $GUI_EVENT_CLOSE
                        ExitLoop
                    Case $iButton1
                        MsgBox($MB_SYSTEMMODAL, "", "Button1 clicked.")
                EndSwitch
            Case $hGUI2
                ; The event comes from the GUI2
 
                ; Switch from event ID
                Switch $aMsg[0]
                    Case $GUI_EVENT_CLOSE
                        GUIDelete($hGUI2)
                    Case $iButton2
                        MsgBox($MB_SYSTEMMODAL, "", "Button2 clicked.")
                EndSwitch
        EndSwitch
 
        ; Avoid high CPU usage.
        Sleep(10)
    WEnd
 
    ; Delete the previous GUIs and all controls.
    GUIDelete($hGUI1)
EndFunc   ;==>Example
Br, FireFox.

 

 

Is this from some link?

I found this yesterday, but as I said, for 3 GUI-s, complete different story than 2.

http://www.autoitscript.com/wiki/Managing_Multiple_GUIs

Edited by CroatianPig

YES, I know I ask facepalm questions.

YES, I know you asked the God why I had to register to the forum where normal people are.

YES, I know everything!

Link to comment
Share on other sites

For web design it's HTML and CSS, not PHP.

 

I missunderstood then.

Btw, is it ok and polite to talk about other programs and programming languages, because this is an official AutoIt forum?

I ask because I started it by asking something, but don't know if it's ok...

Edited by CroatianPig

YES, I know I ask facepalm questions.

YES, I know you asked the God why I had to register to the forum where normal people are.

YES, I know everything!

Link to comment
Share on other sites

Is this from some link?

No, and these examples are not "perfect" to be added to the helpfile.

Btw, is it ok and polite to talk about other programs and programming languages, because this is an official AutoIt forum?

I ask because I started it by asking something, but don't know if it's ok...

Dunno...

Link to comment
Share on other sites

So, can you tell me, what's actually wrong with this scipt I made?

Is it one or more mistakes?

I did every step for 3 times, and the previous script I made the exact same way, worked !

How???

Btw, I deleted everything half an hour ago, because I was mad like 100 devils.

I must install the program again, and write it all over again.

Great...

Btw, do you sometimes explode totally because of programming?

Edited by CroatianPig

YES, I know I ask facepalm questions.

YES, I know you asked the God why I had to register to the forum where normal people are.

YES, I know everything!

Link to comment
Share on other sites

So, can you tell me, what's actually wrong with this scipt I made?

 

Is it one or more mistakes?

Look the difference between my example and the latest script you posted.

Hint: GUIGetMsg() <> GUIGetMsg(1), and of course what's following.

Btw, do you sometimes explode totally because of programming?

No :)
Link to comment
Share on other sites

Look the difference between my example and the latest script you posted.

Hint: GUIGetMsg() <> GUIGetMsg(1), and of course what's following.

 

I can't actually start it... 

Error: can't open include file <MsgBoxConstants.au3>

And $MB_SYSTEMMODAL not decleared as variable...

P.S. I will write that script again, and put it later. If possible, tell me which exact line has a mistake.

Ty, laterzzz

Edited by CroatianPig

YES, I know I ask facepalm questions.

YES, I know you asked the God why I had to register to the forum where normal people are.

YES, I know everything!

Link to comment
Share on other sites

You need the latest beta to run my example.

Where is the mistake? It's the whole while. You're not using the GUIGetMsg function correctly.

 

What beta? Link please. I got newest autoit..........

P.S. Found but.... Note: The beta can be unstable – always check the forums. oO

 

Ok, got it working. Should I always write code in beta?

And your both GUI-s open at once on start... I need to open 2. and 3. if certain buttons are pressed :(

Edited by CroatianPig

YES, I know I ask facepalm questions.

YES, I know you asked the God why I had to register to the forum where normal people are.

YES, I know everything!

Link to comment
Share on other sites

The beta can be unstable – always check the forums

The functions used in the examples are not concerned by this warning, it's only for new features that you are not aware of.

 

And your both GUI-s open at once on start... I need to open 2. and 3. if certain buttons are pressed :(

Manage when you need to show your GUIs with the GUISetState function ;)

Br, FireFox.

Link to comment
Share on other sites

Manage when you need to show your GUIs with the GUISetState function ;)

Br, FireFox.

 

Ok, I see I will have to learn what arrays are, and how they work.

What's the minimum number of GUI-s that would require GUISetState with array?

Edano did on the first page a script with 2 GUI-s, but no arrays.

Means 3 require an array?

YES, I know I ask facepalm questions.

YES, I know you asked the God why I had to register to the forum where normal people are.

YES, I know everything!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...