Code: Select all
If winactive("ahk_class TROLineDlg")
{
ControlGetText, DateinputIllegal, TmtDBDateDialog1 ;Get Date from date field
Msgbox Illegal text is %DateinputIllegal%
StringReplace, CorrectedDateInput, DateinputIllegal, /,,All ;Remove backslashes from date
Msgbox Corrected date is %CorrectedDateInput%
StringLeft, ShortenedCorrectedDateInput, CorrectedDateInput, 4 ;Grab first four characters of original date input (Farther up in code)
StringLeft, ShortenedCorrectedRODate, CorrectedRODate, 4 ;Grab first four characters of incorrect date for analysis
msgbox Shortened original date is "%ShortenedCorrectedRODate%" `nShortened date is "%ShortenedCorrectedDateInput%" ;Print values to screen
Sleep 1500
If (ShortenedCorrectedDateInput != %ShortenedCorrectedRODate%) ;Compare value of variables
{
Msgbox,4, Warning, Dates don't match. `nShortenedCorrectedRODate = %ShortenedCorrectedRODate% `nShortenedCorrectedDateInput = %ShortenedCorrectedDateInput% `nCommencing date change, 4
ifmsgbox No
Break
TrayTip,, Corrected RO Date %CorrectedRODate%
Sleep 1000
ControlGetFocus, FocusReturnFunction,
TrayTip, Update, Starting focus was %FocusReturnFunction%.
Sleep 1000
ControlFocus, TmtDBDateDialog1
Sleep 1000
ControlSend, TmtDBDateDialog1, %CorrectedRODate%, A
Sleep 1000
ControlFocus, %FocusReturnFunction%
ControlGetText, Dialog2Date, TmtDBDateDialog1
TrayTip, Update, Dialog 2 Date: %Dialog2Date%
Sleep 1000
}
Higher up this scrip is is pulling a date from one input box, which has the form "11/12/14," and stripping it of it's backslashes, resulting in "111214". Then this section of script is supposed to check another date box, which is unfortunately in the form of "11/18/2014" (today). So in order to do the comparison I stripped it of it's slashes, and then using LeftString Stripping both variables down to their first four characters, so they read "1112" and "1118." So far so good. It changes the date, and then should check again.
Here's where I run into trouble. Even though both variables have the same number (and the MsgBox tells me so), it still thinks that they're not equal. I'm probably just missing a piece of syntax, right?
Thanks!
Paul