Jump to content

Recommended Posts

Posted (edited)

Ok , first of all in C++ Break means Exit the While Loop , but in Autoit ExitLoop means Exit the Script so i want an example to stop the loop without exiting the whole script

my code is :

Func _StopLoop()
   Global $off = 2
    EndFunc

Func _Loop()
    Global $off = 0
Do
While 1
    If _IsPressed("12") Then
        MouseClick("Left")
    EndIf
Until $off > 0
Return
EndFunc

I tried that with HotKeySet but it don't stop the loop and when i use Exit Loop it exit the script and when i use While NOT $off > 0 all of this exits the script

So please give me an example without closing the script.

Edited by AhmedSabry32
Posted

Exit means exit the script. ExitLoop means exit the loop.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

  On 4/19/2013 at 6:51 PM, 'allSystemsGo said:

If there is nothing to execute after the loop exits, then the script will exit.

#include <GUIConstantsex.au3>
GUICreate("autoIT",300,100)
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Then this code you posted the Script will exit because nothing to excute after the Exit Loop right?

In this case there must be code under the Exit Loop?

  • Moderators
Posted (edited)

Once AutoIt processes the ExitLoop, it goes back to the line after where it entered the loop. If you have nothing more, it is going to close:

#include <Misc.au3>
Local $hDLL = DllOpen("user32.dll")
_Loop1()
;Nothing here, so script exits

Func _Loop1()
While 1
If _IsPressed(01, $hDLL) Then ExitLoop
WEnd
;Press left mouse button, jump back to line 4
EndFunc

If, however, you do this, it won't exit:

#include <Misc.au3>
Local $hDLL = DllOpen("user32.dll")
_Loop1()
Msgbox(0, "", "Exited Loop")

Func _Loop1()
While 1
If _IsPressed(01, $hDLL) Then ExitLoop
WEnd
;Press left mouse button, jump back to line 4
EndFunc
Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

Is there's an example of using the code inside Hotkeyset because i don't Use the Function out side only in HotKeySet and Case $button so i want it do only this without msg box and what else , I mean like this :

HotKeySet("{END}", "_Loop")

While 1
$nmsg = GUIGetMsg()
Switch $nmsg
Case $Button1
_Loop()
EndSwitch
WEND


Func _Loop()
While 1
If _IsPressed("01") Then
MouseClick("Left")
EndIf
ElseIf _IsPressed("02") Then
ExitLoop
WEND
Posted

  On 4/19/2013 at 7:31 PM, 'JLogan3o13 said:

AhmedSabry32, what is the application or window you're trying to MouseClick on? There is probably a far easier way to accomplish this...

Well I'm using it as Example so idk how to do exit the loop without exiting the script without adding more codes
Posted

Considering his last 3 locked threads, I'd say it's either some kind of game, game hack, or malware.

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!

  Reveal hidden contents

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

Posted

  On 4/19/2013 at 7:38 PM, 'JLogan3o13 said:

My thoughts, as well. Especially as a GUI is referenced but we are not seeing the part of the code...

Well I'm doing A Programme If a key is pressed it will do mouse click it has useful things like when you have no mouse .

Umm How can i Break It without adding more codes to it because idk what to add also this is the main script which i edited in the topic.

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
  • Recently Browsing   0 members

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