Jump to content

Recommended Posts

Posted
I am using autoIt to handle the saveAs dialog box in selenium java. Here, I should save the pdf file in required directory
ControlFocus("Save As","","Edit1")
ControlSend("Save As","","Edit1","-----My file path\file_name.pdf")
ControlClick("Save As","","Button2")

Is it possible to add today's date or last weekend date(Saturday) in my file name and send in the file path to get saved?

Posted
23 minutes ago, emiley said:

Is it possible to add today's date ... in my file name and send in the file path to get saved?

[NOT TESTED]

Local $sFilepath = "-----My file path\file_name" & "-" & @YEAR & "-" & @Mon & "-" & @MDAY & ".pdf"
ControlFocus("Save As","","Edit1")
ControlSend("Save As","","Edit1",$sFilepath)
ControlClick("Save As","","Button2")

 

Posted
30 minutes ago, Musashi said:

[NOT TESTED]

Local $sFilepath = "-----My file path\file_name" & "-" & @YEAR & "-" & @Mon & "-" & @MDAY & ".pdf"
ControlFocus("Save As","","Edit1")
ControlSend("Save As","","Edit1",$sFilepath)
ControlClick("Save As","","Button2")

 

Thanks, it added today's date in my file name! But, I am still trying to figure out how to add last weekend (saturday) date here.

Posted
2 hours ago, emiley said:

Thanks, it added today's date in my file name! But, I am still trying to figure out how to add last weekend (saturday) date here.

Try this :

#include <Date.au3>

Local $sFilepath, $sCurrentDate, $aYMD, $iWeekday, $sDateLastSaturday
$sCurrentDate = _NowCalcDate()
$aYMD = StringSplit($sCurrentDate, "/", 2)
$iWeekday  =  _DateToDayOfWeek($aYMD[0], $aYMD[1], $aYMD[2])
$sDateLastSaturday = _DateAdd("D", - $iWeekday, $sCurrentDate)
$sFilepath = "-----My file path\file_name" & "-" & StringReplace($sDateLastSaturday, "/", "-") & ".pdf"
ControlFocus("Save As","","Edit1")
ControlSend("Save As","","Edit1",$sFilepath)
ControlClick("Save As","","Button2")

 

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
×
×
  • Create New...