Werte in echtzeit im GUI anzeigen

  • Hallo.
    Ich würde gerne Werte (hier im Beispiel die X und Y Koordinate der Maus) in echtzeit im GUI anzeigen lassen; ähnlich wie beim Window Info Tool.
    Jedoch bekomme ich es nicht hin, dass die Inputboxen durch die Verzögerungen beim erstellen / entfernen wie verrückt blinken.
    Ich hoffe ihr könnt mir helfen. :)

    Hier der Code:

    [autoit]


    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("Form1", 301, 86, 283, 201)
    $Input1 = GUICtrlCreateInput("", 136, 12, 121, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Label1 = GUICtrlCreateLabel("Mousepos X", 32, 16, 63, 17)
    $Input2 = GUICtrlCreateInput("", 136, 44, 121, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Label2 = GUICtrlCreateLabel("Mousepos Y", 32, 48, 63, 17)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    $mousepos = MouseGetPos()

    GUICtrlDelete ($Input1)
    GUICtrlDelete ($Input2)

    $Input1 = GUICtrlCreateInput("" & $mousepos[0] & "", 136, 12, 121, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)

    $Input2 = GUICtrlCreateInput("" & $mousepos[1] & "", 136, 44, 121, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)

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

    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

    [/autoit]

    Einmal editiert, zuletzt von heini (16. September 2008 um 15:29)

  • Hi, und willkommen im Forum :)

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>

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

    $Form1 = GUICreate("Form1", 301, 86, 283, 201)
    $Input1 = GUICtrlCreateInput("", 136, 12, 121, 21, $ES_READONLY)
    $Input2 = GUICtrlCreateInput("", 136, 44, 121, 21, $ES_READONLY)
    $Label1 = GUICtrlCreateLabel("Mousepos X", 32, 16, 63, 17)
    $Label2 = GUICtrlCreateLabel("Mousepos Y", 32, 48, 63, 17)
    GUISetState(@SW_SHOW)

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

    While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE then Exit
    $mousepos = MouseGetPos()
    If GUICtrlRead($Input1) <> $mousepos[0] then GUICtrlSetData($Input1,$mousepos[0])
    If GUICtrlRead($Input2) <> $mousepos[1] then GUICtrlSetData($Input2,$mousepos[1])
    WEnd

    [/autoit]

    Du erstellst dein Input jedes mal neu. Anstelle davon musst du einfach immer einen neuen String reinschreiben lassen.

    /Edit: Den Vorschlag 2 von Oscar noch eingebaut :)

    Einmal editiert, zuletzt von anno2008 (16. September 2008 um 15:31)