Sign in to follow this  
Followers 0
Edifice

Reacting to change in input fields?

15 posts in this topic

Hello

I have this program in which I need to calculate a price of something. This is easily done, however I don't want to calculate the price in the GUI, coz that would be a huge waste of CPU to calculate it 1000 times each second.

Is there some kind of method to know and react to change in dropdown menues?

Example:

User changes value of dropdown / writes own value in an input field. Then, and only then, will the function be called that does the calculating.

Share this post


Link to post
Share on other sites



typically when you use GuiGetMsg() the script does not react until something is done with a control.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Hello

I have this program in which I need to calculate a price of something. This is easily done, however I don't want to calculate the price in the GUI, coz that would be a huge waste of CPU to calculate it 1000 times each second.

Is there some kind of method to know and react to change in dropdown menues?

Example:

User changes value of dropdown / writes own value in an input field. Then, and only then, will the function be called that does the calculating.

If you mean a combo then search for CBN_DROPDOWN.

To detect when the text in an edit is changed search for EN_CHANGE and maybe EN_KILLFOCUS to know when the user exits the edit.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

If you mean a combo then search for CBN_DROPDOWN.

To detect when the text in an edit is changed search for EN_CHANGE and maybe EN_KILLFOCUS to know when the user exits the edit.

So my link should work then as it checks for the EN_CHANGE :D Thats good to know, thanks martin.

Share this post


Link to post
Share on other sites

typically when you use GuiGetMsg() the script does not react until something is done with a control.

This worked really well. Thanks :D

Anyway, I wondered if you, or someone else for that matter, knew why is piece of code is not putting data into my input field?

Case $nMsg = $combo_work1
                Select
                    Case $combo_work1 = "Udføres"
                    Case $combo_work1 = "Værkstedstime"
                        GUICtrlSetData($input_itemprice1, "450")
                    Case $combo_work1 = "Testbegyr"
                        GUICtrlSetData($input_itemprice1, "375")
                    Case $combo_work1 = "Kort test"
                        GUICtrlSetData($input_itemprice1, "125")
                EndSelect
                GUICtrlSetData($input_price1, Int(GUICtrlRead($input_itemprice1, 1) * GUICtrlRead($input_quantity1, 1)))

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This worked really well. Thanks :D

Anyway, I wondered if you, or someone else for that matter, knew why is piece of code is not putting data into my input field?

Case $nMsg = $combo_work1
                Select
                    Case $combo_work1 = "Udføres"
                    Case $combo_work1 = "Værkstedstime"
                        GUICtrlSetData($input_itemprice1, "450")
                    Case $combo_work1 = "Testbegyr"
                        GUICtrlSetData($input_itemprice1, "375")
                    Case $combo_work1 = "Kort test"
                        GUICtrlSetData($input_itemprice1, "125")
                EndSelect
                GUICtrlSetData($input_price1, Int(GUICtrlRead($input_itemprice1, 1) * GUICtrlRead($input_quantity1, 1)))

Your

Case $combo_work1 = "Udføres"

should probably be

Case GuiCtrlRead($combo_work1) = "Udføres"

etc

Also, although it won't cause a problem, there is no advanced option for GuiCtrlRead with edits or inputs.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Now I got the part with the combo's working. Just hate it when I stare at something for so long I completely miss the obvious error I made :D

Anyway, The GUIGetMsg () approach only got me half of the way - it works great with combo's, except when you write something in them instead of selecting something. And also, it doesn't work at all with regular input fields.

Here's the code, try the tab called "Prisoverslag - beta" and you'll properly see what I'm trying to achieve.

Hope somebody has the magic trick :huggles: - btw if you don't have the "printMGv2.au3" file just comment it out. It's only used for printing.

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Date.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <array.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include 'printMGv2.au3';the print UDF for printing using printmg.dll

Global Const $CBS_DROPDOWNLIST = 0x0003, $RED = 0x0000ff, $GREEN = 0x00ff00, $BLUE = 0xff0000, $BLACK = 0x000000
Dim $app_name = "Indlevering"
Dim $client = "ADD-Data "
Dim $colors = "Sort|Hvid|Grå|Sølv|Orange|Rød|Gul|Grøn|Blå|Lilla"
Dim $brands = "ADD-Data|Gigabyte|Asus|MSI|Toshiba|Clevo|HP|Shuttle|Aopen|Calvin|Acer|Packard Bell|Samsung|Lenovo|IBM|NZXT|Antec|Apevia|Western Digital"
Dim $worktypes = "Værkstedstime|Testbegyr|Kort test|"
Dim $pris_arbejdstime = "450"
Dim $pris_testgebyr = "375"
Dim $pris_korttest = "125"

