Welcome Guest.   Make a donation to an author on the site October 31, 2014, 05:14:05 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Learn about the DonationCoder.com microdonation system (DonationCredits).
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Insert future or past date as text  (Read 5574 times)
willwilliams
Supporting Member
**
Posts: 12

View Profile Give some DonationCredits to this forum member
« on: June 14, 2008, 03:23:28 PM »

Hi

My request follows on from the previous one.

I have adapted some programming (I think Kartal put it forward) so that I can put today's date in yymmdd format as the first part of name of a new file.

:*:yz::
FormatTime, CurrentDateTime,, yyMMdd
SendInput %CurrentDateTime%
return

It sits as part of my universal autocorrect file, so is there for me to us, by pressing "yz"


In Word, I have used a great macro that lets you enter future or past dates, by entering the number of days ahead, or past you want to have a date for - "7" or "-7", for example - in a dialog box that comes up when you call up the macro

********************************
Sub InsertFutureDate()
' Written by Graham Mayor and posted on the word.docmanagement newsgroup in
' March 2000
' Inserts a future date in a document - note that this is not a field
' Some style revisions and error handler by Charles Kenyon
'
Dim Message As String
Dim Mask As String
Dim Title As String
Dim Default As String
Dim Date1 As String
Dim MyValue As Variant
Dim MyText As String
Dim Var1 As String
Dim Var2 As String
Dim Var3 As String
Dim Var4 As String
Dim Var5 As String
Dim Var6 As String
Dim Var7 As String
Dim Var8 As String
'

'Date mask below includes non-breaking spaces (Chr(160))
Mask = "d" & Chr(160) & "MMMM" & Chr(160) & "yyyy" ' Set Date format
Default = "14" ' Set default.
Title = "Plus or minus date starting with " & Format(Date, Mask)
Date1 = Format(Date, Mask)
Var1 = "Enter number of days by which to vary above date. " _
& "The number entered will be added to "
Var2 = Format(Date + Default, Mask) ' Today plus default (14)
Var3 = Format(Date - Default, Mask) ' Today minus default (14)
Var4 = ". The default ("
Var5 = ") will produce the date "
Var6 = ". Minus (-"
Var7 = ". Entering '0' (zero) will insert "
Var8 = " (today). Click cancel to quit."
MyText = Var1 & Date1 & Var4 & Default & Var5 & Var2 & Var6 _
& Default & Var5 & Var3 & Var7 & Date1 & Var8
'
' Display InputBox and get number of days
GetInput:
MyValue = InputBox(MyText, Title, Default)
'
If MyValue = "" Then
    End 'quit subroutine
End If
'
On Error GoTo Oops 'just in case
Selection.InsertBefore Format((Date + MyValue), Mask)
Selection.Collapse (wdCollapseEnd)
End 'End subroutine
'
Oops: ' error handler in case user types something other than a number
'
MsgBox Prompt:="Sorry, only a number will work, please try again.", _
Buttons:=vbExclamation, _
Title:="A number is needed here."
GoTo GetInput
End Sub
*******************************

It would be great if there could be something like it in AHK

Will
Logged
skrommel
Fastest code in the west
Developer
***
Posts: 882



View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: June 14, 2008, 04:49:21 PM »

 smiley Try OneDay!

It shows the date x days from a given date.

Skrommel


[copy or print]
;OneDay.ahk
; Shows the date x days from a given date
;Skrommel @ 2008

#NoEnv
#SingleInstance,Force
SendMode,Input

format=dddd dd. MMMM yyyy

applicationname=OneDay

activeid:=WinExist("A")
WinGetTitle,activetitle,ahk_id %activeid%

Gui,Add,Edit,xm w200 R1 -Wrap Vahead GCALC,0
Gui,Add,UpDown,Range-2147483648-2147483647
Gui,Add,Text,x+10 yp+3,days from
Gui,Add,DateTime,xm w200 Vfrom GCALC,%format%
Gui,Add,Text,x+10 yp+3,is
Gui,Add,Edit,xm w200 Vto
Gui,Add,Button,x+10 W60 GCOPY,&Copy
Gui,Add,Button,x+10 W60 GSEND Default,&Send to
Gui,Add,Statusbar,G1HOURSOFTWARE,www.1HourSoftware.com
Gui,Show,,%applicationname%
Gui,+LastFound
guiid:=WinExist()
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
OnMessage(0x200,"WM_MOUSEMOVE")
OnExit,EXIT
Return


