Sign in to follow this  
Followers 0
jacob_1998_1999

(Solved)Type future date? _DateAdd()

9 posts in this topic

#1 ·  Posted (edited)

I have a little script written out to type out the present time/date on hotkey.My problem is that I would like it to actually type the date of 7 days in advance.I just don't know the technique to apply such a thing. Would anyone be able toguide me to a solution? Please and thank you. :)

Global $PausedHotKeySet("{PAUSE}", "TogglePause")HotKeySet("{ESC}", "Terminate")HotKeySet("{Insert}", "InsertTime")$time=_GetTodaysDate()While 1 Sleep(100)WEndFunc TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("")EndFunc ;==>TogglePauseFunc Terminate() Exit 0EndFunc ;==>TerminateFunc InsertTime() _GetTodaysDate()Send ($Time)EndFunc ;==>ShowMessageFunc _GetTodaysDate($iReturnTime = 1) Local $aMDay[8] = [7, "Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"], _ $aMonth[13] = [12, "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"], $aTime[2] = ["", ' ' & @HOUR & ':' & @MIN & ':' & '00'] Return $aMDay[@WDAY] & ', ' & @MDAY & ' ' & $aMonth[@MON] & ' ' & @YEAR & $aTime[$iReturnTime]EndFunc ;==>_GetTodaysDate
Edited by jacob_1998_1999

Share this post


Link to post
Share on other sites



Check out _DateAdd() in the Help File, should be exactly what you're looking for.

Share this post


Link to post
Share on other sites

Well damn, that is much simpler than the mess that I threw together. :) Ty.

Share this post


Link to post
Share on other sites

Well damn, that is much simpler than the mess that I threw together. :) Ty.

I agree :D

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I'm apparently skipping something.. I can't output the variable.. O_o Msgbox works, but Send will not.. Tried various things.. /headdesk.. The variable only outputs "2012" skips all Text and will not output the "/" apparently.

#include Date.au3
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{Insert}", "InsertTime")

Local $sNewDate = _DateAdd('n', 10080, _NowCalc())
MsgBox(4096, "", "Don't attack before: " & $sNewDate)
$PasteThis = ("Attack After: " + String($sNewDate))
While 1
Sleep(100)
WEnd


Func TogglePause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>TogglePause

Func Terminate()
Exit 0
EndFunc ;==>Terminate

Func InsertTime()

Send("This is lame...")
Send ($PasteThis)
Send ($sNewDate)
EndFunc ;==>ShowMessage
Edited by jacob_1998_1999

Share this post


Link to post
Share on other sites

k, apparently, I got it... Syntax errors...

#include <Date.au3>
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{Insert}", "InsertTime")

Local $sNewDate = _DateAdd('n', 10080, _NowCalc())
$PasteThis = ("Attack After: ")
While 1
    Sleep(100)
WEnd


Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func InsertTime()

Send ($PasteThis & $sNewDate)
EndFunc   ;==>ShowMessage

Share this post


Link to post
Share on other sites

*** You can't use +.. Forgot to use & to combine variables.

Share this post


Link to post
Share on other sites

If anyone else actually decides to use this, Remember simple things like... If you're going to call this, put it in the while loop. -_-

You'll never update the time, if you just create the variable when the program is ran.. You need to continuously have it updating the time. Just a little FYI. :)

Share this post


Link to post
Share on other sites

This is my updated script if anyone decides to build off of it in the future. :)

#include 
Global $Paused
Opt("TrayIconHide", 1)
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{Insert}", "InsertTime")


$PasteThis = ("Attack After: ")
While 1
Sleep(100)
ToolTip('Running.', 0, 0)
Local $sNewDate = _DateAdd('n', 10080, _NowCalc())
WEnd


Func TogglePause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>TogglePause

Func Terminate()
Exit 0
EndFunc ;==>Terminate

Func InsertTime()

Send ($PasteThis & $sNewDate)
EndFunc ;==>ShowMessage

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