Alodar99 Posted July 15, 2008 Share Posted July 15, 2008 I have found that If we could work with mostly integer variables Autoit would run much faster -- is there any way to designate an integer variable? --Al [font="Franklin Gothic Medium"]---Al[/font] Link to comment Share on other sites More sharing options...
Paulie Posted July 15, 2008 Share Posted July 15, 2008 (edited) Int() IsInt() Round() Edited July 15, 2008 by Paulie Link to comment Share on other sites More sharing options...
Alodar99 Posted July 15, 2008 Author Share Posted July 15, 2008 Well, I meant to be able to designate a variable as integer, for example usually you would use !n instead of $n . Integerizing floating points would just slow down the script even worse. If you have ever used QuickMacros you will find they are integer by default and the programs run twice the speed of Autoit.--Al [font="Franklin Gothic Medium"]---Al[/font] Link to comment Share on other sites More sharing options...
Paulie Posted July 15, 2008 Share Posted July 15, 2008 (edited) Odd.. I've never really had a problem with autoit's speed. maybe you should use "QuickMarcros" if 1 hundred-thousandth of a second really matters muttley EDIT: my maths was wrong Edited July 15, 2008 by Paulie Link to comment Share on other sites More sharing options...
Alodar99 Posted July 15, 2008 Author Share Posted July 15, 2008 HUH! Quick Macros uses GOTO! muttley Anyways, it is not as structured as Autoit. The speed problem is only noticeable when I am moving the mouse cursor down the screen clicking. Like if you would click every third pixel on the screen from top to bottom, it takes Autoit many more seconds and when you need to do this a lot, it slows the program to a crawl. --Al [font="Franklin Gothic Medium"]---Al[/font] Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 15, 2008 Share Posted July 15, 2008 I have found that If we could work with mostly integer variables Autoit would run much faster -- is there any way to designate an integer variable? --AlPlease post a short demo script where you found a significant performance difference based on the variable type in AutoIt. muttley Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 15, 2008 Share Posted July 15, 2008 HUH! Quick Macros uses GOTO! Anyways, it is not as structured as Autoit. The speed problem is only noticeable when I am moving the mouse cursor down the screen clicking. Like if you would click every third pixel on the screen from top to bottom, it takes Autoit many more seconds and when you need to do this a lot, it slows the program to a crawl.--AlMouseMove()?And how did this relate to an integer variable type? muttley Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Paulie Posted July 15, 2008 Share Posted July 15, 2008 You sure it's not just how you code it? this script hits every 3rd pixel in about 3 seconds... Hardly a crawl when you consider that (1280x1024)/3 is 436906.66 pixels to click on... Dim $Time[10], $Total = 0 For $i = 0 to 9 $Timer = TimerInit() For $x = 0 to @DesktopWidth Step 3 For $y = 0 to @DesktopHeight Step 3 Mouseclick("left",$x,$y,0) Next Next $Time[$i] = TimerDiff($Timer) Next For $i = 0 to 9 $Total += $Time[$i] Next $Final = $Total / 10 MsgBox(0,"", $Final) Link to comment Share on other sites More sharing options...
Alodar99 Posted July 15, 2008 Author Share Posted July 15, 2008 (edited) I'm not sure that it is caused by the fact that AI uses floatingpoint and QM uses integers, but this is the only difference i could find in the two languages. here is an example of the same code rendered in both: Quick Macros: *scan* a=576 for c 600 50 -31;; line up through center lef a c w1; 0.01 if pixel(1003 843 w1)<>targself goto *attack* and now Autoit: Func quicktarget() for $c=600 to 50 step -31;; line up through center MouseClick("left",576,$c,1) sleep(10) if PixelGetColor(1003,851)<>$SelfTarg then $targ=1 EndIf Next if $Targ=1 Then Attack() $Targ=0 $mob=0 return EndIf Endfunc basically the curser scrolls down the page and if it targets a mob then my character is no longer targeted which is the Pixel-color-check. Maybe there are other reasons why the cursor moves so slowly in AI? ---Al Edited July 15, 2008 by Alodar99 [font="Franklin Gothic Medium"]---Al[/font] Link to comment Share on other sites More sharing options...
Alodar99 Posted July 15, 2008 Author Share Posted July 15, 2008 (edited) Dang, editor drops the tabs, what do I need to put them in quotes? In QM that would take less than half a second Paulie. -Al Edited July 15, 2008 by Alodar99 [font="Franklin Gothic Medium"]---Al[/font] Link to comment Share on other sites More sharing options...
aslani Posted July 15, 2008 Share Posted July 15, 2008 Why do you have to have these... if $Targ=1 Then Attack() $Targ=0 $mob=0 return EndIf ..if you can add it in your For...Next loop? Func quicktarget() for $c=600 to 50 step -31;; line up through center MouseClick("left",576,$c,1) sleep(10) if PixelGetColor(1003,851)<>$SelfTarg then Attack() $Targ=0 $mob=0 return EndIf Next Endfunc Doesn't make any sense to call $Targ = 1 if you're going to reset it to "0" at the end of the function. Not sure if that will improve the speed or not, but it's still an extra unneccessay steps. [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
Alodar99 Posted July 15, 2008 Author Share Posted July 15, 2008 heh, actually it was in the loop in the actual program but I separated it for this forum, I guess I didn't check the logic of it -- good job. No it is still slow. And, if I remove the 100th of a second sleep between the key clicks it never actually will target anything, it needs to stay at the spot for a 100th second after the click. The slowness is in calculating the next mouse move and then getting there. -AL (will be back in a few hours) [font="Franklin Gothic Medium"]---Al[/font] Link to comment Share on other sites More sharing options...
aslani Posted July 15, 2008 Share Posted July 15, 2008 (edited) Another thing; MouseClick("left",576,$c,1) sleep(10) if PixelGetColor(1003,851)<>$SelfTarg then $targ=1 EndIf You're MouseClick()-ing to a sequence of coordinates yet you're PixelGetColor() in (1003,851) coords? O.o Maybe instead of MouseClick()-ing, maybe it will get optimized using PixelSearch()? Maybe, just maybe, the processe of MouseClick()-ing is what's slowing it down. EDIT: Not sure if this is what you're trying to accomplish but here's an attempt to optimize your script. Dim $aColor[1] Dim $aYCoord[1] Func _quickTarget() For $c = 600 To 50 Step -31; not sure how you're going to get from 600 to 50 by subtracting 31...but oh well, it's your script $i = 0 $aYCoord[$i] = $c ReDim $aYCoord[UBound($aYCoord) + 1] $i += 1 Next For $ia = 0 To Ubound($aYCoord) - 1 $aColor[$ia] = PixelGetColor(576, $aYCoord[$ia]) ReDim $aColor[UBound($aColor) + 1] Next For $ib = 0 To UBound($aColor) - 1 If $aColor[$ib] <> $SelfTarg Then Attack() $Targ = 0 $mob = 0 Return EndIf Next EndFunc Edited July 15, 2008 by aslani [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
Alodar99 Posted July 16, 2008 Author Share Posted July 16, 2008 Okay, some clarification. -- The step -31 -- once the $c goes below 50 the loop stops, that's how they work -- 31 is just an adjustment for the best speed getting there. -- The mouseclicking is necessary because once he faces a mob -- this particular game does not have an auto-target, so instead he just clicks from top to bottom in hopes that he will "target" the mob -- if he does target the mob, the color around his health bar changes and this let's the program know he has targeted "something". -- the comparable QuickMacro program with the same wait zooms down the screen in half a second, the Autoit program crawls on all fours. --Al [font="Franklin Gothic Medium"]---Al[/font] Link to comment Share on other sites More sharing options...
Alodar99 Posted July 16, 2008 Author Share Posted July 16, 2008 Maybe this is a better comparison" Autoit: for $n=1 to 60 Mouseclick("left",885,112+($n*10),1) next QuickMacros: int n for n 1 60 lef 885 112+(n*10) w1;0.01 The QM version is more than twice the speed -- The only difference is the use of integers, because in all other ways Autoit is just as fast -- compiled or interpreted. ---Al [font="Franklin Gothic Medium"]---Al[/font] Link to comment Share on other sites More sharing options...
Alodar99 Posted July 16, 2008 Author Share Posted July 16, 2008 So, I guess there is no way to create an integer variable in Autoit? Ok, I thought maybe I was missing something. [font="Franklin Gothic Medium"]---Al[/font] Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 16, 2008 Share Posted July 16, 2008 So, I guess there is no way to create an integer variable in Autoit? Ok, I thought maybe I was missing something.My understanding of it (subject to correction, as always): All variables in AutoIt are C type 'Variant'. Internally, AutoIt tags these variants as Int, Float, String, etc.. Checking the type with VarGetType() checks AuotIt's internal flags on how the variant is being used but doesn't say anything necessarily about it's "real" type down at the C++ level. muttley Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Alodar99 Posted July 16, 2008 Author Share Posted July 16, 2008 So, do you think that if I initialize a variable with an integer at the beginning, it will remain integerized till a decimal value is introduced -- that is something to experiment with... [font="Franklin Gothic Medium"]---Al[/font] Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 16, 2008 Share Posted July 16, 2008 So, do you think that if I initialize a variable with an integer at the beginning, it will remain integerized till a decimal value is introduced -- that is something to experiment with... AutoIt is not "stongly typed" and will not respect your attempts to keep a variant as one type. The type changes dynamically based on what you did with it: $a = "1" ConsoleWrite("Debug: $a = " & $a & " type: " & VarGetType($a) & @LF) $a = $a ^ 2 ConsoleWrite("Debug: $a = " & $a & " type: " & VarGetType($a) & @LF) $b = "2" ConsoleWrite("Debug: $b = " & $b & " type: " & VarGetType($b) & @LF) $c = $a + $b ConsoleWrite("Debug: $c = " & $c & " type: " & VarGetType($c) & @LF) $d = $a & $b ConsoleWrite("Debug: $d = " & $d & " type: " & VarGetType($d) & @LF) $e = $a / $b ConsoleWrite("Debug: $e = " & $e & " type: " & VarGetType($e) & @LF) muttley Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Alodar99 Posted July 16, 2008 Author Share Posted July 16, 2008 So here is a good illustration for the use of Integers, The last segment, $F is allocated as a 32 bit integer variable, I just wish it could be kept that way. If you don't feel like running this code, here is the results... Debug: $a = 1 type: String Time: 2.31007013461208 Debug: $a = 1 type: Double Time: 2.3039241020856 Debug: $b = 2 type: String Time: 2.3597971250536 Debug: $c = 3 type: Double Time: 3.44233694505866 Debug: $d = 12 type: String Time: 7.42356919664371 Debug: $e = 0.5 type: Double Time: 3.4831242518253 Debug: $f = 2233 type: Int32 Time: 1.9010796064863 +>19:25:11 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 2.076 expandcollapse popup$Timer = TimerInit() For $i = 0 to 999 $a = "1" Next $Time = TimerDiff($Timer) ConsoleWrite("Resource Allocation = Time: " & $Time & @LF) $Timer = TimerInit() For $i = 0 to 999 $a = "1" Next ConsoleWrite("Debug: $a = " & $a & " type: " & VarGetType($a)) $Time = TimerDiff($Timer) ConsoleWrite(" Time:" & " " & $Time & @LF) $Timer = TimerInit() For $i = 0 to 999 $a = $a ^ 2 Next ConsoleWrite("Debug: $a = " & $a & " type: " & VarGetType($a)) $Time = TimerDiff($Timer) ConsoleWrite(" Time:" & " " & $Time & @LF) $Timer = TimerInit() For $i = 0 to 999 $b = "2" Next ConsoleWrite("Debug: $b = " & $b & " type: " & VarGetType($b)) $Time = TimerDiff($Timer) ConsoleWrite(" Time:" & " " & $Time & @LF) $Timer = TimerInit() For $i = 0 to 999 $c = $a + $b Next ConsoleWrite("Debug: $c = " & $c & " type: " & VarGetType($c)) $Time = TimerDiff($Timer) ConsoleWrite(" Time:" & " " & $Time & @LF) $Timer = TimerInit() For $i = 0 to 999 $d = $a & $b Next ConsoleWrite("Debug: $d = " & $d & " type: " & VarGetType($d)) $Time = TimerDiff($Timer) ConsoleWrite(" Time:" & " " & $Time & @LF) $Timer = TimerInit() For $i = 0 to 999 $e = $a / $b Next ConsoleWrite("Debug: $e = " & $e & " type: " & VarGetType($e)) $Time = TimerDiff($Timer) ConsoleWrite(" Time:" & " " & $Time & @LF) $Timer = TimerInit() For $i = 0 to 999 $f = 11 + 2222 Next ConsoleWrite("Debug: $f = " & $f & " type: " & VarGetType($f)) $Time = TimerDiff($Timer) ConsoleWrite(" Time:" & " " & $Time & @LF) [font="Franklin Gothic Medium"]---Al[/font] Link to comment Share on other sites More sharing options...
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