CALC:
Gui,Submit,NoHide
EnvAdd,from,%ahead%,Days
FormatTime,to,%from%,%format%
GuiControl,,to,%to%
Return


COPY:
Clipboard=%to%
TOOLTIP(to)
Return


SEND:
Gui,Submit
IfWinExist,ahk_id %activeid%
{
  WinActivate,ahk_id %activeid%
  WinWaitActive,ahk_id %activeid%,,5
}
Send,%to%
Gosub,EXIT


TOOLTIP(tip)
{
  SetTimer,TOOLTIPOFF,Off
  ToolTip,%tip%
  SetTimer,TOOLTIPOFF,3000
}


TOOLTIPOFF:
SetTimer,TOOLTIPOFF,Off
ToolTip,
Return


1HOURSOFTWARE:
Run,www.1HourSoftware.com
Return


WM_MOUSEMOVE(wParam,lParam)
{
  Global hCurs
  Global guiid
  Global activetitle

  MouseGetPos,,,mwin,mctrl
  If mwin Not in %guiid%
    Return
  If mctrl In msctls_statusbar321
    DllCall("SetCursor","UInt",hCurs)
  If mctrl In Button2
    TOOLTIP(activetitle)
  Return
}


GuiEscape:
GuiClose:
EXIT:
OnMessage(0x200,"")
DllCall("DestroyCursor","Uint",hCurs)
ExitApp
« Last Edit: June 20, 2008, 04:24:48 PM by skrommel » Logged

Please stop by my site at  1 Hour Software by skrommel  for downloads and more info.
Perry Mowbray
N.A.N.Y. Organizer
Charter Member
***
Posts: 1,807



Thoughtful Scribbles

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: June 15, 2008, 06:37:54 AM »

Also, FARR has a new Clock Plugin, which was pretty easy to add the ability to use some past or future time. Clock is not my plugin though, but I presume we can change our own copies?

Anyway, it's a nice FARR Plugin which means it's quite versatile.
Logged

willwilliams
Supporting Member
**
Posts: 12

View Profile Give some DonationCredits to this forum member
« Reply #3 on: June 17, 2008, 02:23:21 PM »

Thanks!

Can OneDay be modfied so that the result of the input asking what the day and date will be in X days' time can be pasted into the app I was in before i called OneDay?
Logged
skrommel
Fastest code in the west
Developer
***
Posts: 882



View Profile WWW Give some DonationCredits to this forum member
« Reply #4 on: June 18, 2008, 11:43:09 AM »

 smiley I've added a "Copy" and "Send to" button to the code above.

Skrommel
« Last Edit: June 20, 2008, 04:25:13 PM by skrommel » Logged

Please stop by my site at  1 Hour Software by skrommel  for downloads and more info.
skrommel
Fastest code in the west
Developer
***
Posts: 882



View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: June 20, 2008, 04:26:06 PM »

 smiley And I've made the Enter key push the "Paste to" button.

Skrommel
Logged

Please stop by my site at  1 Hour Software by skrommel  for downloads and more info.
willwilliams
Supporting Member
**
Posts: 12

View Profile Give some DonationCredits to this forum member
« Reply #6 on: June 20, 2008, 04:35:33 PM »

That's it!

I am in some other app.  I have used a keyboard shortcut to run the code - Ctrl-Alt-b, so that's how I can bring up OneDay

I enter into the box the number of days forward (or backwards) I want to write (or leave it as 0 to get today's date)

Then press enter.

Great job, thanks.

Will
Logged
willwilliams
Supporting Member
**
Posts: 12

View Profile Give some DonationCredits to this forum member
« Reply #7 on: June 20, 2008, 04:38:51 PM »

Oh, I've tweaked the date format to suit my own preference - for example, Friday 20 June 2008 or Friday 4 July 2008.  (I knew how to do that much - Grin!)
Logged
willwilliams
Supporting Member
**
Posts: 12

View Profile Give some DonationCredits to this forum member
« Reply #8 on: June 20, 2008, 04:50:32 PM »

Just to make myself clear.  I have OneDay.  I have copies OneDay and made a shortcut icon of it.  In the properties dialog of the shortcut icon, ctrl-alt-b is the shortcut key.

I am pleased with the OneDay
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.031s | Server load: 0.07 ]