Gui, Add, DateTime, x16 y10 w100 h30 , Gui, Add, Button, x116 y10 w100 h30 , Add Date Gui, Add, Edit, x16 y70 w200 h20 , Edit Gui, Add, Text, x16 y40 w200 h20 , Add Choosen date to : Gui, Show, x316 y175 h105 w232, Gui Return GuiClose: ExitApp
How can I add date to edit-box by a button?
#1
Rivaa
Posted 16 February 2012 - 06:29 PM
#2
Posted 16 February 2012 - 06:32 PM
#3
Posted 16 February 2012 - 07:14 PM
Gui, Add, DateTime, x16 y10 w100 h30 vDat, Gui, Add, Button, x116 y10 w100 h30 gGo, Add Date Gui, Add, Edit, x16 y70 w200 h20 vEdi , Edit Gui, Add, Text, x16 y40 w200 h20 , Add Choosen date to : Gui, Show, x316 y175 h105 w232, Gui Return Go: Gui, Submit, NoHide FormatTime, fDat, %Dat%, yyyy/MM/dd GuiControl, ,Edi, %fDat% return
#4
Posted 16 February 2012 - 07:14 PM
pls help
Gui, Add, DateTime, x16 y10 w100 h30 , Gui, Add, Button, x116 y10 w100 h30 , Add Date Gui, Add, Edit, x16 y70 w200 h20 , Edit Gui, Add, Text, x16 y40 w200 h20 , Add Choosen date to : Gui, Show, x316 y175 h105 w232, Gui Return GuiClose: ExitApp
As Ohnitiel said and Odlanir said, they are right.
But i will explain you, maybe it helps you understand better.
First, you have to asign variables to the items you have in the gui.
If you have an Edit, you will recognize it, and use it by assigning a variable.
For example, let's call that edit "Edit1". So in the program, each time we mention "Edit1", ahk will know that you are "talking about" that Edit.
Gui, Add, Edit, x16 y70 w200 h20 [color=red]vEdit1[/color] , Edit
The "v" before the name is to let ahk know you are naming a variable. If you want the variable to be called "Variable", you should use "vVariable" when defining it.
Ok, you will do the same with the calendar you added. So the date you select is stored in a variable, and you can use it inside the program.
Let's call it "Date1" (remember using the "v" before)
Gui, Add, DateTime, x16 y10 w100 h30[color=red] vDate1[/color],
Cool. Now we can manage those values.
What are we doing now? Adding a label to the button!
When you assign a label (routine) to a button, each time it is pressed, it will launch the actions/commands that are inside the defined label.
Firstly we have to assign it. How? Just like when we assigned variables, but using a "g" instead of "v".
"v" is for variable
"g" is for ... go to, i guess (lol).
Gui, Add, Button, x116 y10 w100 h30 [color=red]gAddDate[/color], Add Date
Ok, now, each time you press that button, it will launch the "AddDate" routine. So we have to say what is the "AddDate" routine going to do.
We do it the same way you specified the "GuiClose" to do ExitApp.
Now, the routine is "AddDate", so..
AddDate: ;;; logic... return
Remember adding the "return" when the routine ends, so it just stopps there and don't continue doing other things.
Now, the logic part.
You want it to show the date in the Edit box.
As you are reading values from the gui (the date from the calendar/DateTime), you have to specify the "Gui, submit".
That command makes the values from the gui, stores inside their respectives variables.
AddDate: Gui, Submit, Nohide return
The "NoHide" specification makes the gui being still visible. If you don't write it, the gui will hide.
Ok, by pressing the Add Date button, all the values from the gui will be stored in their respectives variables.
So, in that moment, we will have the variable "Date1" filled with the date you selected in the calendar!
What we have to do now is to send that value to the Edit.
How?
Using GuiControl.
GuiControl command allows us to modify some things from the gui. In this case, we will modify the "Edit" text.
The structure we should use is
Guicontrol,, variable, value
Variable = The expected variable which value we want to change
Value = The value we will give to the variable we mentioned.
In this case, the Variable will be "Edit1", remember!
And the value will be the value of variable "Date1"
So we should write this:
Guicontrol,, Edit1, Date1
right?
WRONG!
By doing that, the Edit blank will have the text "Date1", what we want is to have the value inside the variable "Date1".
So we should add the '%' signs around it. That makes reference to the value inside a variable.
Guicontrol,, Edit1, [color=red]%Date1%[/color]
So that would be all the program!
I leave you the whole thing with the marked addins:
Gui, Add, DateTime, x16 y10 w100 h30 [color=red]vDate1[/color], Gui, Add, Button, x116 y10 w100 h30 [color=red]gAddDate [/color], Add Date Gui, Add, Edit, x16 y70 w200 h20 [color=red]vEdit1[/color], Edit Gui, Add, Text, x16 y40 w200 h20 , Add Choosen date to : Gui, Show, x316 y175 h105 w232, Gui Return [color=red]AddDate: Gui, submit, Nohide Guicontrol,,Edit1, %Date1% return[/color] GuiClose: ExitApp
The format of the text will be a little ugly.
If you want us to explain you how to change it, tell us.
#5
Posted 16 February 2012 - 07:18 PM
#6
Rivaa
Posted 17 February 2012 - 10:09 AM
#7
Posted 17 February 2012 - 11:30 AM
Thanx everybody "BUT" I dont wanna use variable to editbox... just i wanna click "editbox" then click "add" button .. ? Is there any different Idea ?
Do you think values/data are stored magicaly in the memory of your computer ???
#8
Rivaa
Posted 17 February 2012 - 11:46 AM
#9
Posted 17 February 2012 - 01:14 PM
...
..."BUT" I dont wanna use variable to editbox...
...
.. then button sends date to "clicked" editbox I mean...
What do you send to EditBox ? A VARIABLE.
#10
Posted 17 February 2012 - 01:49 PM
...
..."BUT" I dont wanna use variable to editbox...
...
.. then button sends date to "clicked" editbox I mean...
What do you send to EditBox ? A VARIABLE.
I think he wants this:
You have many edit boxes. You click one of them (any), and then press the Add Date button. And there the date will be sent to the edit box you clicked before.
If so, try using GuiControlGet
Specially this:
GuiControlGet, OutputVar, FocusV [v1.0.43.06+]: Same as Focus (above) except that it retrieves the name of the focused control's associated variable. If that control lacks an associated variable, the first 63 characters of the control's text/caption is retrieved instead (this is most often used to avoid giving each button a variable name).
Note: If you click the button, i think that the outputvar will retrieve the button as the focused control.
Anyway, i'm not sure if that's your intention, please be mroe specific.
#11
Rivaa
Posted 17 February 2012 - 02:21 PM
You have many edit boxes. You click one of them (any), and then press the Add Date button. And there the date will be sent to the edit box you clicked before.
yes janopn, I want this
#12
Posted 17 February 2012 - 02:48 PM
Example :
Get data from edit
Send them to another edit
The "Get data" will ALWAYS put the data in a var to be able to send them afterward.
#13
Posted 17 February 2012 - 02:58 PM
2)Yes, it's possible. I made a little test but i cannot make exactly what i want.
So please answer this:
1)The edit boxes will be in your gui? (the program you created), or will be in an external application (such as firefox, notepad, etc).
2)You want/need it to be sent by pressing a button in the GUI, or you want/need it to be sent by pressing a keyboard key? (one is much easier than the other).
#14
Rivaa
Posted 17 February 2012 - 04:22 PM
Gui, Add, DateTime, x16 y10 w100 h30 , Gui, Add, Button, x116 y10 w100 h30 , Add Date Gui, Add, Edit, x16 y70 w200 h20 , Edit Gui, Add, Text, x16 y40 w200 h20 , Add Choosen date to : Gui, Show, x316 y175 h105 w232, Gui Return GuiClose: ExitApp
in gui , same program
#15
Rivaa
Posted 17 February 2012 - 04:24 PM




