AutoHotkey Community

It is currently May 27th, 2012, 10:50 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Formate Date Time menu
PostPosted: October 11th, 2006, 3:10 pm 
Offline

Joined: July 25th, 2006, 7:37 pm
Posts: 490
Location: Midwest, USA
Here is a small script I set up for a user of mine. Basically, you hit the hotkey, and a popup menu appears, letting you choose which format to choose, then inserting it into the text where the cursor is. Feel free to paste comments.

Code:
#Persistent
#SingleInstance, Force

^+a::
  Menu, DateTimeFormat, Add, &LongDateTime
  Menu, DateTimeFormat, Add, &ShortDateTime
  Menu, DateTimeFormat, Add, L&ongDate
  Menu, DateTimeFormat, Add, S&hortDate
  Menu, DateTimeFormat, Show, %A_CaretX%, %A_CaretY%
Return

&LongDateTime:
  FormatTime, LDT, , dddd, MMMM dd, yyyy, h:mm tt
  SendInput, %LDT%
Return

&ShortDateTime:
  FormatTime, SDT, , MM/dd/yy, h:mm tt
  SendInput, %SDT%
Return

L&ongDate:
  FormatTime, LD, , LongDate
  SendInput, %LD%
Return

S&hortDate:
  FormatTime, SD, , ShortDate
  SendInput, %SD%
Return

_________________
SilverEdge78


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 11th, 2006, 7:39 pm 
Offline

