Schon beim Schreiben eine Veränderung

  • Hier wie kann ich machen, dass ich ohne auf Berechnenbutton klicke die sachen schon berechnen?
    Also das soll währen dich tippe die Zahlen schon verändern und ins Label reinschreiben.
    Ich denk mal das hat was mit while zu tun aber weiter habe ich keine idee.
    Code:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #Region ### START Koda GUI section ### Form=J:\koda_1.7.0.1\Forms\Form1.kxf
    $Form1 = GUICreate("Form1", 451, 268, 203, 124)
    GUISetBkColor(0x9DB9EB)
    $np = GUICtrlCreateInput("45000", 20, 22, 73, 21)
    $pnoblue = GUICtrlCreateInput("145", 20, 65, 73, 21)
    $pplus = GUICtrlCreateInput("160", 20, 112, 73, 21)
    $pblue = GUICtrlCreateInput("160", 20, 154, 73, 21)
    $pblueplus = GUICtrlCreateInput("180", 20, 200, 73, 21)
    $Label3 = GUICtrlCreateLabel("% with blue", 18, 141, 73, 15)
    GUICtrlSetFont(-1, 10, 400, 0, "Flubber")
    $Label1 = GUICtrlCreateLabel("NPC Price", 18, 8, 63, 12)
    GUICtrlSetFont(-1, 10, 400, 0, "Flubber")
    $Label2 = GUICtrlCreateLabel("% with +", 18, 98, 57, 12)
    GUICtrlSetFont(-1, 10, 400, 0, "Flubber")
    $Label13 = GUICtrlCreateLabel("All Blue Items", 265, 10, 200, 17)
    GUICtrlSetFont(-1, 10, 400, 0, "Flubber")
    $Label8 = GUICtrlCreateLabel("+2", 264, 60, 16, 17)
    $Label9 = GUICtrlCreateLabel("+3", 264, 96, 16, 17)
    $Label10 = GUICtrlCreateLabel("+4", 264, 132, 16, 17)
    $Label11 = GUICtrlCreateLabel("+5", 264, 168, 16, 17)
    $enp = GUICtrlCreateLabel("0", 162, 24, 101, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $eplus = GUICtrlCreateLabel("0", 162, 113, 101, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $eblue = GUICtrlCreateLabel("0", 162, 158, 101, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $eblueplus = GUICtrlCreateLabel("0", 163, 201, 101, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $enoblue = GUICtrlCreateLabel("0", 163, 65, 101, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $e1 = GUICtrlCreateLabel("0", 282, 24, 100, 17)
    $e2 = GUICtrlCreateLabel("0", 282, 60, 100, 17)
    $e3 = GUICtrlCreateLabel("0", 282, 96, 100, 17)
    $e4 = GUICtrlCreateLabel("0", 282, 132, 100, 17)
    $e5 = GUICtrlCreateLabel("0", 282, 168, 100, 17)
    $Label5 = GUICtrlCreateLabel("+1", 264, 24, 16, 17)
    $Label6 = GUICtrlCreateLabel("% with blue and +", 20, 186, 110, 12)
    GUICtrlSetFont(-1, 10, 400, 0, "Flubber")
    $Label12 = GUICtrlCreateLabel("% non blue or +", 20, 50, 98, 15)
    GUICtrlSetFont(-1, 10, 400, 0, "Flubber")
    $Berechnen = GUICtrlCreateButton("Berechnen", 16, 228, 77, 29, 0)
    GUICtrlSetBkColor(-1, 0xA6CAF0)
    $Reset = GUICtrlCreateButton("Reset", 115, 229, 77, 29, 0)
    GUICtrlSetBkColor(-1, 0xA6CAF0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    func berechnen()
    $np2 = GUICtrlRead($np)
    $pnoblue2 = GUICtrlRead($pnoblue)
    $pplus2 = GUICtrlRead($pplus)
    $pblue2 = GUICtrlRead($pblue)
    $pblueplus2 = GUICtrlRead($pblueplus)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($enp, $np2)
    $pnoblue2 = $np2 * $pnoblue2 / 100
    GUICtrlSetData($enoblue, $pnoblue2)
    $pplus2 = $np2 * $pplus2 / 100
    GUICtrlSetData($eplus, $pplus2)
    $pblue2 = $np2 * $pblue2 / 100
    GUICtrlSetData($eblue, $pblue2)
    $pblueplus2 = $np2 * $pblueplus2 / 100
    GUICtrlSetData($eblueplus, $pblueplus2)

    [/autoit] [autoit][/autoit] [autoit]

    $pblueplus3 = GUICtrlRead($pblueplus)
    $e12 = $np2 * $pblueplus3 / 100
    GUICtrlSetData($e1, $e12)
    $e22 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e2, $e22)
    $e32 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e3, $e32)
    $e42 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e4, $e42)
    $e52 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e5, $e52)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func reset()
    GUICtrlSetData($enp, "0")
    GUICtrlSetData($enoblue, "0")
    GUICtrlSetData($eplus, "0")
    GUICtrlSetData($eblue, "0")
    GUICtrlSetData($eblueplus, "0")

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($e1, "0")
    GUICtrlSetData($e2, "0")
    GUICtrlSetData($e3, "0")
    GUICtrlSetData($e4, "0")
    GUICtrlSetData($e5, "0")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $Berechnen
    berechnen()
    Case $Reset
    reset()
    EndSwitch
    WEnd

    [/autoit]

    EDIT: Topic passend verändert

    Einmal editiert, zuletzt von MaZy (4. März 2009 um 21:33)

  • Hey,

    vom Prinzip her funktioniert das so:

    Spoiler anzeigen
    [autoit]

    $flag = 0

    [/autoit] [autoit][/autoit] [autoit]

    $eingabe = GUICtrlCreateInput()

    [/autoit] [autoit][/autoit] [autoit]

    While

    $msg = GUIGetMsg()

    $eingabe_alt = GUICtrlRead($eingabe)

    If $flag == 1 Then
    Funktion_zum_Berechnen()
    $flag = 0
    EndIf

    If $eingabe_alt <> GUICtrlRead($eingabe) Then
    $flag = 1
    EndIf

    WEnd

    [/autoit]

    Gruß

    Prajoss

    "Never touch a running System!"

  • geht nicht.. kommt bei mir fehler aber danke. Hast damit mir geholfen mir eine Idee zu entwickeln

    Spoiler anzeigen
    [autoit]

    $bla = GUICtrlRead($np)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    if GUICtrlRead($np) <> $bla Then
    berechnen()
    EndIf
    WEnd

    [/autoit]

    das klappt ganz gut nur irgendwie sieht man ,dass es ganze zeit überschrieben wird. Man sieht wenn man genau betrachtet wie die zahlen verschwinden.. also ganz leicht.. ob es laggen würde.

    außerdem gibs noch ein trick merk ich gerade

    Spoiler anzeigen
    [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $Berechnen
    berechnen()
    Case $Reset
    reset()
    EndSwitch
    berechnen()
    WEnd

    [/autoit]


    Schon peinlich das mir das net eingefallen ist :P
    Aber da hab ich das selbe problem :S

  • deswegen hab ich ja bei mir immer ein Flag gesetzt damit er eben nicht dauernd die Funktion aufruft, sondern nur wenn sich was geändert hat im Edit

    "Never touch a running System!"

    • Offizieller Beitrag

    So geht es komfortabler:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    $hGUI = GUICreate('Test', 220, 100, -1, -1)

    [/autoit] [autoit][/autoit] [autoit]

    $hLabel = GUICtrlCreateLabel('', 5, 5, 210, 40)
    GUICtrlSetFont(-1, 20)

    [/autoit] [autoit][/autoit] [autoit]

    $hInput = GUICtrlCreateInput('', 5, 50, 210, 22)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()
    GUIRegisterMsg($WM_COMMAND, 'MY_WM_COMMAND')

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Until GUIGetMsg() = -3

    [/autoit] [autoit][/autoit] [autoit]

    Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nID = BitAND($wParam, 0x0000FFFF), $sExt
    Switch $nID
    Case $hInput
    GUICtrlSetData($hLabel, GUICtrlRead($hInput))
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>MY_WM_COMMAND

    [/autoit]
  • danke der funkz ohne probleme.. ich bin aber hier irrtiert.
    Warum funktioniert das immernoch?

    Spoiler anzeigen
    [autoit]

    GUIRegisterMsg($WM_COMMAND, 'MY_WM_COMMAND')

    [/autoit] [autoit][/autoit] [autoit]

    Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    $np2 = GUICtrlRead($np)
    $pnoblue2 = GUICtrlRead($pnoblue)
    $pplus2 = GUICtrlRead($pplus)
    $pblue2 = GUICtrlRead($pblue)
    $pblueplus2 = GUICtrlRead($pblueplus)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($enp, $np2)
    $pnoblue2 = $np2 * $pnoblue2 / 100
    GUICtrlSetData($enoblue, $pnoblue2)
    $pplus2 = $np2 * $pplus2 / 100
    GUICtrlSetData($eplus, $pplus2)
    $pblue2 = $np2 * $pblue2 / 100
    GUICtrlSetData($eblue, $pblue2)
    $pblueplus2 = $np2 * $pblueplus2 / 100
    GUICtrlSetData($eblueplus, $pblueplus2)

    [/autoit] [autoit][/autoit] [autoit]

    $pblueplus3 = GUICtrlRead($pblueplus)
    $e12 = $np2 * $pblueplus3 / 100
    GUICtrlSetData($e1, $e12)
    $e22 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e2, $e22)
    $e32 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e3, $e32)
    $e42 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e4, $e42)
    $e52 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e5, $e52)
    Local $nID = BitAND($wParam, 0x0000FFFF), $sExt
    Switch $nID
    Case $np

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>MY_WM_COMMAND

    [/autoit]


    Ih hab die sachen darüber geshrieben und nicht mal unter Casetrotzdem gehts :S

    EDIT: looooooool

    Spoiler anzeigen
    [autoit]

    GUIRegisterMsg($WM_COMMAND, 'MY_WM_COMMAND')

    [/autoit] [autoit][/autoit] [autoit]

    Func MY_WM_COMMAND()
    $np2 = GUICtrlRead($np)
    $pnoblue2 = GUICtrlRead($pnoblue)
    $pplus2 = GUICtrlRead($pplus)
    $pblue2 = GUICtrlRead($pblue)
    $pblueplus2 = GUICtrlRead($pblueplus)
    GUICtrlSetData($enp, $np2)
    $pnoblue2 = $np2 * $pnoblue2 / 100
    GUICtrlSetData($enoblue, $pnoblue2)
    $pplus2 = $np2 * $pplus2 / 100
    GUICtrlSetData($eplus, $pplus2)
    $pblue2 = $np2 * $pblue2 / 100
    GUICtrlSetData($eblue, $pblue2)
    $pblueplus2 = $np2 * $pblueplus2 / 100
    GUICtrlSetData($eblueplus, $pblueplus2)
    $pblueplus3 = GUICtrlRead($pblueplus)
    $e12 = $np2 * $pblueplus3 / 100
    GUICtrlSetData($e1, $e12)
    $e22 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e2, $e22)
    $e32 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e3, $e32)
    $e42 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e4, $e42)
    $e52 = $np2 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100 * $pblueplus3 / 100
    GUICtrlSetData($e5, $e52)
    EndFunc

    [/autoit]

    Das geht auch!! Außer ohne

    [autoit]

    GUIRegisterMsg($WM_COMMAND, 'MY_WM_COMMAND')

    [/autoit]

    geht es nicht, Also ist GUIRegisterMsg nur wichtig