Dim $row1 = 30
Dim $row2 = $row1 + 30
Dim $row3 = $row2 + 30
Dim $row4 = $row3 + 30
Dim $row5 = $row4 + 30
Dim $rowheight = 20
Dim $colom1 = 20
Dim $colom2 = $colom1 + 120
Dim $colom3 = $colom2 + 120
Dim $colom4 = $colom3 + 120
Dim $smallcolom1 = 30
Dim $smallcolom2 = $smallcolom1 + 80
Dim $smallcolom3 = $smallcolom2 + 80
Dim $smallcolom4 = $smallcolom3 + 80
Dim $smallcolom5 = $smallcolom4 + 80
Dim $smallcolom6 = $smallcolom5 + 80
Dim $smallcolom7 = $smallcolom6 + 80
Dim $colomwidth = 110
Dim $smallwidth = 70

HotKeySet("{F9}", "iniprint")
HotKeySet("{F11}", "clearfields")


$mainGUI = GUICreate ($client & $app_name, 500, 450) ; Creates the GUI

    $clearfields    = GUICtrlCreateButton("Ryd alle felter", 140, 420, 100, 25)
    $button_print       = GUICtrlCreateButton("Udskriv", 260, 420, 100, 25)

$label_modtager     = GUICtrlCreateLabel("Modtager: ",              10,     33,     100,    20,     2)
$combo_modtager     = GUICtrlCreateCombo("Alf",                     110,    30,     70,     20,     0x0103)         ; create first item
GUICtrlSetData($combo_modtager, "Claus|Lasse|Per|Jacob|Toke") ; add other item
$label_navn         = GUICtrlCreateLabel("Navn:  ",                 10,     58,     100,    20,     2)
$input_name         = GUICtrlCreateInput("",                        110,    55,     300,    20,     0)
$label_tlfnr        = GUICtrlCreateLabel("Telefonnummer:  ",        10,     83,     100,    20,     2)
$input_phonenumber  = GUICtrlCreateInput("",                        110,    80,     150,    20,     0x2000)
$input_other        = GUICtrlCreateInput("",                        270,    80,     140,    20,     0)
$label_indleveret   = GUICtrlCreateLabel("Indleveret produkt:  ",   10,     108,    100,    20,     2)
$combo_indleveret   = GUICtrlCreateCombo("Almindelig PC",           110,    105,    170,    20,     $CBS_DROPDOWNLIST)      ; create first item
GUICtrlSetData($combo_indleveret, "Laptop|Hardware|Andet")                                                                  ; add other item snd set a new default
$chkbx_garanti      = GUICtrlCreateCheckbox("Garantireperation",    10,     130,    100,    20)
$combo_faknr        = GUICtrlCreateCombo("Faktura nr.",                 110,    130,    100,    20, 2)                          ; create first item
GUICtrlSetData($combo_faknr, "Ukendt")


