Jump to content

GUI beginner attempt, cash register


Recommended Posts

Good Luck, please consider my suggestion to read the gui management sections of the Help file.  It would be worthwhile to spend an hour going through either piece of code and making sure that you understand what each statement is doing.

kylomas

 

I am using it much, it is very helpfull, but it doesn't help about some things...

For example, this line:

guisetfont(12,400,-1,'Comic Sans MS')

I don't get that "-1"... In the help file, it says only about italic and underlined...

And the next message about the same thing:

guictrlsetfont(-1,14,800)

Do you actually "call" that "-1" mentioned before? Is it only a designation for a certain font you decleared prior? If yes, does it call for font 12, weight 400, attribute (code??) -1, and Comic sans MS?

Another thing there is no help when I click on it, and press F1 is:

guictrlcreateedit('',230,50,660,200,BitOr($ws_hscroll,$es_readonly))

But I think I understood something: ws_hscroll = horizontal scroll?

But what is the second part: es_readonly, and what are the abbreviations "ws" and "es"?

So complicated ^^

P.S. Fixed that "track root" of course, I get a GUI with destinations and details.

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 first -1 (in font) means: no change on this param
 
the other -1 refers to the last created control

 

guisetfont = font for all controls in a gui

guictrlsetfont = font for one single control, overriding guisetfont

 

es_ = edit style
ws_ = window style
 
but those are not important to know

Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
Share on other sites

Edano,

I've been trying to understand something about this script you made and I learned much from it:

GUICreate ("Articles", 975, 635, 500, 100) ;==> draws GUI
GUISetFont (20, 400, "", "Comic Sans MS")
Global $ware[18]
For $j=0 To 2
    For $i=0 To 5
        $ware[$j*6+$i]=GUICtrlCreateButton ("Product "&$i+1+$j*6, 5+255*$j, 5+105*$i, 250, 100)
    Next
Next
$Finish =    GUICtrlCreateButton  ("Finish", 770, 5, 200, 625)

GUISetState()  ;==> shows GUI

While 1
    $msg = GUIGetMsg()  ;==> proves GUI
    For $i=0 To 17
        If $msg=$ware[$i] Then _EvaluateQuantity($i)
    Next
    If $msg = $Finish Or $msg=-3 Then Exit
WEnd



;\\\\\\\\\\\\\\\\\\\\\\\\\\\\ FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Func _EvaluateQuantity($button)
    Local $product=GUICtrlRead($ware[$button])
    Local $quantity = InputBox ("", "Quantity of "&$product&":", "", "", 500, 250, 500, 200, "", "")
    Local $ans = MsgBox (4,"","You chose an article: " & $product & ", and quantity: " & $quantity)
EndFunc

Does that script actually "remember" which products I choose and what the quantity is?

Because I've been trying to set a task about this line:

If $msg = $Finish Or $msg=-3 Then Exit

and I tried to add: & Run ("Notepad.exe"), but nothing works. I even put the next line:

Run ("Notepad.exe")

and something non-good happened... It opened I think several hundred notepad new docs, PC went slow, and had to restart...

How should I add it so it opens notepad (faster than MS Word for testing), and make it print all the products and quantities, each in one line, lets say?

I am familiar with basic commands like "Send" ({"ENTER 5"}) or so, "Winwaitactive", "Run", etc...

If possible, don't write the script, and just give me a hint of what commands you would use so I try to figure it out a bit.

And if you will update the script and write, please put intentionaly some mistakes, so I can think about it and how to fix it, because you always help generously.

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 if you will update the script and write, please put intentionaly some mistakes, so I can think about it and how to fix it.

.

LOL. it's vice versa imo :)

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
Share on other sites

no, the script does not store anything. i just helped you to fix the GUI. i did not add anything. you have to think how to store it. variables store values.

notepad opened without ending because you are in a LOOP. BASIC: better use messageboxes to check the effects of what you do.

i am not sure why you want to use notepad, but you could instead use GUICtrlCreateEdit for example. or a label.

and try to understand what $msg and GUIGetMsg() means.

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
Share on other sites

no, the script does not store anything. i just helped you to fix the GUI. i did not add anything. you have to think how to store it. variables store values.

notepad opened without ending because you are in a LOOP. BASIC: better use messageboxes to check the effects of what you do.

