Jump to content

Change the date from Windows


 Share

Recommended Posts

I want to change the date to 17.01.2007

I use the next code:

Opt("TrayIconDebug", 1)
Opt("SendKeyDelay", 200)
Run("rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,0")
WinActivate("Date and Time Properties", "")
ControlCommand("Date and Time Properties", "", "ComboBox1", "ShowDropDown", "")
Send("{UP 11}")
ControlCommand("Date and Time Properties", "", "ComboBox1", "HideDropDown", "")
ControlSetText("Date and Time Properties", "", "Edit2", "")
Sleep(1000)
ControlSetText("Date and Time Properties", "", "Edit2", "2007")
Send("{TAB 9}")
Send("{ENTER}")
Send("{TAB 7}")
Send("{ENTER}")oÝ÷ ÙIߢ»n«^+ayÖ²q©÷öÖÞr§çm£^ðØméÞÆ×(f§u§]yÖµêíéZ²Ð¨Úè'­Mìmr¦jwZºÚ"µÍÛÛÛÛXÚÊ ][ÝÑ]H[[YHÜYÉ][ÝË ][ÝÉ][ÝË    ][ÝÐØ[ÛXZ[I][ÝË   ][ÝÛY ][ÝËK
ÎK

Any ideas?

Edited by dexter23
Link to comment
Share on other sites

C:\Program Files\AutoIt3\Include\date.au3

; #FUNCTION# ====================================================================================================

================
; Name...........: _Date_Time_SetSystemTime
; Description ...: Sets the current system time and date, expressed in UTC
; Syntax.........: _Date_Time_SetSystemTime($pSystemTime)
; Parameters ....: $pSystemTime - Pointer to a $tagSYSTEMTIME structure that contains the new system date and time
; Return values .: Success    - True
;                 Failure     - False
; Author ........: Paul Campbell (PaulIA)
; Modified.......:
; Remarks .......: The SetLocalTime function enables the SE_SYSTEMTIME_NAME privilege before changing the local time
; Related .......: _Date_Time_GetSystemTime, $tagSYSTEMTIME
; Link ..........;
; Example .......; Yes
; ====================================================================================================

===========================
Func _Date_Time_SetSystemTime($pSystemTime)
    Local $aResult

    $aResult = DllCall("Kernel32.dll", "int", "SetSystemTime", "ptr", $pSystemTime)
    Return SetError($aResult[0] = 0, 0, $aResult[0] <> 0)
EndFunc  ;==>_Date_Time_SetSystemTime
Link to comment
Share on other sites

Thx

Another idea: how can I get the curent date and stored then into a variable?

Look into AutoIt helpfile at _Date_Time_SetSystemTime() --> example

$tCur = _Date_Time_GetSystemTime()
MsgBox(0,"Result","Current system date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))
Edited by Zedna
Link to comment
Share on other sites

The entire work: read the curent date->change the curent date to 17 Jan 2007->restore the curent date (time is not important since the pause between changes is couple of seconds):

#include <Date.au3>

$tCur = _Date_Time_GetSystemTime()
$tNew = _Date_Time_EncodeSystemTime(1, 17, 2007)
_Date_Time_SetSystemTime(DllStructGetPtr($tNew))
Sleep(5000)
_Date_Time_SetSystemTime(DllStructGetPtr($tCur))

Thx for your help.

Link to comment
Share on other sites

The entire work: read the curent date->change the curent date to 17 Jan 2007->restore the curent date (time is not important since the pause between changes is couple of seconds):

#include <Date.au3>

$tCur = _Date_Time_GetSystemTime()
$tNew = _Date_Time_EncodeSystemTime(1, 17, 2007)
_Date_Time_SetSystemTime(DllStructGetPtr($tNew))
Sleep(5000)
_Date_Time_SetSystemTime(DllStructGetPtr($tCur))

Thx for your help.

Now look back at your first post and its code ;-)

It's nice to see the real POWER of AutoIt!

Link to comment
Share on other sites

  • 1 year later...
  • 3 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...