Error:The same variable cannot be used for more than one control Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

songoku
Posts: 73
Joined: 12 Apr 2018, 13:22

Error:The same variable cannot be used for more than one control

07 Aug 2018, 10:53

Hallo,
Bekomme folgende Fehler angezeigt. wenn ich den Script ein 2x starten will.
Hätte gerne, wenn ich Jedesmal F4 drücke, das es ein Eingabefeld aufpoppt.

vielen Dank im Voraus

Code: Select all

---------------------------
gui.ahk
---------------------------
Error:  The same variable cannot be used for more than one control.

Specifically: vName

	Line#
	001: Return
	002: Gui,Add,Text,,Bitte Namen eingeben:
--->	003: Gui,Add,Edit,vName
	004: Gui,Add,Button,gOK,&Ok
	005: Gui,Show,,	
	006: Return
	010: Gui,Submit,NoHide
	011: Run,https://www.google.de/search?q=%Name%
	012: Gui,Hide
	013: Return

The current thread will exit.
---------------------------
OK   
---------------------------

Code: Select all

F4::
Gui, Add, Text,, Bitte Namen eingeben:
Gui, Add, Edit, vName
Gui, Add, Button, gOK, &Ok
Gui, Show,, `t
Return


OK:
    Gui, Submit, NoHide
Run, https://www.google.de/search?q=%Name%
Gui, Hide
    Return
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Error:The same variable cannot be used for more than one control

07 Aug 2018, 11:43

give you GUI a name and initialize it once in the auto-execute section of the script. then show it or hide it, depending on your needs. there is also no reason to use the NoHide option, if your gonna hide the GUI on the following line anyway, just skip it.

Code: Select all

Gui, MyGui: New
Gui, Add, Text,, Bitte Namen eingeben:
Gui, Add, Edit, vName
Gui, Add, Button, gOK, &Ok

F4::
Gui, MyGui: Show,, `t
Return

OK:
Gui, MyGui: Submit
Run, https://www.google.de/search?q=%Name%
Return
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Error:The same variable cannot be used for more than one control  Topic is solved

07 Aug 2018, 11:52

same, but shorter: with Enter-key enabled

Code: Select all

Gui, Add, Text,, Bitte Namen eingeben:
Gui, Add, Edit, vName
Gui, Add, Button, Default, &Ok
F4:: Gui, Show,, `t

ButtonOK:
Gui, Submit
Run, https://www.google.de/search?q=%Name%
Return
Warum geht das? Der erste Hotkey beendet die Autoexecute-section!
songoku
Posts: 73
Joined: 12 Apr 2018, 13:22

Re: Error:The same variable cannot be used for more than one control

07 Aug 2018, 12:13

Thanks und Danke,
Wie hast du "Enter-key enabled" gemacht, meine, welche Zeile macht das möglich?
Und ist es möglich, dass das Eingabefeld nach Ok oder Enter geleert wird ?

LG
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Error:The same variable cannot be used for more than one control

07 Aug 2018, 12:36

Enter-key wird enabled durch option Default in Gui, Add, Button.

Zum leeren: GuiControl,, Name
Beispiel:

Code: Select all

ButtonOK:
Gui, Submit
GuiControl,, Name
Run, https://www.google.de/search?q=%Name%
Return
Submit übernimmt den Wert im GUI, kann danach sofort gelöscht werden (fällt nicht auf, weil hidden), wir brauchen später nur den Wert in der Variablen.

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 55 guests