Jump to content
  1. kisstom


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By argumentum
      I was looking for something like this, in the forum and my HDD. Bad hair day. Anyway,
      Here is the code
      If Not StringInStr($CmdLineRaw, "/ErrorStdOut") Then Exit MsgBox(262144, @ScriptName, "...please run this example from editor.", 3) #include <Date.au3>; for _EstimatedTime() #include <InetConstants.au3>; for _EstimatedTime_Example_2() ;=============================================================================== ; ; Function Name: _EstimatedTime() ; https://www.autoitscript.com/forum/topic/177371-_estimatedtime-calculate-estimated-time-of-completion/ ; Description: calculate estimated time of completion ; Parameter(s): $a - holds the data ; $iCurrentCount - Current count ; $iTotalCount - Total count ; Requirement(s): #include <Date.au3> ; Return Value(s): false on incomplete data for assessment ; Author(s): argumentum ; Note(s): read the comments ; ;=============================================================================== Func _EstimatedTime(ByRef $a, $iCurrentCount = "", $iTotalCount = "") If $iCurrentCount & $iTotalCount = "" Then ; initialize $a = "" Dim $a[12] $a[5] = TimerInit() ; handle for TimerDiff() $a[0] = "00:00:00" $a[1] = "00:00:00" $a[2] = _NowCalc() ; starting date and time $a[3] = "" $a[4] = "0" Else If $iTotalCount = 0 Then Return False If $iCurrentCount > $iTotalCount Then $iCurrentCount = $iTotalCount _TicksToTime(Int(TimerDiff($a[5])), $a[6], $a[7], $a[8]) _TicksToTime(Int((TimerDiff($a[5]) / $iCurrentCount) * ($iTotalCount - $iCurrentCount)), $a[9], $a[10], $a[11]) $a[0] = StringFormat("%02i:%02i:%02i", $a[6], $a[7], $a[8]) ; elapsed time $a[1] = StringFormat("%02i:%02i:%02i", $a[9], $a[10], $a[11]) ; estimated total time $a[3] = _DateAdd("s", Int((TimerDiff($a[5]) / $iCurrentCount) * ($iTotalCount) / 1000), $a[2]) ; estimated date and time of completion $a[4] = Int($iCurrentCount / $iTotalCount * 100) ; percentage done EndIf Return True EndFunc ;==>_EstimatedTime _EstimatedTime_Example_1() Func _EstimatedTime_Example_1() ConsoleWrite(@CRLF & "+ Example 1" & @CRLF) ConsoleWrite("elapsed " & @TAB & "estimated" & @TAB & "starting date time " & @TAB & "estimated date time" & @CRLF) ConsoleWrite(" _NowCalc() = " & _NowCalc() & @CRLF) Local $n, $sec = @SEC, $aETTF ; "Estimated Time To Finish" data holder _EstimatedTime($aETTF) ; called with just the data holder to init. it For $n = 1234 To 1 Step -1 Sleep(1) If $sec <> @SEC Then $sec = @SEC _EstimatedTime($aETTF, 1234 - $n, 1234) ConsoleWrite($aETTF[0] & @TAB & $aETTF[1] & @TAB & $aETTF[2] & @TAB & $aETTF[3] & @TAB & $aETTF[4] & @CRLF) EndIf Next _EstimatedTime($aETTF, 1234 - $n, 1234) ConsoleWrite($aETTF[0] & @TAB & $aETTF[1] & @TAB & $aETTF[2] & @TAB & $aETTF[3] & @TAB & $aETTF[4] & @CRLF) ConsoleWrite(" _NowCalc() = " & _NowCalc() & @CRLF) EndFunc ;==>_EstimatedTime_Example_1 _EstimatedTime_Example_2() Func _EstimatedTime_Example_2() ConsoleWrite(@CRLF & "+ Example 2" & @CRLF) ConsoleWrite("elapsed " & @TAB & "estimated" & @TAB & "starting date time " & @TAB & "estimated date time" & @CRLF) ConsoleWrite(" _NowCalc() = " & _NowCalc() & @CRLF) Local $aETTF ; "Estimated Time To Finish" data holder _EstimatedTime($aETTF) ; called with just the data holder to init. it ; Save the downloaded file to the temporary folder. Local $sFilePath = @MyDocumentsDir & "\tempFile.bin" Local $sLink = "http://downloads.sourceforge.net/project/portableapps/PortableApps.com%20Platform/PortableApps.com_Platform_Setup_12.0.5.paf.exe?r=http%3A%2F%2Fsourceforge.net%2Fdirectory%2Fbusiness-enterprise%2Fos%3Awindows%2Ffreshness%3Arecently-updated%2F&ts=1442615522&use_mirror=iweb" ; Download the file in the background with the selected option of 'force a reload from the remote site.' Local $hDownload = InetGet($sLink, $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True. Do Sleep(1000) If _EstimatedTime($aETTF, InetGetInfo($hDownload, $INET_DOWNLOADREAD), InetGetInfo($hDownload, $INET_DOWNLOADSIZE)) Then ConsoleWrite($aETTF[0] & @TAB & $aETTF[1] & @TAB & $aETTF[2] & @TAB & $aETTF[3] & @TAB & $aETTF[4] & @CRLF) Else ConsoleWrite(". ") EndIf Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) ; Retrieve the number of total bytes received and the filesize. Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD) Local $iFileSize = FileGetSize($sFilePath) ; Close the handle returned by InetGet. InetClose($hDownload) _EstimatedTime($aETTF, $iBytesSize, $iFileSize) ConsoleWrite($aETTF[0] & @TAB & $aETTF[1] & @TAB & $aETTF[2] & @TAB & $aETTF[3] & @TAB & $aETTF[4] & @CRLF) ConsoleWrite(" _NowCalc() = " & _NowCalc() & @CRLF) ; Display details about the total number of bytes read and the filesize. ConsoleWrite("The total download size: " & $iBytesSize & " - The total filesize: " & $iFileSize & @CRLF) ; Delete the file. FileDelete($sFilePath) EndFunc ;==>_EstimatedTime_Example_2  
    • By dersiniar
      Hihi guys several hours messing and i still cat figure out why timer wont reset in my func.
      Func shold loop untill timer difference and then it shold do other things including to reset timer as well.
      Timer otself works good. after 30seconds it goes to next func. it just dosnt reset timer. 
      Func _Start() While 1 If TimerDiff($hTimer) > 30 * 1000 Then ; Wait for 10 secs $hTimer = 0 $hTimer = TimerInit() Sleep(100) _Image() Sleep(100) _actTimer() Sleep(100) Else MouseClick("Left", $aPos6[0], $aPos6[1], 1) MouseClick("Left", $aPos4[0], $aPos4[1], 1) MouseClick("Left", $aPos5[0], $aPos5[1], 1) MouseClick("Left", $aPos7[0], $aPos7[1], 150,0) Sleep(100) EndIf WEnd EndFunc  
    • By mrtgtr
      I want to do something , after wait 2 min and again do same thing
      But I do do not want with sleep, it must be timer 
      How I do this ?
    • By TotalAuto
      Howdy All
      I've gone around and around in circles wasting hours trying to fix this problem to no avail so I thought I would try posting for help given there are some real smart people in this forum.
      I have 5 separate .au3 scripts that all do different basic tasks. For example:
      1.au3 = opens Chrome browser to obtain information from a specific website then closes
      2.au3 = opens an Excel workbook to run a macro then saves and closes
      3.au3 = Open two seperate workbooks and transfers data from one to the other then saves and closes
      4.au3 = .......etc
      5.au3 = .......etc
      These 5 separate scripts, doing completely different tasks, need to each run once per day at 5 different designated times within a day and then close. For example:
      1.au3 = 10am
      2.au3 = 12pm
      3.au3 = 2pm
      4.au3 = 4pm
      5.au3 = 5pm
      I can not get these different scripts to reliably run at their designated times. When I manually run these scripts individually by using 'Go F5' they work perfectly. If I convert these scripts to an .exe and manually run each one they work about 98% of time.
      How can I schedule these different .au3 files or associated .exe files to reliably run each day at different times?
      Attempts To Fix The Issue
      1. I have tried converting each .au3 script into their own .exe file and use Window's Task Scheduler to run these .exe files at their designated time but the success rate  of running each .exe in full, to completion, without error is very low at about 30%. Things that commonly go wrong include a browser not opening but movement still continues on the desk top. Other times things just do not happen at all.
      2. I have Windows 7 64 bit and have tried creating and running both (x86) and (x64) .exe files but again reliability problems exist;
      3. I have also tried moving each .exe file to the My Documents folder as I read someone that keeping your files on your desktop ties your files to individual Windows user profiles which can cause AutoIt operating errors. Not sure if this is correct but thought I would try it anyway. It did not fix my issue.
      4. I installed a program called AlwaysUp which supposedly always reliably runs in the background and will reliably execute your AutoIt script or .exe files. Still have significant reliability issues.
      Therefore, can someone please provide advice on how I can get my 5 different .au3 files to run at 5 designated times through the day, every day, without fail? Overtime I will be creating more and more different .au3 files to run certain tasks throughout the day and do not want to create one large AutoIt file that continually runs and attempts to do all the different tasks itself.
      Any help is very appreciated.
    • By jannikrendl
      Hey guys,
      I would like to create a simple Timer which starts counting down if a key is pressed and after running out of time making a sound. Afterwards it should reset and wait again for the same key to be pressed to start again.
      I am new to autoit and really don't know how to get started...
      How I would try to do it:
      while(1) WEnd HotKeySet("{F9}", "_Timer") Func _Timer() ;FUNCTION HERE but I don't know what to do there :& EndFunc Best regards and thanks in advance
  • Create New...