i am not sure why you want to use notepad, but you could instead use GUICtrlCreateEdit for example. or a label.

and try to understand what $msg and GUIGetMsg() means.

 

It's coz I need to print out bills and so they can be saved (I was thinking a MS Word doc file is the best), and it seems best in making a MS Word template, which I then fill with "unique" information.

Information such as: "number of bill", "date of bill", and certain product or a service with a certain quantity, and I thought it's the easiest to code the script to open MS word at the end.

After opening, it automatically uses scripted combination of keys like "enter", "down", "tab", "space", etc... to get to a specific place where, let's say, date must be enterered, and it offers me a new pop-up of the date (I'm giving examples only).

After, let's say that, it goes to a place in that document, where all the products and their quantities must be entered, and it just pastes recorded things I clicked on the beginning, using our starting GUI.

Another thing that makes me curious, and I'm sure that it can be coded on many ways in autoit, is that prices and quantities must be typed always with 2 decimal numbers, because of the fact that we the same currency type like, USA or EU, or I think, most of the countries.

I mean, we have to type a price like, let's say, coffee with cream is 2,60 dollars (2 dollars and 60 cents).

P.S. I hope you understand what I typed, and if not, please ask.

P.S.S.  The thing you mentioned last... Is it printable and sendable, using e-mail? 

 

Oh yes, and would it be possible to somehow record every bill automatically, so it automatically adds the number of bill +1 every time, and if possible remembering when turning off pc?

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

yes, all that you ask is possible. but you will need some time to understand and code it all. surely some months.

 

No problem, I'm starting to love it seriously.

How would you advise me to learn best? Watch tutorials on youtube? Find random scripts on the internet and try to understand? Write same scripts several times to understand everything and remember all the commands etc?

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

No problem, I'm starting to love it seriously.

How would you advise me to learn best? Watch tutorials on youtube? Find random scripts on the internet and try to understand? Write same scripts several times to understand everything and remember all the commands etc?

.

take example scripts (the helpfile is full of examples), analyze them until you understand. work thru this to get the basic ideas.

do your own codes step by step and begin with the easiest part first. use messageboxes for debugging. i use them always.

i see lots of people coming here and wanting too much, they think they can learn complex GDI graphics in some minutes, but it takes time to understand the logic. get used to the expressions and syntax. it is like learning a - spoken - language.

Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
Share on other sites

i see lots of people coming here and wanting too much, they think they can learn complex GDI graphics in some minutes, but it takes time to understand the logic. get used to the expressions and syntax. it is like learning a - spoken - language.

 

 

Yes, I know those kind of people too, but I'm seriously not one of them. I already said on the previous page that I consider all those of you who replied to me, as smart and creative, and I'm aware it will take a long time to learn things.

do your own codes step by step and begin with the easiest part first. use messageboxes for debugging. i use them always.

 

 

I don't understand what you mean.

I mean, I know what Msgbox is, like "Hello world", etc.

But how does it do debugging?

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 can use MsgBox debugging like this:

#include <Constants.au3>

_myFunction()

If @error Then
  MsgBox($IDOK, "_myTestScript", "@error: " & @error)
EndIf

Func _myFunction()
  Return SetError(10101010, 0, False)
EndFunc

Or like this:

#include <Constants.au3>

Global Const $myVariable = _myFunction()

If Not $myVariable Then
  MsgBox($IDOK, "_myTestScript", "_myFunction() returned: " & $myVariable)
EndIf

Func _myFunction()
  Return SetError(10101010, 0, False)
EndFunc
Link to comment
Share on other sites

 

 

I've been away for a few days, a man must earn for his bread and water.

I have 2 questions about this script I have been doing:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.8.1
 Author:         Croatian Pig

 Script Function:
    Template AutoIt script.
"{}"
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

