2016-04-09 6 views
0

Ich versuche, ein Programm zu erstellen, das mir in einer Textbeschriftung den Farbwert der x, y-Positionen zeigt, die in Bearbeitungsfelder angegeben sind.So erstellen Sie dynamische Textbeschriftung autohotkey

Das Problem ist, dass es nur einmal funktioniert und nachdem es nicht aktualisiert wird. Es ist kein Problem mit dem Wert selbst, da der Wert korrekt aktualisiert wird, wenn ich eine MsgBox verwende.

Meine folgenden Code:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. 
; #Warn ; Enable warnings to assist with detecting common errors. 
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. 
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. 

#SingleInstance, force 

Gui, Add, Text,, X ;xpos label 
Gui, Add, Edit, vxpos Number ;xpos to be entered by user 
Gui, Add, Text,, Y ;ypos label 
Gui, Add, Edit, vypos Number ;ypos to be entered by user 
Gui, Add, Button, Default, GetColor ;to get the color 
Gui, Add, Text,, vmyRGB ;color value that should be displayed 
Gui, Show, AutoSize 
Return 

ButtonGetColor: ;called when pressing the button 
    Gui, Submit, NoHide ;retrieves values of my edit fields 
    PixelGetColor, myColor, %xpos%, %ypos% ;pixelcolor in my myColor variable 
    GuiControl,, vmyRGB, %myColor% ;updates my text field with the variable value, working once 
    MsgBox, %myColor% ;checks the value of my variable, always working 
Return 

etwas Hilfe zu diesem Thema benötigen, danke :)

Antwort

0

Nun, nachdem einige weitere Forschung verschiedene Schlüsselwörter, fand ich eine Lösung aus:

ersetzt
Gui, Add, Text,, vmyRGB ;color value that should be displayed 

von

Gui, Add, Text, vmyRGB, %myRGB% ;color value that should be displayed 

und ersetzt

GuiControl,, vmyRGB, %myColor% ;updates my text field with the variable value, working once 

von

GuiControl, Text, myRGB, %myColor% ;updates my text field with the variable value 
+0

Ich denke, dass '% vmyRGB%' sollte '% myRGB% betragen'? Das 'v' wird nur zum Angeben der Variablenoption verwendet. Siehe Dokumentation für Details – Blauhirn

+0

auch, wenn Ihr Problem gelöst ist, markieren Sie bitte diese Frage hier als die akzeptierte Antwort. – Blauhirn

+0

Ja, ich habe mein Problem gelöst, aber ich kann es nicht als akzeptiert markieren, bevor ich noch 2 Tage warte (vielleicht weil es meine eigene Antwort ist oder weil mein Konto neu ist, denke ich). + Ich weiß nicht, aber warum es sogar mit% vmyRGB% anstelle von% myRGB% funktionierte, änderte ich es tho. – PineApple34