| View previous topic :: View next topic |
| Author |
Message |
Katrina Guest
|
Posted: Fri Jul 16, 2004 4:21 am Post subject: Timestamp |
|
|
I want to automatically insert a timestamp onto the clipboard when I start my script so that when it pastes the contents, I have the date and time pasted without having to type it every time. Where I work, I have to manually type, the date and time before every note I make in the computer. It gets old really really fast. Anyway to automate this? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Fri Jul 16, 2004 4:40 am Post subject: |
|
|
This can be done by using some of the built-in date-time variables from http://www.autohotkey.com/docs/Variables.htm#YYYY
In example below, the hotkey Win+Z is made to insert a timestamp onto the clipboard. Note that this will only work if the clipboard contents are plain text because any formatting (such as HTML, fonts, etc.) is lost when you update the clipboard. This example also requires version 1.0.16 if you want to use any of the new month-name and day-name variables.
#z::
clipboard = %A_Hour%:%A_Min% -- %A_MM%/%A_DD%/%A_YYYY%`n%clipboard%
return
If you need to retain the HTML or other formatting on the clipboard, it's probably best to do this instead:
#z:: ; pastes timestamp and clipboard
Send %A_Hour%:%A_Min% -- %A_MM%/%A_DD%/%A_YYYY%`n^v
return
You can change the order and type of the date-time elements by referring to the link above. |
|
| Back to top |
|
 |
Katrina Guest
|
Posted: Mon Jul 19, 2004 1:37 am Post subject: Y doesn't my script work? |
|
|
Hmmmm, try as I might, I can't figure out why my script doesn't work. I wish I knew more about his stuff. I've been impressed with what I've seen other people accomplish in the "Scripts and Utilities" section. Why doesn't my simple little script work?
#z:: ;
clipboard = ;
clipboard = %A_MM%/%A_DD% %A_Hour%:%A_Min% TC`n%clipboard%
return
Sleep, 100
Send, {CTRLDOWN}v{CTRLUP}
I want it to paste current date and time into whatever open window I have when I press win/z. Since I use 3 different windows, I can't set a specific window name... but I have a feeling that is what is keeping this from working. What would be really really cool, is if I could use Rajat's ultracool "triggers" (found in "Use shortcut text realtime") script to insert the current date and time whenever I type a word such as `date. I know thats a little much to ask for, so I'll be happy if someone can tell me how to make THIS script work.  |
|
| Back to top |
|
 |
Katrina Guest
|
Posted: Mon Jul 19, 2004 1:46 am Post subject: Ok, I'm stupid... |
|
|
#z:: ;
clipboard = ;
Send %A_MM%/%A_DD% %A_Hour%:%A_Min% KC %clipboard%
Ok, I fixed it on my own... I reread what Chris wrote just after I hit submit... but I am still curious, any way to incorporate Rajat's "triggers" script? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Mon Jul 19, 2004 2:18 am Post subject: |
|
|
| Quote: | | to insert the current date and time whenever I type a word such as `date |
With the latest version, this should do the trick:
::``date::
Send %A_MM%/%A_DD% %A_Hour%:%A_Min% KC
return
Whenever you type `date, the date and time string will appear (you need `` in the definition to create a single literal accent).
Btw, in your script you don't have to empty the clipboard first. I thought you wanted to additionally paste what was on the clipboard, but apparently all you want to do is insert the date and time. Thus, the above should work without needing to do anything with the clipboard at all.
You can read more about this feature at http://www.autohotkey.com/docs/Hotstrings.htm |
|
| Back to top |
|
 |
Katrina Guest
|
Posted: Mon Jul 19, 2004 5:12 am Post subject: Ah hah! |
|
|
Thankyou for taking the time for little ole beginner code scripter...
Your program is so amazing that even ppl like me can use it... with a little help from others
So does this mean I can use multiple ::``date:: ie ::``name:: in the same script to create a script that will auto replace? I couldn't get it to work but I wonder if that is supported somehow? Your program is awesome.  |
|
| Back to top |
|
 |
Katrina Guest
|
Posted: Mon Jul 19, 2004 5:34 am Post subject: nevermind... |
|
|
When I said "beginner" I meant "stupid" I figured that one out too after I read your documentation. thanks for the help  |
|
| Back to top |
|
 |
|