Jump to content

Timeproblem in my Loop


klamsi
 Share

Recommended Posts

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

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

  • Moderators

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

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

Why?

I just dont want that.

How can I prevent this?

Link to comment
Share on other sites

  • Moderators

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

  • Moderators

Hmmm, that chances nothing =(

Do you have an other idea?

Get a faster computer? :lmao: j/k

What 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

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

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 :lmao:

Greetz,

Klamsi

Link to comment
Share on other sites

  • Moderators

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...