$hindleveret = GUICreate ("", 500, 180, 0, 180, $WS_POPUP, $WS_EX_MDICHILD, $mainGUI)
    $hSubTabs = GUICtrlCreateTab (0, 0, 500, 280)
    $hSubTabPage1 = GUICtrlCreateTabItem ("Beskrivelse")
        $combo_color1       = GUICtrlCreateCombo("Farve 1",             $colom1,    $row2,  $colomwidth,    $rowheight, 0x0102)     ; create first item
        GUICtrlSetData($combo_color1, $colors)                                                                              ; add other items
        $combo_color2       = GUICtrlCreateCombo("Farve 2",             $colom2,    $row2,  $colomwidth,    $rowheight, 0x0102)     ; create first item
        GUICtrlSetData($combo_color2, $colors)                                                                              ; add other items
        $combo_color3       = GUICtrlCreateCombo("Farve 3",             $colom3,    $row2,  $colomwidth,    $rowheight, 0x0102)     ; create first item
        GUICtrlSetData($combo_color3, $colors)                                                                              ; add other items
        $combo_color4       = GUICtrlCreateCombo("Farve 4",             $colom4,    $row2,  $colomwidth,    $rowheight, 0x0102)     ; create first item
        GUICtrlSetData($combo_color4, $colors)                                                                              ; add other items
        $combo_brand    = GUICtrlCreateCombo("Mærke",                  $colom1,      $row1, $colomwidth, $rowheight, 0x0102)   ; create first item
        GUICtrlSetData($combo_brand, $brands)                                                                               ; add other items
        $diversebskrvls = GUICtrlCreateInput("",                    $colom1, $row3, 470, $rowheight)
    $hSubTabPage2 = GUICtrlCreateTabItem ("Tilbehør")
        $recoverymedier = GUICtrlCreateCheckbox("Recovery Medier",  $colom1, $row1, $colomwidth, $rowheight)
        $PSU            = GUICtrlCreateCheckbox("Strømforsyning",  $colom2, $row1, $colomwidth, $rowheight)
        $taske          = GUICtrlCreateCheckbox("Taske",            $colom3, $row1, $colomwidth, $rowheight)
        $memorystick    = GUICtrlCreateCheckbox("Memorystick",      $colom4, $row1, $colomwidth, $rowheight)
        $eksternhdd     = GUICtrlCreateCheckbox("Ekstern Harddisk", $colom1, $row2, $colomwidth, $rowheight)
        $eksterndvdrw   = GUICtrlCreateCheckbox("Ekstern DVD/RW",   $colom2, $row2, $colomwidth, $rowheight)
        $manual         = GUICtrlCreateCheckbox("Manual",           $colom3, $row2, $colomwidth, $rowheight)
        $3gmodem        = GUICtrlCreateCheckbox("3G Modem",         $colom4, $row2, $colomwidth, $rowheight)
        $diversetlbhr   = GUICtrlCreateInput("",                    $colom1, $row3, 470, $rowheight)
    $hSubTabPage3 = GUICtrlCreateTabItem ("Fejlbeskrivelse")
        $fejlbeskrivelse = GUICtrlCreateInput("",                   $colom1, $row1, 470, $rowheight)
    $hSubTabPage4 = GUICtrlCreateTabItem ("Prisoverslag - Beta")
        $lbl_done = GUICtrlCreateLabel("udføres",                      $colom1,    $row1+15,$colomwidth,   $rowheight, 0x01)
        $combo_work1        = GUICtrlCreateCombo("Udføres",            $colom1,    $row2,  $colomwidth,    $rowheight, 0x0102)     ; create first item
        GUICtrlSetData($combo_work1, $worktypes)                                                                                    ; add other items
        $combo_work2        = GUICtrlCreateCombo("Udføres",            $colom1,    $row3,  $colomwidth,    $rowheight, 0x0102)     ; create first item
        GUICtrlSetData($combo_work2, $worktypes)                                                                                    ; add other items
        $combo_work3        = GUICtrlCreateCombo("Udføres",            $colom1,    $row4,  $colomwidth,    $rowheight, 0x0102)     ; create first item
        GUICtrlSetData($combo_work3, $worktypes)                                                                                    ; add other items
        $lbl_antal = GUICtrlCreateLabel("Antal",                        $colom2,    $row1+15,$colomwidth,   $rowheight, 0x01)
        $input_quantity1    = GUICtrlCreateInput("",                    $colom2,    $row2,  $colomwidth,    $rowheight, 0x2000) 
        $input_quantity2    = GUICtrlCreateInput("",                    $colom2,    $row3,  $colomwidth,    $rowheight, 0x2000) 
        $input_quantity3    = GUICtrlCreateInput("",                    $colom2,    $row4,  $colomwidth,    $rowheight, 0x2000) 
        $input_price1 = GUICtrlCreateInput("",                          $colom4,    $row2,  $colomwidth,    $rowheight, 0x2800)
        $input_price2 = GUICtrlCreateInput("",                          $colom4,    $row3,  $colomwidth,    $rowheight, 0x2800)
        $input_price3 = GUICtrlCreateInput("",                          $colom4,    $row4,  $colomwidth,    $rowheight, 0x2800)
        $lbl_af = GUICtrlCreateLabel("Stykpris",                        $colom3,    $row1+15,$colomwidth,   $rowheight, 0x01)
        $input_total = GUICtrlCreateInput("",                           $colom4,    $row5,  $colomwidth,    $rowheight, 0x2800)
        $lbl_total = GUICtrlCreateLabel("Total:",                       $colom3,    $row5,  $colomwidth,    $rowheight, 0x0002)
        $input_itemprice1 = GUICtrlCreateInput("",                      $colom3,    $row2,  $colomwidth,    $rowheight, 0x2000)
        $input_itemprice2 = GUICtrlCreateInput("",                      $colom3,    $row3,  $colomwidth,    $rowheight, 0x2000)
        $input_itemprice3 = GUICtrlCreateInput("",                      $colom3,    $row4,  $colomwidth,    $rowheight, 0x2000)

