AutoHotkey Community

It is currently May 27th, 2012, 11:39 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: October 7th, 2005, 5:15 pm 
Code:
TheDate := A_Now
MsgBox, % TheDate
FormatTime, TheDate,, dd-MM-yy
MsgBox, % TheDate
Run, %COMSPEC% /k date %TheDate%,,max


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 7th, 2005, 5:44 pm 
Offline

Joined: October 4th, 2005, 5:39 pm
Posts: 32
The same problem as before.
I also try; "FormatTime, TheDate,, MM-dd-yy " but still the same problem.
What is the way if I use default MM/DD/YYYY ? because I am not 100% sure about my default date.

_________________
thanks

WIN XP PRO


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 7th, 2005, 8:24 pm 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2250
Location: switzerland
(DOS) run,execute, cmd or command, type in: date and ENTER
see the format
to change date I used this script
Code:
InputBox,D,Send Date to DOS,TT-MM-YY       
if ErrorLevel <> 0
    ExitApp
Run %COMSPEC% /C date %D%,,hide
msgbox,%A_NOW%   ;YYYYMMDDHHMNSS
ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 8th, 2005, 9:46 am 
Offline

Joined: October 4th, 2005, 5:39 pm
Posts: 32
:( why DOS script (.bat) is working very good , without invert the month and date and script of .ahk can not do the same?
"set stam=%date%
set stam=%stam:~-10%
date=%stam% "

can this script of DOS translated to ahk format?

_________________
thanks

WIN XP PRO


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 8th, 2005, 10:20 am 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2250
Location: switzerland
just how to run bat or DOS commands
xy.bat:
Code:
set stam=%date%
set stam=%stam:~-10%
date=%stam%
rem pause
xy.ahk
Code:
run %COMSPEC% /K xy.bat
Code:
run %COMSPEC% /K dir
run %COMSPEC% /C dir  ;hidden


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 8th, 2005, 10:30 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
You beat me :)

Anyway, the DllCall documentation could probably use another structure-passing example, so here's one that changes the clock via DllCall("SetSystemTime").

Only the very first line needs to be altered. All the rest just takes care of actually setting the specified time. Use caution when changing to a date in the future as it may cause scheduled tasks to run prematurely!

Code:
SetSystemTime("20051008142211")  ; Pass it a timestamp (local not UTC).

SetSystemTime(YYYYMMDDHHMISS)
; Sets the system clock to the specified date and time.
; Caller must ensure that the incoming parameter is a valid date-time stamp
; (local time, not UTC). Returns non-zero on success and zero otherwise.
{
   ; Convert the parameter from local time to UTC for use with SetSystemTime().
   UTC_Delta -= %A_NowUTC%, Seconds  ; Seconds is more accurate due to rounding issue.
   UTC_Delta := Round(-UTC_Delta/60) ; Round to nearest minute to ensure accuracy.
   YYYYMMDDHHMISS += %UTC_Delta%, Minutes

   VarSetCapacity(SystemTime, 16, 0)  ; Struct consists of 8 UShorts (i.e. 8*2=16)

   StringLeft, Int, YYYYMMDDHHMISS, 4    ; YYYY (year)
   InsertInteger(Int, SystemTime, 0, 2)
   StringMid, Int, YYYYMMDDHHMISS, 5, 2  ; MM (month of year, 1-12)
   InsertInteger(Int, SystemTime, 2, 2)
   StringMid, Int, YYYYMMDDHHMISS, 7, 2  ; DD (day of month)
   InsertInteger(Int, SystemTime, 6, 2)
   StringMid, Int, YYYYMMDDHHMISS, 9, 2  ; HH (hour in 24-hour time)
   InsertInteger(Int, SystemTime, 8, 2)
   StringMid, Int, YYYYMMDDHHMISS, 11, 2 ; MI (minute)
   InsertInteger(Int, SystemTime, 10, 2)
   StringMid, Int, YYYYMMDDHHMISS, 13, 2 ; SS (second)
   InsertInteger(Int, SystemTime, 12, 2)

   return DllCall("SetSystemTime", str, SystemTime)
}

InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
{
   mask := 0xFF  ; This serves to isolate each byte, one by one.
   Loop %pSize%  ; Copy each byte in the integer into the structure as raw binary data.
   {
      DllCall("RtlFillMemory", UInt, &pDest + pOffset + A_Index - 1, UInt, 1
         , UChar, (pInteger & mask) >> 8 * (A_Index - 1))
      mask := mask << 8  ; Set it up for isolation of the next byte.
   }
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSN [Bot] and 17 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group