Joined: December 28th, 2005, 10:46 am
Posts: 99
A long time ago, I seen an other one, with a GUI, that I have modified to give different date formats, depending of a parameter. The advantage : you can choose the date format that the function returns and then SendInput it (so not only the today's date) :
Code:
; XXXXXXXXXXXXXXXXXXXXXxxxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;   Kalend Function
;      - If the user hit the ESC key, the returned result is O
;      - When the user hit on !c (Cancel), the retruned date is the today's one
;      - there is an argument which indicate the return fcormat wanted
;         . 1 = dd/mm/yy
;         . 2 = dd/mm/ccyy
;         . 3 = ddmmyy
;         . 4 = ddmmccyy
;         . 5 = yy-mm-dd
;         . 6 = ccyy-mm-dd
;         . 7 = yymmdd
;         . 8 = ccyymmdd
; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Kalend(K_FormDat)
  {
   Global F03_Date
   Gui, 3:Add, Text, x6 y10 w130 h20,Enter the date :
   Gui, 3:Add, DateTime, x6 y30 w130 h20 vF03_Date,
   Gui, 3:Add, Button, x6 y60 w60 h20 Default,&OK
   Gui, 3:Add, Button, x76 y60 w60 h20,&Cancel
   Gui, 3:Show, x562 y225 h90 w146, Date
   WinWaitClose, Date, Enter the date
   Return TD_RDate

3GuiEscape:
   Gui, 3:cancel
   Gui, 3:Destroy
   TD_RDate = 0
   return

3ButtonCancel:
3GuiClose:
   Gui, 3:cancel
   Gui, 3:Destroy
   If K_FormDat = 1
      FormatTime, TD_RDate,, dd/MM/yy
   Else If K_FormDat = 2
      FormatTime, TD_RDate,, dd/MM/yyyy
   Else If K_FormDat = 3
      FormatTime, TD_RDate,, ddMMyy
   Else If K_FormDat = 4
      FormatTime, TD_RDate,, ddMMyyyy
   Else If K_FormDat = 5
      FormatTime, TD_RDate,, yy-MM-dd
   Else If K_FormDat = 6
      FormatTime, TD_RDate,, yyyy-MM-dd
   Else If K_FormDat = 7
      FormatTime, TD_RDate,, yyMMdd
   Else If K_FormDat = 8
      FormatTime, TD_RDate,, yyyyMMdd
   return

3ButtonOK:
   Gui, 3:submit
   Gui, 3:Destroy
   If K_FormDat = 1
      FormatTime, TD_RDate, %F03_Date%, dd/MM/yy
   Else If K_FormDat = 2
      FormatTime, TD_RDate, %F03_Date%, dd/MM/yyyy
   Else If K_FormDat = 3
      FormatTime, TD_RDate, %F03_Date%, ddMMyy
   Else If K_FormDat = 4
      FormatTime, TD_RDate, %F03_Date%, ddMMyyyy
   Else If K_FormDat = 5
      FormatTime, TD_RDate, %F03_Date%, yy-MM-dd
   Else If K_FormDat = 6
      FormatTime, TD_RDate, %F03_Date%, yyyy-MM-dd
   Else If K_FormDat = 7
      FormatTime, TD_RDate, %F03_Date%, yyMMdd
   Else If K_FormDat = 8
      FormatTime, TD_RDate, %F03_Date%, yyyyMMdd
   return
  }


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 11th, 2006, 11:07 pm 
Offline

Joined: September 3rd, 2006, 5:34 am
Posts: 601
Location: Iowa, U.S.
Yes a gui is nice, but his hotkey is for convienence. I prefer the gui because i like windows but a hotkey has its own benefits.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 12th, 2006, 6:04 pm 
Offline

Joined: December 28th, 2005, 10:46 am
Posts: 99
To send the today's date, an hotkey must be simpler and faster than a GUI. But if you want to send any date, the GUI is simpler and more powerfull (at least in my mind). I have two hotkeys (for me ^F2 and ^+F2) which call the function to return a date in a format depending of the hotkey typed, and I use them every day at work.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2006, 5:29 pm 
Offline

Joined: July 25th, 2006, 7:37 pm
Posts: 490
Location: Midwest, USA
I personally use a single hotkey, Ctrl-` to enter in the date in Time Long Date format. Just how I preer it. This scriplet was requested by a user specifically as created. Im sure a gui would look nice/be more effective, but he can hit the key combo, hit l and enter and its done. *shrugs* He likes it and I thought others might as well. That is all. :)

_________________
SilverEdge78


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 11th, 2007, 6:29 am 
Offline

Joined: March 27th, 2007, 1:21 pm
Posts: 12
Could someone tell me how to activate the Kalend function please?

Terje


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2007, 6:17 pm 
Offline

Joined: June 14th, 2007, 6:43 pm
Posts: 11
Took me a little bit to figure out how to use the GUI as well.

Here is the code I used to get it to work, you can change the format you get by changing the number in the "msgbox % Kalend(1)" command.

Code:
; XXXXXXXXXXXXXXXXXXXXXxxxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;   Kalend Function
;      - If the user hit the ESC key, the returned result is O
;      - When the user hit on !c (Cancel), the retruned date is the today's one
;      - there is an argument which indicate the return fcormat wanted
;         . 1 = dd/mm/yy
;         . 2 = dd/mm/ccyy
;         . 3 = ddmmyy
;         . 4 = ddmmccyy
;         . 5 = yy-mm-dd
;         . 6 = ccyy-mm-dd
;         . 7 = yymmdd
;         . 8 = ccyymmdd
; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
^F3::
   msgbox % Kalend(8)
return 

Kalend(K_FormDat)
  {
   Global F03_Date
   Gui, 3:Add, Text, x6 y10 w130 h20,Enter the date :
   Gui, 3:Add, DateTime, x6 y30 w130 h20 vF03_Date,
   Gui, 3:Add, Button, x6 y60 w60 h20 Default,&OK
   Gui, 3:Add, Button, x76 y60 w60 h20,&Cancel
   Gui, 3:Show, x562 y225 h90 w146, Date
   WinWaitClose, Date, Enter the date
   Return TD_RDate

3GuiEscape:
   Gui, 3:cancel
   Gui, 3:Destroy
   TD_RDate = 0
   return

3ButtonCancel:
3GuiClose:
   Gui, 3:cancel
   Gui, 3:Destroy
   If K_FormDat = 1
      FormatTime, TD_RDate,, dd/MM/yy
   Else If K_FormDat = 2
      FormatTime, TD_RDate,, dd/MM/yyyy
   Else If K_FormDat = 3
      FormatTime, TD_RDate,, ddMMyy
   Else If K_FormDat = 4
      FormatTime, TD_RDate,, ddMMyyyy
   Else If K_FormDat = 5
      FormatTime, TD_RDate,, yy-MM-dd
   Else If K_FormDat = 6
      FormatTime, TD_RDate,, yyyy-MM-dd
   Else If K_FormDat = 7
      FormatTime, TD_RDate,, yyMMdd
   Else If K_FormDat = 8
      FormatTime, TD_RDate,, yyyyMMdd
   return

3ButtonOK:
   Gui, 3:submit
   Gui, 3:Destroy
   If K_FormDat = 1
      FormatTime, TD_RDate, %F03_Date%, dd/MM/yy
   Else If K_FormDat = 2
      FormatTime, TD_RDate, %F03_Date%, dd/MM/yyyy
   Else If K_FormDat = 3
      FormatTime, TD_RDate, %F03_Date%, ddMMyy
   Else If K_FormDat = 4
      FormatTime, TD_RDate, %F03_Date%, ddMMyyyy
   Else If K_FormDat = 5
      FormatTime, TD_RDate, %F03_Date%, yy-MM-dd
   Else If K_FormDat = 6
      FormatTime, TD_RDate, %F03_Date%, yyyy-MM-dd
   Else If K_FormDat = 7
      FormatTime, TD_RDate, %F03_Date%, yyMMdd
   Else If K_FormDat = 8
      FormatTime, TD_RDate, %F03_Date%, yyyyMMdd
   return
  }


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2007, 7:10 pm 
Offline

Joined: June 14th, 2007, 6:43 pm
Posts: 11
I did some playing with the GUI and added a DDL to pick the format.
I also changed the way it presents the date, I used SendInput like silveredge78.
You pick the date and format and it will insert it where the cursor is.
This is my first GUI I've worked with and Im open to suggestions/criticism.
Here is the code.

Code:
; XXXXXXXXXXXXXXXXXXXXXxxxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;   Kalend Function
;      - If the user hit the ESC key, the returned result is O
; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
; ===============================
; =Modified by bennoman 06/15/07=
; ===============================

!`::
   SendInput % Kalend()
return 

Kalend()
{
   Global F03_Date
   Global FormatChoice
   Gui, 3:Add, Text, x6 y10 w130 h20,Enter the date :
   Gui, 3:Add, DateTime, x6 y25 w130 h20 vF03_Date,
   Gui, 3:Add, Text, x6 y50 w130 h20,Choose your format :
   Gui, 3:Add, DropDownList, x6 y65 w130 h180 vFormatChoice, mm/dd/yy||mm/dd/ccyy|dd/mm/yy|dd/mm/ccyy|ddmmyy|ddmmccyy|yy-mm-dd|ccyy-mm-dd|yymmdd|ccyymmdd
   Gui, 3:Add, Button, x6 y95 w60 h20 Default,&OK
   Gui, 3:Add, Button, x76 y95 w60 h20,&Cancel
   Gui, 3:Show, x562 y225 h125 w146, Date
   WinWaitClose, Date, Enter the date
   Return TD_RDate

   3GuiEscape:
      Gui, 3:cancel
      Gui, 3:Destroy
      TD_RDate = 0
   return

   3ButtonCancel:
   3GuiClose:
      Gui, 3:cancel
      Gui, 3:Destroy
   return

   3ButtonOK:
      Gui, 3:submit
      Gui, 3:Destroy
      If FormatChoice = mm/dd/yy
         FormatTime, TD_RDate, %F03_Date%, MM/dd/yy
      Else If FormatChoice = mm/dd/ccyy
         FormatTime, TD_RDate, %F03_Date%, MM/dd/yyyy
      Else If FormatChoice = dd/mm/yy
         FormatTime, TD_RDate, %F03_Date%, dd/MM/yy
      Else If FormatChoice = dd/mm/ccyy
         FormatTime, TD_RDate, %F03_Date%, dd/MM/yyyy
      Else If FormatChoice = ddmmyy
         FormatTime, TD_RDate, %F03_Date%, ddMMyy
      Else If FormatChoice = ddmmccyy
         FormatTime, TD_RDate, %F03_Date%, ddMMyyyy
      Else If FormatChoice = yy-mm-dd
         FormatTime, TD_RDate, %F03_Date%, yy-MM-dd
      Else If FormatChoice = ccyy-mm-dd
         FormatTime, TD_RDate, %F03_Date%, yyyy-MM-dd
      Else If FormatChoice = yymmdd
         FormatTime, TD_RDate, %F03_Date%, yyMMdd
      Else If FormatChoice = ccyymmdd
         FormatTime, TD_RDate, %F03_Date%, yyyyMMdd
   return
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2007, 9:28 pm 
terje wrote:
Could someone tell me how to activate the Kalend function please?

Terje

An example of code to call the Kalend function (Demokos version, the others versions are intreresting, too, IMO) :
Code:
<+<^F2::
  CF2 := Kalend(6)
  If CF2 <> 0
    Send, %CF2%
  Return

This display the window to choose the date. If you type ESC, the window is destroyed and nothing is sent. If you type on the Cancel button, the today's date is sent, and if you type on OK (or Enter), the choosen date is sent.
In this example, Kalend(6) return the date in the ISO format ccyy-mm-dd.
The bennoman version is interesting, but the value returned by the function when you type Escape seems to not be managed. IMO, I like the possibility to return the today's date by clicking on the Cancel button.
I don't want any result : ESC
I want the today's date : Cancel Button
I want to send the choosen date : Enter.
To give the choice of the format in the GUI is an interesting option.
IMO I prefer to choose the format by the hotkey which call Kalend. The most of the time, I use only 2 formats, so I have 2 hotkeys to call the function, depending on the format in which I want to have the date sent.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2007, 11:18 am 
Offline

Joined: April 28th, 2006, 12:12 pm
Posts: 55
These are good scripts, but I would like to do something simpler - I would like to hit the hotkey combination and have today's date sent. I have tried to remove the gui that allows the user the choose the date, but I cannot get it to work.

Could somebody please help me?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2007, 3:53 pm 
It's always better to ask for help in the homonym forum... :D :D :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 4:48 am 
Offline

Joined: July 25th, 2006, 7:37 pm
Posts: 490
Location: Midwest, USA
Antonimo, did you see the first part of this script that I posted? Use either that or
Code:
; Auto Time/Date Stamp====================================================
^`::                  ;;Long Time/Date Stamp
  FormatTime, TimeStamp
  SendInput, %TimeStamp%
Return

_________________
SilverEdge78


Last edited by silveredge78 on June 17th, 2007, 8:09 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 9:47 am 
Offline

Joined: April 28th, 2006, 12:12 pm
Posts: 55
Quote:
Antonimo in the wrong forum wrote:
These are good scripts, but I would like to do something simpler - I would like to hit the hotkey combination and have today's date sent. I have tried to remove the gui that allows the user the choose the date, but I cannot get it to work.

Could somebody please help me?

It would be better to follow your topic in this forum, which is made to ... ask for help

May be this code shoud work (not tested). If you want to hit F2 yourself, comment the "SendInput, {F2}" line.
Code (Copy):
<+<^F2::
SendInput, {F2}
FormatTime, TodayDate,, yyyy-MM-dd
SendInput, %TodayDate% {Space}
Return

Is it OK for you ?

Thanks Supercalifragilistic,

This is exactly what I wanted achieve


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2008, 7:41 pm 
Offline

Joined: April 8th, 2008, 7:39 pm
Posts: 8
bennoman wrote:
I did some playing with the GUI and added a DDL to pick the format.
I also changed the way it presents the date, I used SendInput like silveredge78.
You pick the date and format and it will insert it where the cursor is.
This is my first GUI I've worked with and Im open to suggestions/criticism.
Here is the code.

Code:
; XXXXXXXXXXXXXXXXXXXXXxxxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;   Kalend Function
;      - If the user hit the ESC key, the returned result is O
; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
; ===============================
; =Modified by bennoman 06/15/07=
; ===============================

!`::
   SendInput % Kalend()
return 

Kalend()
{
   Global F03_Date
   Global FormatChoice
   Gui, 3:Add, Text, x6 y10 w130 h20,Enter the date :
   Gui, 3:Add, DateTime, x6 y25 w130 h20 vF03_Date,
   Gui, 3:Add, Text, x6 y50 w130 h20,Choose your format :
   Gui, 3:Add, DropDownList, x6 y65 w130 h180 vFormatChoice, mm/dd/yy||mm/dd/ccyy|dd/mm/yy|dd/mm/ccyy|ddmmyy|ddmmccyy|yy-mm-dd|ccyy-mm-dd|yymmdd|ccyymmdd
   Gui, 3:Add, Button, x6 y95 w60 h20 Default,&OK
   Gui, 3:Add, Button, x76 y95 w60 h20,&Cancel
   Gui, 3:Show, x562 y225 h125 w146, Date
   WinWaitClose, Date, Enter the date
   Return TD_RDate

   3GuiEscape:
      Gui, 3:cancel
      Gui, 3:Destroy
      TD_RDate = 0
   return

   3ButtonCancel:
   3GuiClose:
      Gui, 3:cancel
      Gui, 3:Destroy
   return

   3ButtonOK:
      Gui, 3:submit
      Gui, 3:Destroy
      If FormatChoice = mm/dd/yy
         FormatTime, TD_RDate, %F03_Date%, MM/dd/yy
      Else If FormatChoice = mm/dd/ccyy
         FormatTime, TD_RDate, %F03_Date%, MM/dd/yyyy
      Else If FormatChoice = dd/mm/yy
         FormatTime, TD_RDate, %F03_Date%, dd/MM/yy
      Else If FormatChoice = dd/mm/ccyy
         FormatTime, TD_RDate, %F03_Date%, dd/MM/yyyy
      Else If FormatChoice = ddmmyy
         FormatTime, TD_RDate, %F03_Date%, ddMMyy
      Else If FormatChoice = ddmmccyy
         FormatTime, TD_RDate, %F03_Date%, ddMMyyyy
      Else If FormatChoice = yy-mm-dd
         FormatTime, TD_RDate, %F03_Date%, yy-MM-dd
      Else If FormatChoice = ccyy-mm-dd
         FormatTime, TD_RDate, %F03_Date%, yyyy-MM-dd
      Else If FormatChoice = yymmdd
         FormatTime, TD_RDate, %F03_Date%, yyMMdd
      Else If FormatChoice = ccyymmdd
         FormatTime, TD_RDate, %F03_Date%, yyyyMMdd
   return
}


How would be the script, if I want the ISO/Format yyyy-mm-dd as the default set?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2008, 9:32 pm 
Offline

Joined: July 25th, 2006, 7:37 pm
Posts: 490
Location: Midwest, USA
Look at the Gui Control - DropDownList documentation. Specifically:

AHK's Manual wrote:
To have one of the items pre-selected when the window first appears, include two pipe characters after it. Alternatively, include in Options the word Choose followed immediately by the number to pre-select.

_________________
SilverEdge78


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 42 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group