;~ WinSetTrans($mainGUI,"",210)
;~ WinSetTrans($hindleveret,"",200)
GUISetState (@SW_SHOW, $mainGUI)
GUISetState (@SW_SHOW, $hindleveret)

Func clearfields()
    GUICtrlSetData($combo_modtager, "Alf")
    GUICtrlSetData($combo_indleveret, "Almindelig PC")
    GUICtrlSetData($combo_faknr, "Faktura nr.")
    GUICtrlSetData($combo_brand, "Mærke")
    GUICtrlSetData($combo_color1, "Farve 1")
    GUICtrlSetData($combo_color2, "Farve 2")
    GUICtrlSetData($combo_color3, "Farve 3")
    GUICtrlSetData($combo_color4, "Farve 4")
    GUICtrlSetData($input_name, "")     
    GUICtrlSetData($input_phonenumber, "")
    GUICtrlSetData($input_other, "")
    GUICtrlSetState($chkbx_garanti, $GUI_UNCHECKED)
    GUICtrlSetData($diversebskrvls, "")
    GUICtrlSetState($recoverymedier, $GUI_UNCHECKED)
    GUICtrlSetState($PSU, $GUI_UNCHECKED)
    GUICtrlSetState($taske, $GUI_UNCHECKED)
    GUICtrlSetState($memorystick,$GUI_UNCHECKED)
    GUICtrlSetState($eksternhdd, $GUI_UNCHECKED)    
    GUICtrlSetState($eksterndvdrw, $GUI_UNCHECKED)
    GUICtrlSetState($manual, $GUI_UNCHECKED)
    GUICtrlSetState($3gmodem    , $GUI_UNCHECKED)
    GUICtrlSetData($diversetlbhr, "")
    GUICtrlSetData($fejlbeskrivelse, "")
EndFunc

runprogram()

Func runprogram()
    While 1
    $nMsg = GUIGetMsg ()
        Select 
            Case $nMsg = $GUI_EVENT_CLOSE
                program_exit()
            Case $nMsg = $button_print
                iniprint()
            Case $nMsg = $clearfields
                clearfields()
            Case $nMsg = $combo_work1
                Select
                    Case GUICtrlRead($combo_work1) = "Værkstedstime"
                        GUICtrlSetData($input_itemprice1, $pris_arbejdstime)
                    Case GUICtrlRead($combo_work1) = "Testbegyr"
                        GUICtrlSetData($input_itemprice1, $pris_testgebyr)
                    Case GUICtrlRead($combo_work1) = "Kort test"
                        GUICtrlSetData($input_itemprice1, $pris_korttest)
                EndSelect
                GUICtrlSetData($input_price1, Int(GUICtrlRead($input_itemprice1, 1) * GUICtrlRead($input_quantity1, 1)))
                GUICtrlSetData($input_total, Int(GUICtrlRead($input_price1, 1) + GUICtrlRead($input_price2, 1) + GUICtrlRead($input_price3, 1)))
            Case $nMsg = $combo_work2
                Select
                    Case GUICtrlRead($combo_work2) = "Værkstedstime"
                        GUICtrlSetData($input_itemprice2, $pris_arbejdstime)
                    Case GUICtrlRead($combo_work2) = "Testbegyr"
                        GUICtrlSetData($input_itemprice2, $pris_testgebyr)
                    Case GUICtrlRead($combo_work2) = "Kort test"
                        GUICtrlSetData($input_itemprice2, $pris_korttest)
                EndSelect
                GUICtrlSetData($input_price2, Int(GUICtrlRead($input_itemprice2, 1) * GUICtrlRead($input_quantity2, 1)))
                GUICtrlSetData($input_total, Int(GUICtrlRead($input_price1, 1) + GUICtrlRead($input_price2, 1) + GUICtrlRead($input_price3, 1)))
            Case $nMsg = $combo_work3
                Select
                    Case GUICtrlRead($combo_work3) = "Værkstedstime"
                        GUICtrlSetData($input_itemprice3, $pris_arbejdstime)
                    Case GUICtrlRead($combo_work3) = "Testbegyr"
                        GUICtrlSetData($input_itemprice3, $pris_testgebyr)
                    Case GUICtrlRead($combo_work3) = "Kort test"
                        GUICtrlSetData($input_itemprice3, $pris_korttest)
                EndSelect
                GUICtrlSetData($input_price3, Int(GUICtrlRead($input_itemprice3, 1) * GUICtrlRead($input_quantity3, 1)))
                GUICtrlSetData($input_total, Int(GUICtrlRead($input_price1, 1) + GUICtrlRead($input_price2, 1) + GUICtrlRead($input_price3, 1)))
        EndSelect
    WEnd
