Leaderboard
Popular Content
Showing content with the highest reputation on 07/14/2016 in all areas
-
Hi guys, I needed a simple function to download files and show the progress of the download. I commented a bit (don't know if i should have added more) You can provide the url to the file, the wanted file name, the visible name for in the download progress UI, where the file should be downloaded to, if the progressbar should be hidden at the end of the function or if it should remain visible, how long the last message (completed/failed) should show and last but not least, a title for the progress window. At the end of the function you either get the full path of the download file or false when it fails with @error set and @extended set with the error code of the download. #include <InetConstants.au3> Func _webDownloader($sSourceURL, $sTargetName, $sVisibleName, $sTargetDir = @TempDir, $bProgressOff = True, $iEndMsgTime = 2000, $sDownloaderTitle = "MyDownloader") ; Declare some general vars Local $iMBbytes = 1048576 ; If the target directory doesn't exist -> create the dir If Not FileExists($sTargetDir) Then DirCreate($sTargetDir) ; Get download and target info Local $sTargetPath = $sTargetDir & "\" & $sTargetName Local $iFileSize = InetGetSize($sSourceURL) Local $hFileDownload = InetGet($sSourceURL, $sTargetPath, $INET_LOCALCACHE, $INET_DOWNLOADBACKGROUND) ; Show progress UI ProgressOn($sDownloaderTitle, "Downloading " & $sVisibleName) ; Keep checking until download completed Do Sleep(250) ; Set vars Local $iDLPercentage = Round(InetGetInfo($hFileDownload, $INET_DOWNLOADREAD) * 100 / $iFileSize, 0) Local $iDLBytes = Round(InetGetInfo($hFileDownload, $INET_DOWNLOADREAD) / $iMBbytes, 2) Local $iDLTotalBytes = Round($iFileSize / $iMBbytes, 2) ; Update progress UI If IsNumber($iDLBytes) And $iDLBytes >= 0 Then ProgressSet($iDLPercentage, $iDLPercentage & "% - Downloaded " & $iDLBytes & " MB of " & $iDLTotalBytes & " MB") Else ProgressSet(0, "Downloading '" & $sVisibleName & "'") EndIf Until InetGetInfo($hFileDownload, $INET_DOWNLOADCOMPLETE) ; If the download was successfull, return the target location If InetGetInfo($hFileDownload, $INET_DOWNLOADSUCCESS) Then ProgressSet(100, "Downloading '" & $sVisibleName & "' completed") If $bProgressOff Then Sleep($iEndMsgTime) ProgressOff() EndIf Return $sTargetPath ; If the download failed, set @error and return False Else Local $errorCode = InetGetInfo($hFileDownload, $INET_DOWNLOADERROR) ProgressSet(0, "Downloading '" & $sVisibleName & "' failed." & @CRLF & "Error code: " & $errorCode) If $bProgressOff Then Sleep($iEndMsgTime) ProgressOff() EndIf SetError(1, $errorCode, False) EndIf EndFunc ;==>_webDownloaderLet me know what you think The test in my example is done with the installer for java 8 update 65 Example usage : $url = "http://javadl.sun.com/webapps/download/AutoDL?BundleId=111687" $file = "Java_8_Update_65.exe" $name = "Java 8 Update 65" $dir = @TempDir & "\MyDownloader" $installcommand = " /s STATIC=Disable AUTO_UPDATE=Disable WEB_JAVA=Enable WEB_JAVA_SECURITY_LEVEL=H WEB_ANALYTICS=Disable EULA=Enable REBOOT=Disable SPONSORS=Disable" $test = _webDownloader($url, $file, $name, $dir, False) If $test Then ProgressSet(100, "Running silent installation...", "Installing " & $name) $exitCode = RunWait($test & $installcommand) If $exitCode = 0 Then ProgressSet(100, "Installation completed") If $exitCode <> 0 Then ProgressSet(0, "Installation failed" & @CRLF & "Exit code: " & $exitCode) Sleep(3000) ProgressOff() FileDelete($test) Else ProgressOff() EndIfGreetz _webDownloader.au31 point
-
- _____ _____ _ _ - |_ _|___ ___ ___ _ _| __|___ ___|_|___| |_ - | | | -_| -_| | | |__ | _| _| | . | _| - |_| |___|___|_|_|_ |_____|___|_| |_| _|_| - By TarreTarreTarre|___|Build '1.0.0' |_| + F5 = Run script + F6 = Build 'AU3' + F7 = Build 'EXE' + F8 = Options GUI + F10 = Exit TeenyScript All example code and documentation moved to: http://teenyscript.tarre.nu/documentation Official Github repo: http://github.com/tarreislam/teenyscript F.A.Q Q: What is TeenyScript? A: TeenyScript is a Superset of AutoIt which makes it more advanced Q: How does it work? A: TeenyScript code are parsed into native AutoiT code Q: Does it depend on anything else than AutoIt? A: Just one dependency, that is AutoitObject, the best UDF ever created for AutoIt, besides that, only Native AutoIt is used Features "Anonymous" functions Endless scope nesting OOP (powered by AutoitObject) User-friendly integration Powerful macros Namespaces Lists Project support, for easy deployment Userfriendly GUI for userfriendly Tasks for the Userfriendly person And much more To come You decide, I am happy to do requests! Install and Update TeenyScript HOW TO GET STARTED Run TeenyScript.au3 Now this should see something like this in your console Code Press F8 and navigate to the misc tab to install SciTE calltips Run \ Build \ Compile How to run with Sublime Text Here is some examples of TeenyScript code ;Basic List usage $Example_A = Func() ; Create a list Local $myList = { 'Name': 'Tarre' } ; Add \ Change data on $MyList $myList{'Age'} = 25 ; Create MySecondList Local $MySecondList = { "Name" => "John", "Age" => "00" } ; Using variable instead of a string Local $KeyName = "Age" Local $KeyVal = 1337 $MySecondList{$KeyName} = $KeyVal ; You may also pass lists to lists. however this has to be done in this fashion. Local $oList = {'myList': $myList, 'mySecondList' => $MySecondList} ; Return the objects Return $oList EndFunc();call the function on the variable ; Loop through list and print their values $Example_B = Func() Local $MyList = {'A': 'Hello FROM A', 'B': 'Hello FROM B', 'C': 'Hello FROM C'} Local $aNames = ['A', 'B', 'C'] For $i = 0 To UBound($aNames) -1 MsgBox(0,0,$myList{$aNames[$i]}) Next EndFunc #MAIN MsgBox(0,"Example A 1", $Example_A.myList.Name) MsgBox(0,"Example A 2", $Example_A.myList.Age) MsgBox(0,"Example A 3", $Example_A.mySecondList.Name) MsgBox(0,"Example A 4", $Example_A.mySecondList.Age) $Example_B(); Execute examble B Here is a non class nested function calculator example (calculator.ts.au3) $calculator = Func($a, $and, $b) $division = Func($a, $b) if Not $a or Not $b Then Return "Error dividing 0" EndIf Return $a/$b EndFunc Switch $and Case '+' Return $a + $b Case '-' Return $a - $b Case '/' Return $division($a, $b) Case '*' Return $a * $b EndSwitch Return "Unkown attribute "&$and EndFunc #MAIN ConsoleWrite($calculator(25, '*', 25)&@CRLF) ConsoleWrite($calculator(25, '/', 0) & @CRLF) ConsoleWrite($calculator(1, '^', 2) & @CRLF) teeny-script.zip (OLD) TeenyScript beta2.zip (OLD) teeny-script Beta 4.zip (OLD) teeny-script Beta 5.zip (OLD) teeny-script BETA 6.zip (OLD) TeenyScript Beta 7.zip (OLD) teeny-script Beta 8.zip (OLD) TeenyScript-master 1.0.0.zip (OLD) TeenyScript-1.1.0.zip (OLD) TeenyScript-1.2.0.zip (OLD) TeenyScript-2.0.0.zip (OLRD, Release notes) TeenyScript-2.1.3.zip (Newest 2016-09-16, Release notes)1 point
-
Problem with GMAIL login script
eodtech2001 reacted to JackWebb for a topic
Hi Everyone! So I use Autoit to automate my logins. Gmail has recently made some changes to their login page that breaks my script. The username goes in okay, but not the password. I can type in the password manually and it's no problem. What I can't understand is how does the browser know the password is not being typed in manually? I tried every trick I could think of (i'm an Autoit noob) to simulate human typing. Using send() raw and slowing down the type rate of the keys. Nothing works, can anyone shed some light on this? #include <WinAPIShPath.au3> #include <Array.au3> Opt("SendKeyDelay", 25) Opt("SendKeyDownDelay", 25) Send("email@gmail.com", 1) sleep(1500) Send("{enter down}", 0) Send("{enter up}", 0) sleep(1500) Send("password", 1) sleep(1500) Send("{enter down}", 0) Send("{enter up}", 0)1 point -
One shot split: #Include <Array.au3> Global $aList[10] = [9] $aList[1] = "plain_1_text_here 11" $aList[2] = 'plain_2_text_here "2"' $aList[3] = "plain_3_text_here '33'" $aList[4] = 'plain_4_text_here"4"' $aList[5] = "plain_5_text_here'55'" $aList[6] = 'plain_6_text_here"6" // text here' $aList[7] = "plain_7_text_here'77' // text here" $aList[8] = 'plain_8_text_here "8" "88"' $aList[9] = "plain_9_text_here '9 '99" For $i = 1 To $aList[0] $aRes = StringRegExp($aList[$i], "(?|^(\w+)|(\d+))", 3) _ArrayDisplay($aRes) Next sorry, edited because of horrible way1 point
-
1) I would drop this two lines if you do not use $oExcelApp later in your script. 2) Yes1 point
-
Paths with wildcards
Deye reacted to ViciousXUSMC for a topic
Use the Files & Folders return option and then use StringinStr() to verify your string (or RegEx)1 point -
Added 8 more filters (Convolution_Gaussian3x3, Median2, Time Warp, Fish Eye, Swirl, Wave, X-Ray, Distortion Blur). Have fun.1 point
-
Paths with wildcards
Deye reacted to JLogan3o13 for a topic
_FileListToArrayRec has a parameter to search just folders...1 point -
rootx, Time for you to enter the world of "regular expressions"! Just look for the filenames that hold a "digits x digits" string: Global $aList[] = ["File name-keep.jpg", "File name-delete-150x100.jpg", "File name-also keep.jpg", "File name-delete-150x100-150x100.jpg"] For $i = 0 To UBound($aList) - 1 If StringRegExp($aList[$i], "\d+x\d+") Then ConsoleWrite("To delete: " & $aList[$i] & @CRLF) Else ConsoleWrite("To keep: " & $aList[$i] & @CRLF) EndIf Next Please ask if you have any questions. M231 point
-
Here's an example. #include <Array.au3> #include <MsgBoxConstants.au3> Local $avArray[6][2] = [ _ ["abc", "SubString0"], _ ["x", "SubString1"], _ ["y", "SubString2"], _ ["z", "SubString3"], _ ["abc", "SubString4"], _ ["abc", "SubString5"]] Local $search = "x" Local $column = 0 Local $result = _ArrayFindAll($avArray, $search, Default, Default, Default, Default, $column) If IsArray($result) Then _ArrayDisplay($result) local $count = UBound($result) MsgBox(64, "Count", $search & " occured " & $count & " time" & ($count > 1 ? "s" : "") & " in column " & $column & " of the array.") Else MsgBox(16, "Count", $search & " was not found in column " & $column & " of the array.") EndIf I just hate software that says "1 times"1 point
-
I think this is caused by _ExcelBookOpen returning the Excel application object and not the Excel workbook object. So you would need to pass $oExcelWB_X2.ActiveWorkbook1 point
-
1 point
-
1 point