GUICreate ("Articles", 975, 635, 500, 100) ;==> draws GUI
Local $font
$font = "Comic Sans MS"
GUISetFont (25, 400, "", $font)
$ware_1 =  GUICtrlCreateButton  ("Product 1" ,   5,   5, 250, 100)
$ware_2 =  GUICtrlCreateButton  ("Product 2" ,   5, 110, 250, 100)
$ware_3 =  GUICtrlCreateButton  ("Product 3" ,   5, 215, 250, 100)
$ware_4 =  GUICtrlCreateButton  ("Product 4" ,   5, 320, 250, 100)
$ware_5 =  GUICtrlCreateButton  ("Product 5" ,   5, 425, 250, 100)
$ware_6 =  GUICtrlCreateButton  ("Product 6" ,   5, 530, 250, 100)
$ware_7 =  GUICtrlCreateButton  ("Product 7" , 260,   5, 250, 100)
$ware_8 =  GUICtrlCreateButton  ("Product 8" , 260, 110, 250, 100)
$ware_9 =  GUICtrlCreateButton  ("Product 9" , 260, 215, 250, 100)
$ware_10 = GUICtrlCreateButton  ("Product 10", 260, 320, 250, 100)
$ware_11 = GUICtrlCreateButton  ("Product 11", 260, 425, 250, 100)
$ware_12 = GUICtrlCreateButton  ("Product 12", 260, 530, 250, 100)
$ware_13 = GUICtrlCreateButton  ("Product 13", 515,   5, 250, 100)
$ware_14 = GUICtrlCreateButton  ("Product 14", 515, 110, 250, 100)
$ware_15 = GUICtrlCreateButton  ("Product 15", 515, 215, 250, 100)
$ware_16 = GUICtrlCreateButton  ("Product 16", 515, 320, 250, 100)
$ware_17 = GUICtrlCreateButton  ("Product 17", 515, 425, 250, 100)
$ware_18 = GUICtrlCreateButton  ("Product 18", 515, 530, 250, 100)
$Finish =  GUICtrlCreateButton  ("Finish"    , 770,   5, 200, 625)
GUISetState()  ;==> shows GUI
while 1
    $msg = GUIGetMsg()  ;==> proves GUI
    select
        case $msg = $ware_1
            GUICreate ("Quantity", 960, 540, 480, 270) ;==> draws GUI
            local $input_1   =  guictrlcreateinput("Enter quantity", 20, 280, 920, 240)
                                guictrlsetlimit(-1,10)
                                guictrlsetfont(-1,60,800)
                                guictrlcreatelabel("Quantity:", 20, 20, 450, 240)
                                guictrlsetfont(-1,60,800)
                                guictrlcreatebutton ("OK", 490, 20, 450, 240)
                                guictrlsetfont(-1,60,800)
                                GUICtrlSetBkColor(-1,0x00ffff)
            GUISetState()  ;==> shows GUI





        case $msg = $Finish
            Run ("C:\Program Files (x86)\OpenOffice.org 3\program\swriter.exe")
            WinWaitActive ("Untitled 1 - OpenOffice.org Writer")
            Send ("Product 1 " & "Quantity " & $input_1)
            Exit
        case $msg = -3 ; 3 = little cross (close)




    EndSelect
WEnd

So, when you run it, and you choose product 1, and new gui appears, and when I click finish (on the previous gui, behind it), why does it give me number 22 as quantity?

And 2., I would like a hint only (so I learn best + I don't annoy you)... How to continue 2. gui? 

I mean, how to make it "if press OK (I will make CANCEL later also and it should close gui 2 and return me to gui 1) then remember the value of product 1, close gui 2, and return to gui 1 so I can choose more products which would be all typed at the end in open office writter"?

I hope it's understandable what I typed...

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

1.) because $input_1 has the control_ID 22.

btw, i don't have open office writer, resp. i have it, but in a different location, your script is not reproducable. try to use messageboxes instead.

2) make all guis at the beginning of the script, and then show/hide them when you need them. don't make guis in loops, unless it is necessary. this will end up in a desktop full of guis .... :)

3.) why did you remove the $ware array i gave you ? that is much easier to handle.

4.) use the 'Default' keyword for positioning the gui, then it gets centered automatically.

Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
Share on other sites

1.) because $input_1 has the control_ID 22.

Is it by default? And how to change it to, let's say, number 21?

 

btw, i don't have open office writer, resp. i have it, but in a different location, your script is not reproducable. try to use messageboxes instead.

I realised I just can't understand that msgbox at the moment or I maybe I never will (I know how to use it and put parameters to display a certain message, but can't understand that

debugging and the things, that several of you advised me to use as help). Show me please what you mean, for this problem specifically, about the open office.

 

