Sign in to follow this  
Followers 0
Falling

Function that changes Windows Calendar Time?

27 posts in this topic

#1 ·  Posted (edited)

Sorry, if not could someone give me some tips on how to start a project like this?

What i would want to do is use a function that you enter a parametor like

ChangeTime(10, 5, 1985, 4:50pm).

The call to that function would set the calendar in windows to 10/5/1985 at 4:50pm)

The exact time part is not that important really. It's mainly changing the date.

Edited by Falling

Share this post


Link to post
Share on other sites



If you are willing to change (or parse) the date and time format, you could write a function that wraps the DOS "Date" and "Time" functions. Maybe someone else knows a better way.

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

Could you expand on what you said? Like give more meat and less bone? What you said kind of went over my head.

If you change DOS time windows time changes also?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Could you expand on what you said?  Like give more meat and less bone?  What you said kind of went over my head.

If you change DOS time windows time changes also?

<{POST_SNAPBACK}>

Run(@comspec & " /c date 01/01/2004") will change the date to jan 1, 2004

so all you need to do is do run commands for date and time to accomplish what you want.

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

At least in 2000/XP the DOS prompt is just emulated. This means that DOS gets its time from Windows.

Using the Run (AutoIt) command you could execute "Time time to change to" and "Date date to change to" You can find more on this on the internet. Just google the DOS "Date" and "Time" commands. Or you can always just try it... go to the command prompt and type in "Date /?" and "Time /?". This will give you the help provided for these commands.

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Consider using

http://www.softshape.net/download/cmdtime.zip

cmdtime3 for a nice command line apps that sets the clock perfectly.

Edit: oh... I had the clock wrong for 2 seconds!! Thanks cmdtime3. :)

Edit2: time is only one per system. Worry not Falling.

Most probably it is even shared between OS.

Edited by ezzetabi

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Consider using cmdtime3 for a nice command line apps that sets the clock perfectly.

How does this differ from the intrinsic commands provided by windows?

ADDITION: Nevermind, I figured it out. Depending on the situation you are setting the date and time for, this could or may not be useful. It requires an internet connection, and in his example above:

ChangeTime(10, 5, 1985, 4:50pm)
Edited by Matt @ MPCS

Share this post


Link to post
Share on other sites

1. That not all Windows have it.

2. Easy of use. Why use a whole service for a so simple thing?

3. Who care? I like it. :)

Share this post


Link to post
Share on other sites

actually i think that compec line will be exactly what i need.

I need to change dates randomly actually.

Date will change months at a time in my program to determain APR Rates and such.

Share this post


Link to post
Share on other sites

Lemme think... Time limited programs?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Here it is the function i was asking for. Thanks for all your suggestions. But especially to JdeB for the excelent 1 line command and to Matt @ MPCS for explaining how it works.

Func ChangeDateStupidComputer($M, $D, $Y)
  Run(@comspec & " /c date " & $M &"/"& $D &"/"& $Y &"")
EndFunc

ChangeDateStupidComputer("2","3","1981")

This is prob a good method, because now i can make a ChangeTimeStupidComputer that is independent.

--------------------

If only i could get that crazy dos box from popping up. Even if it is for only a split secound.

Edited by Falling

Share this post


Link to post
Share on other sites

I have personally had problems with it but you could try setting the "flag" parameter of the Run command. Set it to @SW_HIDE.

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

If only i could get that crazy dos box from popping up.  Even if it is for only a split secound.

<{POST_SNAPBACK}>

Run(@comspec & " /c date " & $M &"/"& $D &"/"& $Y, "", @SW_HIDE) :)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

What about?

Func ChangeDateStupidComputer($M, $D, $Y)
 Run(@comspec & " /c date " & $M &"/"& $D &"/"& $Y,'',@sw_hide)
EndFunc

ChangeDateStupidComputer("2","3","1981")]

Actually Matt was the first with the date idea...

Edited by ezzetabi

Share this post


Link to post
Share on other sites

Wow. Three answers at the same time!

Share this post


Link to post
Share on other sites

I was with the @SW_HIDE idea too... but it doesn't matter as long as he gets help.

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

==> Unable to execute the external program.:

Run(@comspec & " /c date " & $M &"/"& $D &"/"& $Y &"", @SW_HIDE)

The directory name is invalid.

Guess for WinXP this @SW_HIDE does not work?

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Guess you can't copy and paste.

Try

Run(@comspec & " /c date " & $M &"/"& $D &"/"& $Y &"","", @SW_HIDE)

Edited by ezzetabi

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

You miscopied their code, it is:

Run(@comspec & " /c date " & $M &"/"& $D &"/"& $Y[b], "",[/b] @SW_HIDE)

*** Matt @ MPCS

EDIT: Damn I was late on that one

Edited by Matt @ MPCS

Share this post


Link to post
Share on other sites

==> Unable to execute the external program.:

Run(@comspec & " /c date " & $M &"/"& $D &"/"& $Y &"", @SW_HIDE)

The directory name is invalid.

Guess for WinXP this @SW_HIDE does not work?

<{POST_SNAPBACK}>

look at what is posted and your code... it is different !!

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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