Variablen aus unterschiedlichen GUIs abfragen? Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

heimer61
Posts: 8
Joined: 09 Feb 2020, 16:10

Variablen aus unterschiedlichen GUIs abfragen?

16 Feb 2020, 07:02

Hallo Leute,
cooles Board habt ihr hier. Jetzt muss ich auch mal eine Frage stellen, für die ich als Noob bisher keine Antwort gefunden habe. Ich hoffe jemand kann helfen.


Ich habe eine GUI mit mehreren Unter-GUIs erstellt.
In diesen Unter-GUIs habe ich Edit-Felder, deren Variablen-Inhalte ich im späteren Verlauf des Skripts weiter verwenden möchte.

Das versuche ich, in dem ich mit gPaste1, 2 und 3 die variablen Werte auf den Unter-GUIs anhand ihrer HWNDs auszulesen.

Allerdings lese ich anscheinend falsche Werte aus.


Code: Select all

#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1


Gui, 4: Show, w245 h310, MLT Copy
Gui, 4: Font, s30 Bold q5 c0xE5007D, Calibri
Gui, 4: Add, Text, x38 y-2 w169 h61 +0x200, MLT Copy
Gui, 4: Font
Gui, 4: Add, Button, gMLT1 x64 y80 w168 h45, 1G MLT
Gui, 4: Add, Button, gMLT2 x64 y136 w168 h45, 10G MLT
Gui, 4: Add, Button, gMLT3 x64 y192 w168 h45, 100G MLT
Return

MLT1:
Gui, 4: hide
Gui, 11: Show, w245 h310, MLT Copy
Gui, 11: Font, s30 Bold q5 c0xE5007D, Calibri
Gui, 11: Add, Text, x38 y-8 w169 h61 +0x200, MLT Copy
Gui, 11: Font
Gui, 11: Font, S18, Calibri
Gui, 11: Add, Edit, hWndEdit11 vVPSZ1 x64 y80 w168 h45
Gui, 11: Font, s12, Bold, Calibri 
Gui, 11: Add, Button, gPaste1 x64 y192 w168 h45, Einfügen
Gui, 11: Add, Button, gBack1 x64 y248 w168 h45, Zurück
Gui, 11: Font
Return

MLT2:
Gui, 4: hide
Gui, 2: Show, w245 h310, MLT Copy
Gui, 2: Font, s30 Bold q5 c0xE5007D, Calibri
Gui, 2: Add, Text, x38 y-8 w169 h61 +0x200, MLT Copy
Gui, 2: Font
Gui, 2: Font, S18, Calibri
Gui, 2: Add, Edit, hWndEdit21 vVPSZ2 x64 y80 w168 h45
Gui, 2: Font, s12, Bold, Calibri 
Gui, 2: Add, Button, gPaste2 x64 y192 w168 h45, Einfügen
Gui, 2: Add, Button, gBack2 x64 y248 w168 h45, Zurück
Gui, 2: Font, s12, Bold, Calibri 
Return


MLT3:
Gui, 4: hide
Gui, 3: Show, w245 h310, MLT Copy
Gui, 3: Font, s30 Bold q5 c0xE5007D, Calibri
Gui, 3: Add, Text, x38 y-8 w169 h61 +0x200, MLT Copy
Gui, 3: Font
Gui, 3: Font, S18, Calibri
Gui, 3: Add, Edit, hWndEdit31 vVPSZ3 x64 y80 w168 h45
Gui, 3: Font, s12, Bold, Calibri 
Gui, 3: Add, Button, gPaste3 x64 y192 w168 h45, Einfügen
Gui, 3: Add, Button, gBack3 x64 y248 w168 h45, Zurück
Gui, 3: Font
Return

Back1:
Gui, 11: destroy
Gui, 4: show
Return

Back2:
Gui, 2: destroy
Gui, 4: show
Return

Back3:
Gui, 3: destroy
Gui, 4: show
Return

Paste1:
GuiControlGet, Gui, 11: %Edit11%
MsgBox 0x42040, Ergebnis, Es wurde %Edit11% eingegeben.
Return

Paste2:
GuiControlGet, Gui, 2: %Edit21%
MsgBox 0x42040, Ergebnis, Es wurde %Edit21% eingegeben.
Return

Paste3:
GuiControlGet, Gui, 3: %Edit31%
MsgBox 0x42040, Ergebnis, Es wurde %Edit31% eingegeben.
Return

GuiEscape:
11GuiClose:
2GuiClose:
3GuiClose:
4GuiClose:
Gui +OwnDialogs
MsgBox 0x24, Programm beenden, Wirklich beenden?
IfMsgBox Yes, {
ExitApp
} Else IfMsgBox No, {
Return
}
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Variablen aus unterschiedlichen GUIs abfragen?  Topic is solved

16 Feb 2020, 08:38

Hallo und herzlich willkommen im AHK-Forum.

Die beschriebenen Fehler könnten durch die falsche Anwendung von GuiControlGet verursacht sein.
Versuche es mal mit einem zusätzlichen Komma hinter dem Namen der Gui.

Code: Select all

GuiControlGet, Gui, 11:, %Edit11%
Bei normaler Vergabe von Variablennamen sollte es funktionieren, doch ob dies mit dem hwnd-Zeugs auch funktioniert, weiß ich nicht.
Zudem scheinst Du die Ausgabevariable und die Control-ID verwechselt zu haben. In Deinem Fall ist Gui der Name der Ausgabevariable und somit solltest Du auch

Code: Select all

MsgBox 0x42040, Ergebnis, Es wurde %Gui% eingegeben.
verwenden.
Einfach nur ein toller Typ. :mrgreen:
heimer61
Posts: 8
Joined: 09 Feb 2020, 16:10

Re: Variablen aus unterschiedlichen GUIs abfragen?

16 Feb 2020, 09:06

:clap: Supergeil - Es funktioniert. Jetzt kann ich weiter basteln :)

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: Ragnar and 52 guests