EndFunc

Func iniprint()
    If GUICtrlRead($input_phonenumber) > 99999999 Or GUICtrlRead($input_phonenumber) < 20000000 Then
        MsgBox(0, "Fejl", "Telefonnummeret er ikke indtastet korrekt. Venligst udfyld telefonnummeret")
    Else
    print()
    EndIf
EndFunc

Func accesory()
    $accesory = ""
    If GUICtrlread($recoverymedier) = 1 Then
        $accesory = $accesory & "Recoverymedier, "
    EndIf
    If GUICtrlread($PSU) = 1 Then
        $accesory = $accesory & "Strømforsyning, "
    EndIf
    If GUICtrlread($taske) = 1 Then
        $accesory = $accesory & "Taske, "
    EndIf
    If GUICtrlread($memorystick) = 1 Then
        $accesory = $accesory & "Memorystick, "
    EndIf
    If GUICtrlread($eksternhdd) = 1 Then
        $accesory = $accesory & "Ekstern Harddisk, "
    EndIf
    If GUICtrlread($eksterndvdrw) = 1 Then
        $accesory = $accesory & "Ekstern DVD/RW, "
    EndIf
    If GUICtrlread($manual) = 1 Then
        $accesory = $accesory & "Manualer, "
    EndIf
    If GUICtrlread($3gmodem) = 1 Then
        $accesory = $accesory & "3G Modem, "
    EndIf
    Return($accesory)
EndFunc

Func color()
    $color = ""
    If GUICtrlRead($combo_color1, 1) = "Farve 1" OR GUICtrlRead($combo_color1, 1) = "" Then
    Else
        $color = $color & GUICtrlRead($combo_color1, 1) & ", "
    EndIf
    If GUICtrlRead($combo_color2, 1) = "Farve 2" OR GUICtrlRead($combo_color1, 1) = "" Then
        
    Else
        $color = $color & GUICtrlRead($combo_color2, 1) & ", "
    EndIf
    If GUICtrlRead($combo_color3, 1) = "Farve 3" OR GUICtrlRead($combo_color1, 1) = "" Then
        
    Else
        $color = $color & GUICtrlRead($combo_color3, 1) & ", "
    EndIf
    If GUICtrlRead($combo_color4, 1) = "Farve 4" OR GUICtrlRead($combo_color1, 1) = "" Then
        
    Else
        $color = $color & GUICtrlRead($combo_color4, 1)
    EndIf
    Return($color)
EndFunc

Func garanti()
    $garanti = ""
    If GUICtrlRead($chkbx_garanti) = 1 Then
        $garanti = "indenfor garanti"
    Else
        $garanti = "udenfor garanti"
    EndIf
    Return($garanti)
EndFunc

