Calendar Countdown

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

Post Reply
Gormm
Newbie
Posts: 3
Joined: Tue Mar 25, 2008 6:11 am

Calendar Countdown

Post by Gormm » Tue Mar 25, 2008 6:20 am

I need help making a calendar countdown script.

Something like "Today is March 24 2008. 22 days until April 15 2008."

Thanks!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Mar 25, 2008 7:12 am

Here you go:

Code: Select all

//Set the following three vars to suit your target date
Let>TargetDay=15
Let>TargetMonth=4
Let>TargetYear=2008

VBSTART
VBEND

VBEval>DateDiff("d",Date(),DateSerial(%TargetYear%,%TargetMonth%,%TargetDay%)),daysDif

VBEval>FormatDateTime(Date(),1),TodayFormatted
VBEval>FormatDateTime(DateSerial(%TargetYear%,%TargetMonth%,%TargetDay%),1),TargetFormatted

MessageModal>Today is %TodayFormatted%. %daysDif% days until %TargetFormatted%
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Gormm
Newbie
Posts: 3
Joined: Tue Mar 25, 2008 6:11 am

Post by Gormm » Tue Mar 25, 2008 8:00 am

It works just as I wanted. Thanks!

Now I'm trying to copy and paste it instead of using the MessageModal.

Your example: MessageModal>Today is %TodayFormatted%. %daysDif% days until %TargetFormatted%

Here's what I've got so far:

PutClipBoard>Today is %TodayFormatted%. %daysDif% days until %TargetFormatted%...
Wait>1
GetClipBoard>I don't know what to put here


I don't know what to put in the GetClipBoard to make it paste...

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Mar 25, 2008 8:16 am

PutClipboard puts the text on the clipboard.

GetClipBoard retrieves the clipboard text from the clipboard to a variable.

So you're taking a variable, putting it on the clipboard, then retrieving to a variable again. Circular, pointless and not what you want.

After your PutClipBoard command the text is on the clipboard. Now you can paste it. In most apps the way we paste is by doing CTRL+V. That's the most common keyboard shortcut for pasting. We can simulate this with:

Press CTRL
Send>v
Release CTRL

The script presses CTRL, then sends the v key, then releases CTRL. It does a CTRL+v.

However, why use the clipboard? Why not just type the text into the target application using keystrokes.

Also the script needs to focus the app you want to paste into.

Try this example script which creates the countdown text, runs Notepad and then types it into Notepad:

Code: Select all

//Set the following three vars to suit your target date
Let>TargetDay=15
Let>TargetMonth=4
Let>TargetYear=2008

VBSTART
VBEND

VBEval>DateDiff("d",Date(),DateSerial(%TargetYear%,%TargetMonth%,%TargetDay%)),daysDif

VBEval>FormatDateTime(Date(),1),TodayFormatted
VBEval>FormatDateTime(DateSerial(%TargetYear%,%TargetMonth%,%TargetDay%),1),TargetFormatted

Let>cdString=Today is %TodayFormatted%. %daysDif% days until %TargetFormatted%

Run>Notepad.exe
WaitWindowOpen>notepad*
Wait>0.5
SetFocus>notepad*
Send>cdString
Now, you're going to need to change the SetFocus line to focus your particular window - the one you want the text sent to. You may also need to ensure the correct field is focused. You may have to do that by "tabbing" through the fields by issusing "Press Tab" several times [In Windows when you press the tab key you move from field/object to field/object].

If all the above is new to you then you really should read the Scripting Windows for Beginners guide in the help file. Take a look at:
http://www.mjtnet.com/blog/2008/03/21/r ... resources/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Gormm
Newbie
Posts: 3
Joined: Tue Mar 25, 2008 6:11 am

Post by Gormm » Tue Mar 25, 2008 8:21 am

The...

Press CTRL
Send>v
Release CTRL


....was all that it needed.

Thanks!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts