Jump to content

Recommended Posts

Posted

Hello!

I'm trying a simple script:

$speedTimer = TimerInit()

while $step <= $coordEnd
        $check = PixelGetColor($step, $y)
   if $check > 3615000 and $check < 3619000 then
      ExitLoop
   endif

   $step = $step + 1
WEnd

ConsoleWrite(TimerDiff($speedTimer) & " " & @CRLF)

My puter gives me 0,034 sec while my wife's PC -- 3,6 sec. 

The both computers are: intel-core i5-3450 CPU @3.10 Ghz 3.10 Ghz, 8 Gb, gforce 550 latest drivers, Windows 7 SP-1. 

I tried switching off antiviruses but it didn't help. Even simple notepad script takes ages to run... And ideas?

Thanks in advance!

Posted

Welcome to AutoIt and the forum!

Working with pixels isn't very fast. Which program do you try to automate? Most of the time there are faster ways to do what you want to do.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Running this script on windows desktop just for tests. 

Okay, I made it 'Windows Classic' theme and 'Highest performance". It's better .. a bit. 3,4 sec.

Any more ideas please?

Posted (edited)

Why do you want to spend time to improve the performance of a test script?

I suggest to grab a real life problem, write a script and then make it faster.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

I'm trying to figure out the source of the problem. ANY autoit script works 1000 times slower on my wife's machince for some reason.

AutoIT version 3.3.10.2.

Posted (edited)

Try this:

#include <Constants.au3>


$speedTimer = TimerInit()
$PowerScheme = GetCurrentPowerScheme()

