klamsi Posted January 25, 2006 Share Posted January 25, 2006 Hey Guys. Have a little Problem: I have a PIC that runs from one border of my Form to the other Site I just made it run with this loop. Do $i = $i + 3 GUICtrlSetPos($PIC,$i,1,35,35) Sleep (15) Until $i > 300 But after a while it startes to get slow. The Loop needs much more time then before. When I move the mouse, every thing is normal again and the pic is starting to move faster again. And after some seconds it starts to move slower again. It seemes that the loop sleepes 200ms instead of 15ms, maybe to give the CPU time to do other Threads. Is somebody here who knows how I can prevent this characteristic??? Greetz to all, Klamsi Link to comment Share on other sites More sharing options...
CyberSlug Posted January 25, 2006 Share Posted January 25, 2006 So $i increments from 0 (presumably) to 300 in steps of 3. So the Do-Until loop executes the sleep(15) statement 100 times. 100 * 15 = 150 milliseconds.... What's your intention with this code? Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
klamsi Posted January 25, 2006 Author Share Posted January 25, 2006 Intention? A little game like "snake" or "pacman" I have a pic, and this pic should move around. Well every thing works, but as I told, it works to slow! After around a few loops it startes to slow down. It seemes, that the priority of the loop gets lower then it should be. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 25, 2006 Moderators Share Posted January 25, 2006 With such a small loop number, do you need the Sleep(15)? Does it serve some higher purpose other than trying to save cpu usage? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
klamsi Posted January 25, 2006 Author Share Posted January 25, 2006 With such a small loop number, do you need the Sleep(15)? Does it serve some higher purpose other than trying to save cpu usage?That doesn't metter. I choosed Sleep(15) to make the movement of the PIC smoothly.But what I mean is:Whenever the Loop needs less then ca. 200ms to run through, the loop will slow down strongly after ca. 50 loop-passesWhy?I just dont want that. How can I prevent this? Link to comment Share on other sites More sharing options...
MHz Posted January 25, 2006 Share Posted January 25, 2006 Try a For loop instead. For $i = 1 To 300 Step 3 GUICtrlSetPos($PIC,$i,1,35,35) Sleep(15) Next Link to comment Share on other sites More sharing options...
klamsi Posted January 25, 2006 Author Share Posted January 25, 2006 Try a For loop instead. For $i = 1 To 300 Step 3 GUICtrlSetPos($PIC,$i,1,35,35) Sleep(15) Next To bad That was a good Idea, but it still getz so slow like before Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 25, 2006 Moderators Share Posted January 25, 2006 Have you tried it with just ControlMove() to see what happens? ControlMove($GUINAME, '', $PIC, $i, 1, 35, 35)? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
klamsi Posted January 25, 2006 Author Share Posted January 25, 2006 Have you tried it with just ControlMove() to see what happens?ControlMove($GUINAME, '', $PIC, $i, 1, 35, 35)?Hmmm, that chances nothing =(Do you have an other idea? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 25, 2006 Moderators Share Posted January 25, 2006 Hmmm, that chances nothing =(Do you have an other idea?Get a faster computer? j/kWhat size file is that $PIC out of curiousity... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
MHz Posted January 25, 2006 Share Posted January 25, 2006 Could be a case of too much happening in such a short period of time for the PC to manage it. Try less moves in the same time period like below. For $i = 1 To 150 Step 6 GUICtrlSetPos($PIC,$i,1,35,35) Sleep(30) Next That should help to release some load on the PC. Link to comment Share on other sites More sharing options...
klamsi Posted January 25, 2006 Author Share Posted January 25, 2006 Could be a case of too much happening in such a short period of time for the PC to manage it. Try less moves in the same time period like below. For $i = 1 To 150 Step 6 GUICtrlSetPos($PIC,$i,1,35,35) Sleep(30) Next That should help to release some load on the PC. No thats not the Problem =) I got it with a simple trick: Mousemove(1,1)!!! As I explained, when I move the mouse... my problem stops. So, thats all what I have to do... let the computer move the mouse after the 50th loop... Its creazy... but it works Greetz, Klamsi Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 25, 2006 Moderators Share Posted January 25, 2006 Almost makes you wonder if something like this would work:Local $TestIt = '' While $TestIt <= 10 $MovePic = TestPicMove() $TestIt = $TestIt + $MovePic WEnd Func TestPicMove() For $i = 1 To 30 Step 3 GUICtrlSetPos($PIC,$i,1,35,35) Sleep(15) Next Return 1 EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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