Jump to content

Cant stop tha loop !


Recommended Posts

Good day all,

You can say i am a bit noobish in AutoIt3 but i am learning it !

I came across a problem and it seems like google isnt my best friend anymore.

Here's the problem

while 1

$nMsg = GUIGetMsg()

If $nMsg = $okbutton then

Do

while 2

Sleep(3000)

Send("{F5}")

WEnd

Until ("{Del}") then

Do

Exitloop

endif

Wend

i just cant stop this loop... Del aint doing the trick even if i erase the then Do Exitloop Part. I hope you guys can sort this out for me. I would be gratefull (L)

regards,

Dennis

Link to comment
Share on other sites

When I look quickly over your code, it even won't run!! On the 10th line you have a begin of a Do loop, but after that I never see any Until. You better set it in autoit brackets, that's easier to read.

PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.
Link to comment
Share on other sites

There's a few problems here.

First, the Until doesn't know what to do with "{Del}". You should use something like Until _IsPressed, or use a Hotkey.

Second, the Then after the Until is incorrect and the Do afterwards is malformed.

And Most Important, you have a while statement withina Do Loop, which means the While must end before the Do continues the loop.

Link to comment
Share on other sites

Here's how I would do it

Global $exit = 0
HotKeySet("{del}","_ExitDo")

while 1
    $nMsg = GUIGetMsg()
    If $nMsg = $okbutton then
        Do
            Sleep(3000)
            Send("{F5}")
        Until $exit
    endif
Wend

Func _ExitDo()
    $exit = 1
EndFunc
Link to comment
Share on other sites

Try this:

HotKeySet("{DEL}", "_DEL")
Global $del = False, $Timer = TimerInit()
While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $okbutton Then
        Do
            If TimerDiff($Timer) >= 3000 Then
                Send("{F5}")
                $Timer = TimerInit()
            EndIf
        Until $del
        ExitLoop
    EndIf
WEnd
Func _DEL()
    $del = True
EndFunc   ;==>_DEL

Or you could use _IsPressed as stated before, instead of the HotKeySet and the _DEL function.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Here's how I would do it

Global $exit = 0
HotKeySet("{del}","_ExitDo")

while 1
    $nMsg = GUIGetMsg()
    If $nMsg = $okbutton then
        Do
            Sleep(3000)
            Send("{F5}")
        Until $exit
    endif
Wend

Func _ExitDo()
    $exit = 1
EndFunc

You could use the _IsPressed if you want, but the timing is more critical. A hotkey will interrupt, execute, then continue.
Link to comment
Share on other sites

Global defines a variable that is accessible "globally" (meaning inside and outside functions), Variables can be defined Local which means they can only be used with a limited scope.

aw i see its binary?

0 - off

1 - on

basically. It could also be boolean (True, False); or even Null, Not Null.

In this case 0 means null or nothing. The Until command is mearly checking to see if the variable is 0 or not(nothing). You can test this by assigning $exit to anything besides 0 (ie. "Done", True, 12345).

Edited by spudw2k
Link to comment
Share on other sites

Also, just for learning...if you examine BrewMan's code, he is using a timer instead of a sleep command. The advantage a timer has is that it is reliably more precise. I would assume since you are merely refreshing the screen (f5) the precision isn't so important, but timer funcs can be very useful.

Edited by spudw2k
Link to comment
Share on other sites

ow btw (: maybe somebody can help me out quick ^^

If $nMsg = $Homepage then

        RegWrite  ("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\" , "Start Page" ,"REG_SZ", "http://www.mranderson.nl/")
        


    endif

Button wont change the Homepage :C can somebody help? (:

Link to comment
Share on other sites

ow btw (: maybe somebody can help me out quick ^^

If $nMsg = $Homepage then

        RegWrite  ("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\" , "Start Page" ,"REG_SZ", "http://www.mranderson.nl/")
        


    endif

Button wont change the Homepage :C can somebody help? (:

Are you closing and re-opening IE between homepage changes? I believe it reads that key when it opens, and not again unless you set it via IE Options.

You could force IE to close and re-open.

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