Sign in to follow this  
Followers 0
Diana (Cda)

Syntax For Sending Values To Clipboard?

8 posts in this topic

I'm doing very well with the simple stuff I need AutoIt to do. But I've been stuck on a script for the last couple of days. I've searched through the messages but it's too much for me. I don't understand all the terms yet that people use so I can't figure out what to use of the examples for my own situation. My needs are pretty basic. I have a script that works perfectly, it returns today's date in a yyyy.mm.dd.ddd format (i.e., today shows up as 2004.08.14.Sat). I need to go one step further for other situations, sending the date in that format but to the clipboard.

I found ClipPut and ClipGet, but they seem to deal with actual text as all I got when I substituted Send with ClipPut was the syntax from my script and no date <lol>. Oh, well, d'uh, I know, but I thought it would work.

Here is the working script between asterisks below:

******************************

;

; AutoIt v3.0

;

Sleep(500)

#include <date.au3>

$thisday = _DateDayOfWeek( @WDAY, 1 )

Send(@YEAR & '.' & @MON & '.' & @MDAY & '.' & $thisday)

Exit

; finished

******************************

It works perfectly. Now I just need to modify this to send the information to the clipboard instead of to text output.

Any help appreciated. Thanks!

Share this post


Link to post
Share on other sites



How are you using ClipPut()?

.. ie: Can you post what are you trying that doesn't work?

Share this post


Link to post
Share on other sites

change Send to clipPut()

ClipPut(@YEAR & '.'  & @MON & '.'  & @MDAY & '.' & $thisday)

rest is fine, might want #include before sleep, but prolly just a matter of style.

Share this post


Link to post
Share on other sites

Hmmm :ph34r: .. that works for me ..

When I run it, and press CTRL-V, out pops a pretty date from my clipboard :(

Share this post


Link to post
Share on other sites

change Send to clipPut()

ClipPut(@YEAR & '.'  & @MON & '.'  & @MDAY & '.' & $thisday)

rest is fine, might want #include before sleep, but prolly just a matter of style.

<{POST_SNAPBACK}>

That did the trick! Thanks for this. Such a simple change, eh, to get it to work properly <sigh> <g>. I did try one of the "clip" commands, but didn't get the right output so I obviously didn't script it right.

One last question, if I may. I've run into this time and time again. This clipboard script is for when I'm naming files. When one uses this date format, _all_ files will always sort in proper chronological order. But it's a longish addition to a filename. I've been using shorter names for the day of week, which btw, I do need to add so can't leave that out. Is there a way to further modify the above script so that the days return a 2-character instead of 3-character result? i.e., Mon should be Mn, Tues = Tu, Weds = Wd, Thurs = Th, Fri = Fr, Sat = Sa and Sun = Sn?

Thanks so much!

Share this post


Link to post
Share on other sites

; the one-line solution

$thisday = StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", StringInStr("SunMonTueWedThuFriSat", _DateDayOfWeek(@WDAY,1) ), 2)

The better solution is to create a function.... You could even futher modify the function and get rid of the parameters if they never change.

$thisday = _short_DateDayOfWeek( @WDAY, 1 )
;....
Exit
Func _short_DateOfWeek($iDayNum, $Format)
   Local $d = _DateDayOfWeek( $iDayNum, $iFormat )
   Local $pos = StringInStr("SunMonTueWedThuFriSat", $day)
   Return StringMid($"SnMnTuWdThFrSa", $pos, 2)
EndFunc

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

; the one-line solution

$thisday = StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", StringInStr("SunMonTueWedThuFriSat", _DateDayOfWeek(@WDAY,1) ), 2)

The better solution is to create a function....

The first line above worked just fine. Is it necessary to do the function thing? Just curious. If I get results with one method, wondering why I should choose another. I'll never need to modify the dates again. This is pretty standard now.

Thanks.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

The first line above worked just fine.  Is it necessary to do the function thing?  Just curious.  If I get results with one method, wondering why I should choose another.  I'll never need to modify the dates again.  This is pretty standard now.

Thanks.

<{POST_SNAPBACK}>

So when you end up having to edit the code in six months, you'll look at the line and wonder "why the heck did I do that?" :ph34r: But maybe you're a lot better at commenting your code :(

P.S. Can you figure out why the one-line StringMid method works? There are many ways to solve a problem, and functions make programs easier to write/understand/debug... There might even be a better solution than the two I presented!

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0