Sleep() problem!
-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By Vikramjeet
I have a script that reads the last 7 lines of an active log file. By active I mean that the file is being written while the script runs.
How can I make the script to
1- keep reading the last 7 lines till a specific text appears.
2- Once the specific text appears, then get out of the loop and proceed to other tasks
Thank You
-
By simonc8
I have a script which executes sleep for a couple of hours then carries out instructions. Does the running AutoIt script prevent the computer from entering sleep mode during this time? If not, is there something I can add to the AutoIt script to keep the computer awake?
Grateful for advice.
-
By mistersquirrle
TL;DR: Anyway to bypass built in sleep on TrayGetMsg() and GUIGetMsg() ?
I'm currently working on a project that does some heavy array/ GDI+ processing, which depending what I have it do can take between 4s - 1min. During this time, I'd like to have the Tray icon (mainly, possibly also the GUI) for the program be responsive, so that if someone wanted to change actions or exit the script during this, they can without closing the process.
Currently I have my TrayGetMsg and GUIGetMsg captures in my main program loop, working great, and once I go into the array/ GDI+ functions I tried switching it to an AdlibRegister call, unregistering it once completed. The problem with this is that it's adding ~10-20% more time into those functions, which I'd like to avoid. As I understand it, and from the helpfile: "This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU." From what I've read/ seen/ tested, this adds a 10ms sleep into the calls. I would rather avoid that sleep all together.
The array/ GDI+ function that I'm doing peg the CPU at 100% (for its core) anyways, so that's not a concern of mine. My only concern for this is speed (and having things be responsive to other actions).
Here's an example:
Local $iBlockSize = 20, $iWidth = 1920, $iHeight = 1080, $aBigArray[$iWidth * $iHeight], $iPercentDone, $sLastMsg Local $aSmallerArray[Int(Ceiling($iWidth / $iBlockSize)) * Int(Ceiling($iHeight / $iBlockSize))] Local $sAdlib[] = ["Registered: ", "UnRegistered: ", "Registered to _FakeTray: "], $timer, $iIndexLength = UBound($aBigArray) Local $ixBlocks = Int(Ceiling($iWidth / $iBlockSize)), $iBlockIndex, $iBlockX, $iBlockY For $j = 0 To 2 If $j = 0 Then AdlibRegister("_CheckTray", 100) ElseIf $j = 1 Then AdlibUnRegister("_CheckTray") ElseIf $j = 2 Then AdlibRegister("_FakeTray", 100) EndIf $timer = TimerInit() For $i = 0 To $iIndexLength - 1 ; Loop through $aBigArray $aBigArray[$i] = Random(1, 10, 1) $iPercentDone = Floor(($i / $iIndexLength * 100)) ; Hopefully quick maths to get progress If $sLastMsg <> "We are " & $iPercentDone & "% done" Then ; Check if we're on a new percent $sLastMsg = "We are " & $iPercentDone & "% done" ; If so, update the msg ToolTip($sLastMsg, 0, 0) ; And display the current progress EndIf $y = Floor($i / $iWidth) ; Convert index to Y coordinate $x = Floor($i - ($y * $iWidth)) ; Convert index to X coordinate $iBlockX = Floor($x / $iBlockSize) ; Convert X coord to xBlock coord $iBlockY = Floor($y / $iBlockSize) ; Convert Y coord to yBlock coord $iBlockIndex = Int($iBlockX + ($iBlockY * $ixBlocks)) ; Convert into a blockIndex ;~ If Mod($i, 10000) = 0 Then ;~ ConsoleWrite($iBlockIndex & " - " & $i & @CRLF) ;~ EndIf $aSmallerArray[$iBlockIndex] += Int($aBigArray[$i]) ; Add into $aSmallerArray Next ConsoleWrite("Time to run with Adlib" & $sAdlib[$j] & TimerDiff($timer) & @CRLF) Next Func _CheckTray() Switch TrayGetMsg() Case "Meow" Return Case "Woof" Return EndSwitch EndFunc ;==>_CheckTray Func _FakeTray() Local $sMeow = "Oink" Switch $sMeow Case "Meow" Return Case "Woof" Return EndSwitch EndFunc ;==>_FakeTray Exit On my system, this takes ~1 minute to run, output:
Time to run with AdlibRegistered: 19649.335 Time to run with AdlibUnRegistered: 16264.4124 Time to run with AdlibRegistered to _FakeTray: 16860.1283 >Exit code: 0 Time: 53.92 As you can see, it's ~20.8% faster without the Adlib check, and ~16.5% faster using a (hopefully) reproduction of TrayGetMsg() without the built in sleep. These timings vary, but it's consistently much faster without the TrayGetMsg() sleep (unless it's just that slow). I've used the OnEventModes, and those also slow down performance, more so than just using the GetMsgs, so those are out (but effective, and pretty easy to use).
-
By naru
I have script Like This :
Opt("TrayAutoPause",0)
$var = Ping("www.google.com")
If not @error Then
WinActivate ( "testapp")
ControlClick ( "testapp", "", "[Savetest]")
ControlSend ( " :: Gujarat TPDS - eFPS :: Version - 2.2.0.0 - [eFPS Bill]", "", "[NAME:btnSavebyFP]", "{enter}")
WinWait(":: Aadhar/EID/Verification Number Entry ::")
ControlClick(":: Aadhar/EID/Verification Number Entry ::", "", "[NAME:btnNext]")
If WinExists ("Aadhar : Length Check") Then
ControlClick("Aadhar : Length Check", "", "[CLASS:Button; INSTANCE:1]")
ControlSend(":: Aadhar/EID/Verification Number Entry ::", "", "[NAME:txtAadharNumber]", "{backspace}")
ControlSend(":: Aadhar/EID/Verification Number Entry ::", "", "[NAME:txtAadharNumber]", "^v")
ControlClick(":: Aadhar/EID/Verification Number Entry ::", "", "[NAME:btnNext]")
WinWait(" :: Barcoded Ration Card Members - Biometric Verification/Check Utility ::")
ControlSend("[Class:WindowsForms10.Window.8.app.0.378734a]", "", "[NAME:PictureBox2]", "{tab} {enter}")
Sleep(5600)
RunWait("rasdial /disconnect", "", @SW_HIDE) ; Stop connect from start
RunWait("rasdial Internet", "", @SW_HIDE) ; Connect again
Exit
EndIf
WinWait(" :: Barcoded Ration Card Members - Biometric Verification/Check Utility ::", "", 1)
ControlSend("[Class:WindowsForms10.Window.8.app.0.378734a]", "", "[NAME:PictureBox2]", "{tab} {enter}")
Sleep(5600)
RunWait("rasdial /disconnect", "", @SW_HIDE) ; Stop connect from start
RunWait("rasdial Internet", "", @SW_HIDE) ; Connect again
Exit
Else
#include <MsgBoxConstants.au3>
MsgBox($MB_TOPMOST, "Connection Status", "Internet is not Connected")
Exit
Endif
-
By naru
How can i add sleep command using internet speed.
If my internet speed is 40-50Kbps then sleep for 5 seconds,
If my internet speed is 30-40Kbps then sleep for 4 seconds,
If my internet speed is 20-30Kbps then sleep for 3 seconds.
*Sleep command used bitween my costom script, Example,
RunWait("rasdial /disconnect", "", @SW_HIDE) ; Stop connect from start
Sleep(5000)
RunWait("rasdial Internet", "", @SW_HIDE) ; Connect again
-
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now