Inhalt Textfeld GUI aktualisieren

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

Dani99
Posts: 35
Joined: 13 Apr 2017, 03:08

Inhalt Textfeld GUI aktualisieren

15 Apr 2017, 13:20

Hi.
Ich hab auf einem GUI 2 Textfelder und einen Button.
Ich will, dass nach druck auf den button in den beiden Textfeldern das aktuelle Datum (ohne punkte) und im anderen Feld die Uhrzeit (hhmm) steht.

Kriege es nicht hin.

Any Ideas?
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: Inhalt Textfeld GUI aktualisieren

15 Apr 2017, 13:38

example
EDIT : kleine Korrektur / gosub,T1 eingefügt

Code: Select all

name1=Test
Gui,2:Font,Cdefault,Fixedsys
Gui,2:Color,Black
Gui,2:Color,ControlColor, Black

Gui,2:add,text,   x1  y10 w80 cGray right vD
Gui,2:add,text,   x1  y35 w80 cGray right vT
Gui,2:add,button, x10  y70   h25 w70 gT1,TEST
Gui,2:Show,x1 y1 w200 h110 ,%name1%
gosub,T1
Return
;-------------------------------
2GuiClose:
ExitApp

T1:
stringmid,date1,a_now,1,8
stringmid,hour1,a_now,9,6
GuiControl,2:Text,D,%date1%
GuiControl,2:Text,T,%hour1%
return
Last edited by garry on 16 Apr 2017, 14:37, edited 1 time in total.
Dani99
Posts: 35
Joined: 13 Apr 2017, 03:08

Re: Inhalt Textfeld GUI aktualisieren

16 Apr 2017, 07:59

Fast.
Wie schaffe ich es aber, dass in dem Feld bereits die aktuelle Zeit steht, sobald sich das form öffnet?
just me
Posts: 9461
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Inhalt Textfeld GUI aktualisieren

16 Apr 2017, 08:10

Moin,

schau Dir mal die eingebauten Datum und Zeit Variablen an. Die kann man einem Steuerelement auch schon beim Erstellen zuweisen.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Inhalt Textfeld GUI aktualisieren

16 Apr 2017, 08:14

Versuch mal:

Code: Select all

Gui, Add, Text, vDatum w100
Gui, Add, Text, vZeit w100
Gui, Add, Button,, Aktualisieren
Gui, Show
; no return here

ButtonAktualisieren:
    GuiControl,, Datum, % SubStr(A_Now, 1, 8)
    GuiControl,, Zeit,  % SubStr(A_Now, 9, 4)
Return

GuiClose:
ExitApp
Ich hoffe das hilft.
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: Inhalt Textfeld GUI aktualisieren

16 Apr 2017, 08:43

danke
Ich will, dass nach druck auf den button in den beiden Textfeldern das aktuelle Datum (ohne punkte) und im anderen Feld die Uhrzeit (hhmm) steht.
eigentlich sollte die Zeit immer aktuell sein ( nicht erst auf Knopfdruck anzeigen )

Code: Select all

;-------- https://autohotkey.com/boards/viewtopic.php?f=9&t=30613 ---
name1=Test
Gui,2:Font,Cdefault,Fixedsys
Gui,2:Color,Black
Gui,2:Color,ControlColor, Black

Gui,2:add,text,   x20  y10 w70 cGray right vD
Gui,2:add,text,   x20  y35 w70 cGray right vT
Gui,2:Show,x1 y1 w200 h110 ,%name1%
settimer,t1,1000
Return
;-------------------------------
2GuiClose:
ExitApp

T1:
stringmid,date1,a_now,1,8
stringmid,hour1,a_now,9,6
GuiControl,2:Text,D,%date1%
GuiControl,2:Text,T,%hour1%
return

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 56 guests