DllCall("dwmapi.dll", "hwnd", "DwmEnableComposition", "uint", 0) ; Disable windows aero effect
Run(@ComSpec & " /c Powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ; Change power plan to 'Highest performance"
while $step <= $coordEnd
        $check = PixelGetColor($step, $y)
   if $check > 3615000 and $check < 3619000 then
      ExitLoop
   endif

   $step = $step + 1
WEnd

ConsoleWrite(TimerDiff($speedTimer) & " " & @CRLF)

DllCall("dwmapi.dll", "hwnd", "DwmEnableComposition", "uint", 1) ; Enable windows aero effect
Run(@ComSpec & " /c Powercfg -setactive "&$PowerScheme, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ; Change power plan to previous power plan


Func GetCurrentPowerScheme()
    Local $PowerScheme = -1 , $DOS
    $DOS = Run(@ComSpec & " /c " & 'Powercfg -getactivescheme', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    ProcessWaitClose($DOS, 5)
    $PowerScheme = StdoutRead($DOS)
    $PowerScheme = StringTrimLeft($PowerScheme, StringLen("Power Scheme GUID: "))
    $PowerScheme = StringSplit($PowerScheme, " ", 1)
    $PowerScheme = $PowerScheme[1]
    Return $PowerScheme
EndFunc   ;==>GetCurrentPowerScheme

Add the missing variables.

Edited by Guest
Posted (edited)

Try this:

#include <Constants.au3>


$speedTimer = TimerInit()
$PowerScheme = GetCurrentPowerScheme()

DllCall("dwmapi.dll", "hwnd", "DwmEnableComposition", "uint", 0) ; Disable windows aero effect
Run(@ComSpec & " /c Powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ; Change power plan to 'Highest performance"
while $step <= $coordEnd
        $check = PixelGetColor($step, $y)
   if $check > 3615000 and $check < 3619000 then
      ExitLoop
   endif

   $step = $step + 1
WEnd

ConsoleWrite(TimerDiff($speedTimer) & " " & @CRLF)

DllCall("dwmapi.dll", "hwnd", "DwmEnableComposition", "uint", 1) ; Enable windows aero effect
Run(@ComSpec & " /c Powercfg -setactive "&$PowerScheme, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ; Change power plan to previous power plan


Func GetCurrentPowerScheme()
    Local $PowerScheme = -1 , $DOS
    $DOS = Run(@ComSpec & " /c " & 'Powercfg -getactivescheme', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    ProcessWaitClose($DOS, 5)
    $PowerScheme = StdoutRead($DOS)
    $PowerScheme = StringTrimLeft($PowerScheme, StringLen("Power Scheme GUID: "))
    $PowerScheme = StringSplit($PowerScheme, " ", 1)
    $PowerScheme = $PowerScheme[1]
    Return $PowerScheme
EndFunc   ;==>GetCurrentPowerScheme

Add the missing variables.

The result is 5103.710790044. Basically 5secs.

Edited by Kotomoto82
Posted

The result is 5103.710790044. Basically 5secs.

Maybe it's because the line:

$PowerScheme = GetCurrentPowerScheme()

is after the line:

$speedTimer = TimerInit()

try to move $PowerScheme = GetCurrentPowerScheme() to before $speedTimer = TimerInit()

But in this case, you do not count the time that GetCurrentPowerScheme() takes.

If you get better result then you can delete lines: $PowerScheme = GetCurrentPowerScheme() and Run(@ComSpec & " /c Powercfg -setactive "&$PowerScheme, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

that way you can save time but the script will not restore the power plan settings.

 
I do not believe that GetCurrentPowerScheme() takes more than half a second. But if that is the case then it can help.
  • Developers
Posted

Am I correct when you stated that the most simple au3 script are slow on that one PC?

Even when it contains only:

$a=1

Are you running from SciTE? If so, could you post all SciTE outputpane information?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
$timer = TimerInit()
$a = 1
$b = 2
 
$c = $a + $b
 
ToolTip(TimerDiff($timer), 0, 0)
 
 
-----------------
4377.00343477
 
Just deinstalled Norton 360 so it's not the fault of the antivirus. 
 
 
------------------
 
In the previous script, yes, indeed moving $PowerScheme = GetCurrentPowerScheme() up improved it by 0.5 sec.
Posted

What happens if you run this script?

DllCall("dwmapi.dll", "hwnd", "DwmEnableComposition", "uint", 0) ; Disable windows aero effect
Sleep(5000)
DllCall("dwmapi.dll", "hwnd", "DwmEnableComposition", "uint", 1) ; Enable windows aero effect

Do you see any change?
I'm afraid not.

What operating system are you using?

Posted

it's windows 7 SP-1.

Just tried it on my laptop, windows 8.1.

"

$timer = TimerInit()
$a = 1
$b = 2
 
$c = $a + $b
 
ToolTip(TimerDiff($timer), 0, 0)
"
gives 0.0027 etc
 
but my first script same result as my wife's computer -- 3,4+ sec. Maybe it's a virus after all. Too tired ot figure it out now. i'll try tomorrow. Your help is appreciated! Thanks.
Posted (edited)

If your code checks every pixel on the screen/whatever, you can do it faster if your code will not check all pixels ..

 

this code not checks all pixel but and much much faster. And still can do the job

Local $x , $y , $timer = TimerInit()
Do
    $x = 1
    Do
        $y = 1
        Do
            ToolTip("X",$x,$y)
            $y = $y+10
        Until $y >= @DesktopHeight
        $x = $x+10
    Until $x >= @DesktopWidth
Until $x >= @DesktopWidth And $y >= @DesktopHeight


ConsoleWrite("time: "&TimerDiff($timer)&@CRLF)

EDIT:

and if you disable the ToolTip then it will be much much much faster

Edited by Guest
Posted (edited)

I recommend to use SysInternals Process Explorer

http://technet.microsoft.com/en-us/sysinternals/bb896653

or Process Monitor

http://technet.microsoft.com/en-us/sysinternals/bb896645

to see what (undesirable) processes are running at backround and slowing down your system.

It's probably some virus or malware or forgotten antivirus.

I heard about  some computers with more than one antivirus installed! I would expect that this may be also your case ;-)

Edited by Zedna
Posted
gil900 thanks for the tip. Do .. until is faster. 

I tried Bart PE  with Win Xp on my laptop. The script works ok, as fast as on my puter.

So it must be some driver that slows down autoit script. To be continued...

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...