#include <MsgBoxConstants.au3>
#include <Word.au3>
#include <Date.au3>
#include <FileConstants.au3>
Local $plainText = StringRegExpReplace(ClipGet(),"(?i)([^a-z0-9-_ .:()/])","")
$plainText = StringReplace($plainText," "," ")
if StringInStr($plainText,"Test Description")=0 then Exit MsgBox($MB_SYSTEMMODAL,"Error", "Invalid content copied. Please copy again")
Local $pOinter = StringSplit(StringSplit($plainText,"TC_","1")[2],"Test Description","1")
Local $testCaseID = "TC_" & $pOinter[1]
$pOinter = StringSplit(StringSplit($plainText,"Test Description","1")[2],"Expected Result","1")
Local $testDesc = $pOinter[1]
$pOinter = StringSplit(StringSplit($plainText,"Expected Result","1")[2],"Actual Result","1")
Local $expResult = $pOinter[1]
$pOinter = StringSplit(StringSplit($plainText,"Feature","1")[2],"Assignee","1")
Local $feature = $pOinter[1]
ConsoleWrite($testCaseID & @LF)
ConsoleWrite(StringLen($testDesc) & @LF)
ConsoleWrite($expResult & @LF)
ConsoleWrite($feature & @LF)
ConsoleWrite(_NowDate())
FileCopy(@ScriptDir & "\Sample.docx", @ScriptDir & "\TestCrew Wallet-Release 2-Sprint6+-SIT-" & $testCaseID & ".docx")
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSaveAs Example", _
"Error saving the Word document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\TestCrew Wallet-Release 2-Sprint6+-SIT-" & $testCaseID &".docx", Default, Default, Default)
_Word_DocFindReplace($oDoc, "<date>", _NowDate())
_Word_DocFindReplace($oDoc, "<FEATURE>",$feature)
_Word_DocFindReplace($oDoc, "<TESTID>",$testCaseID)
$i = StringLen($expResult)
$sTart = 1
$rePlace = "<exp>"
While $i>200
_Word_DocFindReplace($oDoc, $rePlace,StringMid($expResult,$sTart,200) & "<exp>")
$i = $i-200
$sTart = $sTart + 200
WEnd
_Word_DocFindReplace($oDoc, $rePlace,StringMid($expResult,$sTart,StringLen($expResult)))
$i = StringLen($testDesc)
$sTart = 1
$rePlace = "<desc>"
While $i>200
_Word_DocFindReplace($oDoc, $rePlace,StringMid($testDesc,$sTart,200) & "<desc>")
$i = $i-200
$sTart = $sTart + 200
WEnd
_Word_DocFindReplace($oDoc, $rePlace,StringMid($testDesc,$sTart,StringLen($testDesc)))
;_Word_DocSave($oDoc);s, @ScriptDir & "\NewFile.docx")
;If @error Then Exit MsgBox($MB_SYSTEMMODAL, @error , @extended)
Automate Wherever/Whatever Possible !!
Saturday 3 July 2021
Create POT doc. Editing word file
Play any song on Youtube... skip search results
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
Local $sAnswer = InputBox("Question", "Type the name of the song")
$url = "https://www.youtube.com/results?search_query=" & StringReplace($sAnswer," ","%20")
ShellExecute ("firefox.exe",$url)
Sleep(3000)
MouseClick($MOUSE_CLICK_LEFT, 400, 300, 2)
Thursday 2 May 2019
Send mail without using port explicitly
There was a time when I was in the mid of automation. Everything from a to z I just wanted to automate. This was one of my personal items which I thought to have myself the mail delivered in case of failure.
#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <ie.au3>
#include <file.au3>
#include <FileConstants.au3>
$file = @DesktopDir&"\mahabharat.txt"
FileOpen($file, 0)
For $i = 1 to _FileCountLines($file)
$line = FileReadLine($file, $i)
Local $hDownload = InetGet($line, @DesktopDir & "\" & StringRight($line,6) , $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
Do
Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
ConsoleWrite($line&@CRLF)
Next
FileClose($file)
To download all the episodes of Mahabharat
There was a time when I became a dying hard fan of Mahabharat, I waned to watch each and every episode of BR Chopra's. I had a notepad file that had all the links. Now I just needed to download them one by one. So here's what I wrote:-
#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <ie.au3>
#include <file.au3>
#include <FileConstants.au3>
$file = @DesktopDir&"\mahabharat.txt"
FileOpen($file, 0)
For $i = 1 to _FileCountLines($file)
$line = FileReadLine($file, $i)
Local $hDownload = InetGet($line, @DesktopDir & "\" & StringRight($line,6) , $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
Do
Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
ConsoleWrite($line&@CRLF)
Next
FileClose($file)
Thursday 30 March 2017
Wednesday 28 December 2016
VBS serving an alarm
Dim Input
Input = InputBox("Enter Time in same format as Current Time : "& left(time(),5),"Alarm")
If len(Input)=5 and instr(Input,":")>1 then
Set oShell = WScript.CreateObject ("WScript.Shell")
reqTime = left(time(),5)
msgbox "Alarm set for "&left(Input,2)-left(reqTime,2)&" hours and "&right(Input,2)-right(reqTime,2)&" minutes"
Do
If left(time(),5)=Input then
oShell.run "calc.exe"
Exit Do
End if
Loop
Set oShell = Nothing
Else
msgbox "Wrong format: try again !!"
End If
Input = InputBox("Enter Time in same format as Current Time : "& left(time(),5),"Alarm")
If len(Input)=5 and instr(Input,":")>1 then
Set oShell = WScript.CreateObject ("WScript.Shell")
reqTime = left(time(),5)
msgbox "Alarm set for "&left(Input,2)-left(reqTime,2)&" hours and "&right(Input,2)-right(reqTime,2)&" minutes"
Do
If left(time(),5)=Input then
oShell.run "calc.exe"
Exit Do
End if
Loop
Set oShell = Nothing
Else
msgbox "Wrong format: try again !!"
End If
Wednesday 11 May 2016
Replace Content of a Batch File
#include <Array.au3>
#include <File.au3>
$ParentPath=<FilePath>
Local $aFileList = _FileListToArray($ParentPath, "*")
If @error = 1 Then
MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
Exit
EndIf
If @error = 4 Then
MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
Exit
EndIf
$count1=0
For $i= 1 to $aFileList[0]
if StringInStr($aFileList[$i],"_") and not StringInStr($aFileList[$i],"APAC") and not StringInStr($aFileList[$i],"IGL") and not StringInStr($aFileList[$i],"ILP") then
$SmokeFolder= $ParentPath & "\" & $aFileList[$i]
Local $bFileList = _FileListToArray($SmokeFolder, "*.bat")
ConsoleWrite($aFileList[$i] & " >> " & $bFileList[1] & @CRLF)
$ChangedLine = '\\file4\develop\wmc_apps\QMC-Automation\Global_Test\Kill.vbs UFT.exe' & @CRLF
$ChangedLine = $ChangedLine & '<neededChange>' & @CRLF
$ChangedLine = $ChangedLine & '<neededChange>' & @CRLF
$ChangedLine = $ChangedLine &'<neededChange>' & @CRLF
$file = FileOpen ($SmokeFolder & "\" & $bFileList[1], 0 )
Dim $Contents
While 1
$Line = FileReadLine ( $file )
If @error Then
Exitloop
MsgBox "Error occured"
EndIf
$Contents = $ChangedLine & $Line & @CRLF
WEnd
FileClose ( $file )
$file = FileOpen ($SmokeFolder & "\" & $bFileList[1], 2 )
FileWrite ( $file, $Contents )
FileClose ( $file )
$count1=$count1+1
EndIf
Next
ConsoleWrite($count1)
Subscribe to:
Posts (Atom)