Func Print()
    Local $mmssgg,$marginx,$marginy
    Dim $currenty = 0
    Dim $currentx = 0
    local $header1 = 25
    local $header2 = 17
    local $header3 = 13
    local $body = 10
    local $leftmargin = 25
    local $rightmargin = 15
    local $topmargin = 15
    local $linespacing_small = 1.3
    local $linespacing_medium = 1.5
    
    Dim $startpoint = 1
    Dim $lenght = 90
    Dim $var = 0
    Dim $result2 = 1
    Dim $empty  = ""
    
    $hp = _PrintDllStart($mmssgg);this must always be called first
    if $hp = 0 then
        consolewrite("Error from dllstart = " & $mmssgg & @CRLF)
        Exit
    endif
    
    ;choose the printer if you don't want the default printer
    ;_PrintSetPrinter($hp);see also _PrinterSelectPrinter
    _PrintPageOrientation($hp,1);set ordinary printing
    _PrintStartPrint($hp)
    $pageheight = _PrintGetpageheight($hp) - _PrintGetYOffset($hp)
    $pagewidth = _PrintGetpageWidth($hp) - _PrintGetXOffset($hp)
    
    ; Print headline
    $currenty = $topmargin
    $currentx = $leftmargin
    _PrintSetFont($hp,'Tahoma',$header1,0,'')
    $text = "ADD-Data Indlevering"
    _PrintText($hp,$text, $currentx, $currenty)
    $textheight = _PrintGetTextHeight($hp,$text)
    $currenty = $currenty + $textheight

    ; Print line under headline
    $currentx = $currentx - 5
    $currenty = $currenty - 17
    _PrintSetLineWid($hp,2)
    _PrintSetLineCol($hp,$BLACK)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)
    $currentx = $leftmargin
        
    ;print "Modtaget af" in the top right corner
    _PrintSetFont($hp,'Tahoma',$header3,0,'')
    $currenty = $currenty - 6
    $text = "Modtaget af " & GUICtrlRead($combo_modtager, 1) & " d. " & @MDAY & "-" & @MON & "-" & @YEAR & " kl. " & @HOUR & ":" & @MIN
    $textwidth = _PrintGetTextWidth($hp,$text)
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, int($pagewidth - $textwidth - $rightmargin - 20), $currenty)
    
    ;Print "kunde informationer"
    $currenty = $currenty + int($textheight * $linespacing_medium)
    _PrintSetFont($hp,'Tahoma',$header2,0,'')
    $text = "Kunde information"
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty) 

    ;Print customer name
    $currenty = $currenty + int($textheight * $linespacing_small)
    $currentx = $currentx * 2
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    $text = "Navn: " & GUICtrlRead($input_name, 1)
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty)
    
    ;Print Contact information
    $currenty = $currenty + int($textheight * $linespacing_small)
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    $text = "Telefonnummer: " & GUICtrlRead($input_phonenumber, 1) & " Anden Kontakt: " & GUICtrlRead($input_other, 1)
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty)

    ;Print "Produkt informationer"
    $currenty = $currenty + int($textheight * $linespacing_medium)
    $currentx = $leftmargin
    _PrintSetFont($hp,'Tahoma',$header2,0,'')
    $text = "Produkt information"
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty) 

    ;Print customer name and waranty info
    $currenty = $currenty + int($textheight * $linespacing_small)
    $currentx = $currentx * 2
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    $text = "Indleveret: " & GUICtrlRead($combo_indleveret, 1) & " " & garanti()
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty)
    
    ;Print invoice ID
    $currenty = $currenty + int($textheight * $linespacing_small)
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    $text = "Faktura nr: " & GUICtrlRead($combo_faknr, 1)
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty)

    ;Print "beskrivelse"
    $currenty = $currenty + int($textheight * $linespacing_small)
    $currentx = $currentx + $leftmargin
    _PrintSetFont($hp,'Tahoma',$header3,0,'')
    $text = "Beskrivelse"
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty)

    ;Print brand
    $currenty = $currenty + int($textheight * $linespacing_medium)
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    $text = "Mærke: " & GUICtrlRead($combo_brand)
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty)

    ;Print color
    $currenty = $currenty + int($textheight * $linespacing_medium)
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    $text = "Farve: " & color()
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty)
    
    ;Print textfield beneth the colors
    $currenty = $currenty + int($textheight * $linespacing_small)
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    $text = GUICtrlRead($diversebskrvls, 1)
    
    $startpoint = 1
    $var = 0
    $result2 = 1
    
    while $result2 > 0
        $var = StringMid($text, $startpoint, $lenght)
        $result2 = Stringcompare($var, $empty, 2)       
        $startpoint = $startpoint + $lenght
        $textheight = _PrintGetTextHeight($hp,$text)
        _PrintText($hp,$var, $currentx, $currenty)
        $currenty = $currenty + int($textheight * $linespacing_small)
    WEnd
    
    ;Print list of accesory
    $currenty = $currenty + int($textheight * $linespacing_small)
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    If accesory() = "" Then
        $text = "Tilbehør: Intet Tilbehør"
    Else
        $text = "Tilbehør: " & accesory()
    EndIf
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty)
    
    ;Print textfield beneth the accesory
    $currenty = $currenty + int($textheight * $linespacing_small)
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    $text = GUICtrlRead($diversetlbhr)

    $startpoint = 1
    $var = 0
    $result2 = 1
    
    while $result2 > 0
        $var = StringMid($text, $startpoint, $lenght)
        $result2 = Stringcompare($var, $empty, 2)       
        $startpoint = $startpoint + $lenght
        $textheight = _PrintGetTextHeight($hp,$text)
        _PrintText($hp,$var, $currentx, $currenty)
        $currenty = $currenty + int($textheight * $linespacing_small)
    WEnd

    ;Print "Fejlbeskrivelse"
    $currenty = $currenty + int($textheight * $linespacing_medium)
    $currentx = $leftmargin
    _PrintSetFont($hp,'Tahoma',$header2,0,'')
    $text = "Fejlbeskrivelse"
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty) 

    ;Print textfield "Fejlbeskrivelse"
    $currenty = $currenty + int($textheight * $linespacing_small)
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    $text = GUICtrlRead($fejlbeskrivelse)

    $startpoint = 1
    $var = 0
    $result2 = 1
    
    while $result2 > 0
        $var = StringMid($text, $startpoint, $lenght)
        $result2 = Stringcompare($var, $empty, 2)       
        $startpoint = $startpoint + $lenght
        $textheight = _PrintGetTextHeight($hp,$text)
        _PrintText($hp,$var, $currentx, $currenty)
        $currenty = $currenty + int($textheight * $linespacing_small)
    WEnd

    _PrintNewPage($hp)
    
    ; Print headline
    $currenty = $topmargin
    $currentx = $leftmargin
    _PrintSetFont($hp,'Tahoma',$header1,0,'')
    $text = "ADD-Data Arbejdsseddel"
    _PrintText($hp,$text, $currentx, $currenty)
    $textheight = _PrintGetTextHeight($hp,$text)
    $currenty = $currenty + $textheight

    ; Print line under headline
    $currentx = $currentx - 5
    $currenty = $currenty - 17
    _PrintSetLineWid($hp,2)
    _PrintSetLineCol($hp,$BLACK)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)
    $currentx = $leftmargin
        
    ;print "Modtaget af" in the top right corner
    _PrintSetFont($hp,'Tahoma',$header3,0,'')
    $currenty = $currenty - 6
    $text = "Modtaget af " & GUICtrlRead($combo_modtager, 1) & " d. " & @MDAY & "-" & @MON & "-" & @YEAR & " kl. " & @HOUR & ":" & @MIN
    $textwidth = _PrintGetTextWidth($hp,$text)
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, int($pagewidth - $textwidth - $rightmargin - 20), $currenty)
    
    ;Print "kunde informationer"
    $currenty = $currenty + int($textheight * $linespacing_medium)
    _PrintSetFont($hp,'Tahoma',$header2,0,'')
    $text = "Kunde information"
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty) 

    ;Print customer name
    $currenty = $currenty + int($textheight * $linespacing_small)
    $currentx = $currentx * 2
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    $text = "Navn: " & GUICtrlRead($input_name, 1)
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty)
    
    ;Print Contact information
    $currenty = $currenty + int($textheight * $linespacing_small)
    _PrintSetFont($hp,'Tahoma',$body,0,'')
    $text = "Telefonnummer: " & GUICtrlRead($input_phonenumber, 1) & " Anden Kontakt: " & GUICtrlRead($input_other, 1)
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty)

    ;Print "Udført arbejde"
    $currenty = $currenty + int($textheight * $linespacing_medium)
    $currentx = $leftmargin
    _PrintSetFont($hp,'Tahoma',$header2,0,'')
    $text = "Udført arbejde"
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, $currentx, $currenty)
    
    ;Print "Pris"
    $currentx = $leftmargin
    _PrintSetFont($hp,'Tahoma',$header2,0,'')
    $text = "Pris"
    $textwidth = _PrintGetTextWidth($hp,$text)
    $textheight = _PrintGetTextHeight($hp,$text)
    _PrintText($hp,$text, int($pagewidth - $textwidth - $rightmargin - 20), $currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,1700,$currenty  - $textheight,1700,$pageheight - 50)

    ; Print line under headline
    $currentx = $currentx - 5
    _PrintSetLineWid($hp,2)
    _PrintSetLineCol($hp,$BLACK)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)
    $currentx = $leftmargin
    
    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)
    
    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)
    
    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)
    
    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)
    
    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)
    
    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)   

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    $currenty = $currenty + int($textheight)
    _PrintLine($hp,$currentx, $currenty,int($pagewidth - $currentx - $rightmargin),$currenty)

    ;Print "Total"
    $currenty = $currenty + int($textheight * $linespacing_medium)
    $currentx = $leftmargin
    _PrintSetFont($hp,'Tahoma',$header2,0,'')
    $text = "Total"
    $textheight = _PrintGetTextHeight($hp,$text)
    $textwidth = _PrintGetTextWidth($hp,$text)
    _PrintText($hp,$text, 1700 - $textwidth - 20, $currenty - 100)

    _PrintEndPrint($hp)
    _printDllClose($hp)