2) make all guis at the beginning of the script, and then show/hide them when you need them. don't make guis in loops, unless it is necessary. this will end up in a desktop full of guis ....  :)

 

Ok, thank you, I will try that, but if I put all gui parameters on the beginning and have 3 lines to start gui-s, it will open all 3.

Instead of that, in this case, I need the 2. gui to be displayed when the quantity needs to be entered, ie. after choosing some product.

Is there a way to "name" them, and call for them at specific location?

3.) why did you remove the $ware array i gave you ? that is much easier to handle.

 

I didn't remove it, it's saved as another script, I studied it alot and understood many things you did there (matrixes style etc.), but it seems far too complicated for me at this time to edit

and acchieve what I'm trying on this script. At the moment. 

4.) use the 'Default' keyword for positioning the gui, then it gets centered automatically.

 

Ok, I will try.

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

heyhey. you did not think much. :(

1. you write

.

Send ("Product 1 " & "Quantity " & $input_1)

.

make a msgbox before. Msgbox(0,"",$input_1). why is it always 22 ? because it is the 22nd control. $input_1 = 22.

and now think what would be the right way to obtain the value of the control that has been typed in $input_1 ...... use helpfile for guictrlcreateinput.

.

2. yes hou have to assign variables for the guis. so what ? do that. and no, they won't open all 3.
they will only open (and close again) on GuiSetState() and use the helpfile.

.

look at GUISetState() what does it do ? look GuiCreate()

3. i gave you a lot of hints. please use the links. study all the instructions and example, or you will never advance. you have to understand what every command means.

edit don't know why the editor messes my post. can't get rid of the formatting. seems to be an invisible quote tag.

Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
Share on other sites

heyhey. you did not think much. :(

1. you write

.

Send ("Product 1 " & "Quantity " & $input_1)

.

make a msgbox before. Msgbox(0,"",$input_1). why is it always 22 ? because it is the 22nd control. $input_1 = 22.

and now think what would be the right way to obtain the value of the control that has been typed in $input_1 ...... use helpfile for guictrlcreateinput.

.

2. yes hou have to assign variables for the guis. so what ? do that. and no, they won't open all 3.
they will only open (and close again) on GuiSetState() and use the helpfile.

.

look at GUISetState() what does it do ? look GuiCreate()

3. i gave you a lot of hints. please use the links. study all the instructions and example, or you will never advance. you have to understand what every command means.

 

look at GUISetState() what does it do ? look GuiCreate()

 

I will and I'm trying my best.

 

These days we are busy like hell all days long.

 

I know I annoy you (mostly you, because you always help) with weird questions, but in 3 weeks or so, I will have the time to focus 24/7 on autoit.

 

I just hope I'm not too stupid to understand all those types of loops, functions, etc.

 

Anyway, you have free one of the apartments in case you wanna come, you can bring 2 friends or a girlfriend (or 2 girlfriends). 

 

20 minutes drive from here, you get here: 

 

http://ronim.jalbum.net/Zlatni%20rat%20Beach/slides/zlatni-rat-air-3.jpg

 

Now I go try to get few more lines in that script.

 

Knowing myself, I will be here in a few hours, crying again...

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

:) no you don't annoy me. i like your simple cashier concept and you obviously designed it for a touch screen. somehow i am interested to get it going.

thanx for the invitation, i will bookmark it. i've never been to croatia. tho i don't have girlfriends (for you ? ;)), but a sweet family.

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
Share on other sites

:) no you don't annoy me. i like your simple cashier concept and you obviously designed it for a touch screen. somehow i am interested to get it going.

thanx for the invitation, i will bookmark it. i've never been to croatia. tho i don't have girlfriends (for you ? ;)), but a sweet family.

 

Yes, touch screens, exactly, or even better, if it's possible ( !!!), by voice recognition maybe, so mouse or keyboard is not needed actually once the program is started.

So, I digged something, and I was just working.

I was here: http://www.autoitscript.com/wiki/Managing_Multiple_GUIs , 

and I tried to implement that script on the script I'm trying to make.

I realised I learned more in the last hour than a whole week before. 

So, now my script looks like this (I will make it more detailed and to look more nicely, because this looks like a heap of junk):

#include <GUIConstantsEx.au3>

 gui1()

 Func gui1()
    $GUI_1  = GUICreate ("Articles", 975, 635, 500, 100) ;==> draws GUI
    Local $font
    $font   =  "Comic Sans MS"
    $GUI_1  =  GUISetFont (25, 400, "", $font)
    $ware_1 =  GUICtrlCreateButton  ("Product 1" ,   5,   5, 250, 100)
    $ware_2 =  GUICtrlCreateButton  ("Product 2" ,   5, 110, 250, 100)
    $ware_3 =  GUICtrlCreateButton  ("Product 3" ,   5, 215, 250, 100)
    $ware_4 =  GUICtrlCreateButton  ("Product 4" ,   5, 320, 250, 100)
    $ware_5 =  GUICtrlCreateButton  ("Product 5" ,   5, 425, 250, 100)
    $ware_6 =  GUICtrlCreateButton  ("Product 6" ,   5, 530, 250, 100)
    $ware_7 =  GUICtrlCreateButton  ("Product 7" , 260,   5, 250, 100)
    $ware_8 =  GUICtrlCreateButton  ("Product 8" , 260, 110, 250, 100)
    $ware_9 =  GUICtrlCreateButton  ("Product 9" , 260, 215, 250, 100)
    $ware_10 = GUICtrlCreateButton  ("Product 10", 260, 320, 250, 100)
    $ware_11 = GUICtrlCreateButton  ("Product 11", 260, 425, 250, 100)
    $ware_12 = GUICtrlCreateButton  ("Product 12", 260, 530, 250, 100)
    $ware_13 = GUICtrlCreateButton  ("Product 13", 515,   5, 250, 100)
    $ware_14 = GUICtrlCreateButton  ("Product 14", 515, 110, 250, 100)
    $ware_15 = GUICtrlCreateButton  ("Product 15", 515, 215, 250, 100)
    $ware_16 = GUICtrlCreateButton  ("Product 16", 515, 320, 250, 100)
    $ware_17 = GUICtrlCreateButton  ("Product 17", 515, 425, 250, 100)
    $ware_18 = GUICtrlCreateButton  ("Product 18", 515, 530, 250, 100)
    $Finish  = GUICtrlCreateButton  ("Finish"    , 770,   5, 200, 625)
    GUISetState()

    While 1
         Switch GUIGetMsg()
             Case $GUI_EVENT_CLOSE
                 ExitLoop
             Case $ware_1
                 ; Disable the first GUI
                 GUISetState(@SW_DISABLE, $GUI_1)
                 gui2()
                 ; Re-enable the first GUI
                 GUISetState(@SW_ENABLE, $GUI_1)
         EndSwitch
     WEnd
 EndFunc   ;==>gui1


Func gui2()
    $GUI_2    = GUICreate ("Quantity", 960, 540, 480, 270) ;==> draws GUI
    $input_1  = guictrlcreateinput("Enter quantity", 20, 280, 920, 240)
                guictrlsetlimit(-1,10)
                guictrlsetfont(-1,60,800)
                guictrlcreatelabel("Quantity:", 20, 20, 450, 240)
                guictrlsetfont(-1,60,800)
    $GUI_2_OK = guictrlcreatebutton ("OK", 490, 20, 450, 240)
                guictrlsetfont(-1,60,800)
                GUICtrlSetBkColor(-1,0x00ffff)
    GUISetState()

    While 1
        ; We can only get messages from the second GUI
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete($GUI_2)
                ExitLoop
            Case $GUI_2_OK or ("{ENTER}")
                MsgBox("", "Confirm quantity:", $input_1)

        EndSwitch
    WEnd
 EndFunc   ;==>gui2

I can't understand why it spamms that messagebox, instead of waiting for a "human" (it's Lord allmighty) to hit enter or click "OK".

On the link I put, I tried to implement the 2.

And their script works perfectly... No spamming... 

Also, please tell me if these 3 things are the same? I mean, does the program have equal respond if I don't align lines "the way they should be aligned"?

Case $GUI_2_OK or ("{ENTER}")
                MsgBox("", "Confirm quantity:", $input_1)


Case $GUI_2_OK or ("{ENTER}")
MsgBox("", "Confirm quantity:", $input_1)


Case $GUI_2_OK or ("{ENTER}")
                                            MsgBox("", "Confirm quantity:", $input_1)
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

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...