EndFunc

Func program_exit()
    Exit
EndFunc
Edited by Edifice

Share this post


Link to post
Share on other sites

Since I assume that the user must only choose one of the items in the list would it be acceptable to use CBS_DROPDOWNLIST instead of CBS_DROPDOWN ?

(0x103 instead of 0x102)


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Since I assume that the user must only choose one of the items in the list would it be acceptable to use CBS_DROPDOWNLIST instead of CBS_DROPDOWN ?

(0x103 instead of 0x102)

No, It's fine that the user can write something himself. The options are variable stuff that can be executed during a computer repair, however the different ways the mend a computer are almost infinite and that is why the user has to be able to input text himself. The options are merely a help to write and price the most common options.

Also writing in the input fields doesn't trigger the calculation I wan't it to.

Is there any way to trigger something every time the user types a new character?

Share this post


Link to post
Share on other sites

No, It's fine that the user can write something himself. The options are variable stuff that can be executed during a computer repair, however the different ways the mend a computer are almost infinite and that is why the user has to be able to input text himself. The options are merely a help to write and price the most common options.

Also writing in the input fields doesn't trigger the calculation I wan't it to.

Is there any way to trigger something every time the user types a new character?

Here is a quick example of reacting to the combobox edit changing.

; *** Start added by AutoIt3Wrapper ***
#include <ComboConstants.au3>
#include <WindowsConstants.au3>
; *** End added by AutoIt3Wrapper ***
#AutoIt3Wrapper_Add_Constants=n

$g=GUICreate("",400,400)
$c=GUICtrlCreateCombo("",50,50,200,25,0x102)

 GUICtrlSetData($c,"Værkstedstime|Testbegyr|Kort test|")
 GUIRegisterMsg($WM_COMMAND,"MyWM_COMMAND")

 GUISetState()

 while GUIGetMsg() <> -3

 WEnd


 func MyWM_COMMAND($h,$m,$w,$l)
     if BitAnd($w,0xffff) = $c Then

     if BitShift($w,16) = $CBN_EDITCHANGE then
         ConsoleWrite(guictrlread($c) & @CRLF)
     EndIf
 EndIf


 EndFunc

Make a note of this link, then you can easily find these things out for yourself. Just choose the control you are interested in, then look for notifications if you want to know when something has happened to a control, or look for messages if you want to tell the control to do something.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Here is a quick example of reacting to the combobox edit changing.

; *** Start added by AutoIt3Wrapper ***
#include <ComboConstants.au3>
#include <WindowsConstants.au3>
; *** End added by AutoIt3Wrapper ***
#AutoIt3Wrapper_Add_Constants=n

$g=GUICreate("",400,400)
$c=GUICtrlCreateCombo("",50,50,200,25,0x102)

 GUICtrlSetData($c,"Værkstedstime|Testbegyr|Kort test|")
 GUIRegisterMsg($WM_COMMAND,"MyWM_COMMAND")

 GUISetState()

 while GUIGetMsg() <> -3

 WEnd


 func MyWM_COMMAND($h,$m,$w,$l)
     if BitAnd($w,0xffff) = $c Then

     if BitShift($w,16) = $CBN_EDITCHANGE then
         ConsoleWrite(guictrlread($c) & @CRLF)
     EndIf
 EndIf


 EndFunc

Make a note of this link, then you can easily find these things out for yourself. Just choose the control you are interested in, then look for notifications if you want to know when something has happened to a control, or look for messages if you want to tell the control to do something.

I'm sorry I didn't find this out myself - Don't think I didn't try.

Anyway, this works beautifully! - Thank you very much!

Share this post


Link to post
Share on other sites

I'm sorry I didn't find this out myself - Don't think I didn't try.

Anyway, this works beautifully! - Thank you very much!

if you want a simple solution then look at post no. two. It's the same theory. I'm surprised no one picked up on it.

Mat

Share this post


Link to post
Share on other sites

if you want a simple solution then look at post no. two. It's the same theory. I'm surprised no one picked up on it.

Mat

I looked at the post but I had a very hard time understanding how I could fit it onto my script. I guess it looked to confusing and/or complicated.

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