Sign in to follow this  
Followers 0
galpha

How To End A Loop

6 posts in this topic

Ok I want that when I press Escape key, It ends a loop. Here's my part of the script:

Func Terminate()
   while 1
$x=Pause()
if $x=1 then exitloop
sleep(10)
SplashOff()
GUISetControlEx($PROGRESS_1, 0)
wend
EndFunc  ;==>Terminate

It does end the loop but the problem is that when I press escape, I can't close my GUI anymore:

;Generated with AutoBuilder 0.3

Opt ("GUICoordMode", 1)
Opt ("GUINotifyMode", 1)
Opt ("TrayIconHide", 1)
Opt ("TrayIconDebug", 1)
Opt ("RunErrorsFatal", 0)

#include "Events.au3"   ;Toutes les fonctions du script sont appellés de là
#include "GUI_include.au3"   ;Global

$VERSION = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Momow", "Version") 

$WS_VSCROLL = 0x200000
$style = $WS_VSCROLL

GUICreate("Momow SpamBot v" & $VERSION & " Final", 347, 198)
$LABEL_1 = GUISetControl("label", "Votre spam:", 10, 20, 70, 20)
$EDIT_1 = GUISetControl("edit", "", 10, 40, 330, 40, $style)
$LABEL_2 = GUISetControl("label", "Nombre de fois:", 10, 90, 80, 20)
$INPUT_2 = GUISetControl("input", "", 100, 90, 40, 20)
$LABEL_3 = GUISetControl("label", "Delay:", 10, 120, 33, 20)
$INPUT_3 = GUISetControl("input", "50", 100, 120, 40, 20)
$PROGRESS_1 = GUISetControl("progress", "Progression", 160, 90, 180, 40, $PBS_SMOOTH)
$BUTTON_1 = GUISetControl("button", "Exit", 280, 160, 60, 30)
$BUTTON_2 = GUISetControl("button", "Start", 10, 160, 70, 30)
$BUTTON_3 = GUISetControl("button", "Save", 100, 160, 40, 20)
$BUTTON_4 = GUISetControl("button", "Load", 150, 160, 40, 20)
$BUTTON_5 = GUISetControl("button", "Update", 210, 160, 60, 30)

GUIShow()
While 1
EnableHotKeys()
ValidityLookup()
   Sleep(100)
   $MSG = GUIMsg(0)
   Select
      Case $MSG = -3
         Exit
         
      Case $MSG = $LABEL_1
         
        ;NE RIEN ÉCRIRE
         
      Case $MSG = $EDIT_1

      Case $MSG = $LABEL_2
         
        ;NE RIEN ÉCRIRE
         
      Case $MSG = $INPUT_2
         
        ;NE RIEN ÉCRIRE
         
      Case $MSG = $PROGRESS_1
         
        ;;;
         
      Case $MSG = $BUTTON_1
         
         Exit
         
      Case $MSG = $BUTTON_2
         
         Check ()
         Pause ()
         
         $I = GUIRead($INPUT_2)
         SplashTextOn("Momow SpamBot v1.0", "Peser Sur  ESC  pour interrompre le script et pesser PAUSE  pour mettre le script en pause", 250, 40, 0, 0, 1, -1, 8, -1) 
         For $P = 1 To $I
            $PERC = Int($P / $I * 100)
            GUISetControlEx($PROGRESS_1, $PERC)
            $R = GUIRead($EDIT_1)
            ClipPut($R)
            Send("^v")
     $M = GUIRead($INPUT_3)
            Sleep($M)
            Send("{ENTER}")
         Next
         SplashOff()
         Sleep(2000)
         GUISetControlEx($PROGRESS_1, 0)
         
      Case $MSG = $BUTTON_3
         
         $S = GUIRead($EDIT_1)
         IniWrite("Config.ini", "Config", "message", $S)
         $U = GUIRead($INPUT_2)
         IniWrite("Config.ini", "Config", "nombre", $U)
         $O = GUIRead($INPUT_3)
         IniWrite("Config.ini", "Config", "delay", $O)
         
      Case $MSG = $BUTTON_4
         
         $Q = IniRead("Config.ini", "Config", "message", "Aucunes valeurs trouvés")
         GUIWrite($EDIT_1, 0, $Q)
         $W = IniRead("Config.ini", "Config", "nombre", "Aucunes valeurs trouvés")
         GUIWrite($INPUT_2, 0, $W)
         $E = IniRead("Config.ini", "Config", "delay", "Aucunes valeurs trouvés")
         GUIWrite($INPUT_3, 0, $E)
         
      Case $MSG = $BUTTON_5
         
         URLDownloadToFile("http://members.lycos.co.uk/momow/files/upd.mom", "upd.mom")
         $NEWESTFILE = FileOpen("upd.mom", 0)
         $NEWEST = FileReadLine($NEWESTFILE, 1)
         FileClose($NEWESTFILE)
         FileDelete("upd.mom")
         $CURRENT = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Momow", "Version") 
         If $CURRENT == $NEWEST Then
            MsgBox(0, "Momow SpamBot v" & $CURRENT, "Vous avez la version la plus recente déjà installer")
            SplashOff()
         Else
            $MSGBOX = MsgBox(4, "Momow SpamBot v." & $CURRENT, "La nouvelle version de Momow SpamBot v." & $NEWEST & " est disponible.  Voulez-vous l'installer maintenant?")
            If $MSGBOX = 6 Then
               
               GUISetControlEx($PROGRESS_1, 0)
               URLDownloadToFile("http://members.lycos.co.uk/momow/files/SpamBot.exe", "SpamBot.exe")
               GUISetControlEx($PROGRESS_1, 50)
               RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Momow", "Version", "REG_SZ", $NEWEST)
               GUISetControlEx($PROGRESS_1, 99)
               Sleep(3000)
               GUISetControlEx($PROGRESS_1, 0)
               MsgBox(0, "Momow SpamBot v1.3 Final", "Vous avez correctement updater votre SpamBot")
               
            EndIf
            
            
         EndIf
         
   EndSelect
Wend
Exit

I want it that when it press escape, you can continue to use the GUI without closing it in task manager (ctrl-alt-del) and ending task.

Share this post


Link to post
Share on other sites



Can you PM the missing part of your script or preferably try to make a smaller script that reproduce what is not working for you

Thanks :D

Share this post


Link to post
Share on other sites

Well the thing that doesn't work is that when you hit escape, it does stop the loop like I want to, only prob is that when I hit escape, the GUI wont close or other buttons wont work.

Share this post


Link to post
Share on other sites

Can't be sure about the problem without the entire code.... but here are some ideas:

Inside Func Terminate, declare Local $x = Pause()

Put Opt("TrayIconDebug", 1) at the beginning of your script. If your GUI is running normally, the tray icon tooltip should usually contain the sleep(100) line. After you hit Esc, see what the tooltip says....


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Well the thing that doesn't work is that when you hit escape, it does stop the loop like I want to, only prob is that when I hit escape, the GUI wont close or other buttons wont work.

As under AU3GUI the ESC key is not process by the AutoIt GUI function.

That can be a clue.

No idea if it interact with Hotkey

Share this post


Link to post
Share on other sites

heres the entire script:

Events.au3

#include-once

Func Check()
   Opt ("WinTitleMatchMode", 2) 
   WinWaitActive("Bloc") 
EndFunc  ;==>Check

Func Pause()
   Global $PAUSED 
   HotKeySet("{PAUSE}", "TogglePause") 
   HotKeySet("{ESC}", "Terminate")
EndFunc  ;==>Pause

Func TogglePause() 
   $PAUSED = Not $PAUSED 
   While $PAUSED 
      Sleep(100) 
      ToolTip('Script est en "Pause"', 0, 0) 
   Wend 
   ToolTip("") 
EndFunc  ;==>TogglePause

Func Terminate()
   While 1
Local $x = Pause()
      $X = Pause()
      If $X = 1 Then ExitLoop
      Sleep(10)
      SplashOff()
      GUISetControlEx($PROGRESS_1, 0)
   Wend
EndFunc  ;==>Terminate

Func EnableHotKeys()
   HotKeySet("^a", "SelectAll")
EndFunc  ;==>EnableHotKeys

Func DisableHotKeys()
   HotKeySet("^a")
EndFunc  ;==>DisableHotKeys

Func SelectAll()
  ;Note that 0xB1 == EM_SETSEL.... so select all character 0 - max bytes
   GUISendMsg($EDIT_1, $EM_SETSEL, 0, -1)
EndFunc  ;==>SelectAll

Func Active()
   Opt ("WinTitleMatchMode", 2) 
   WinActive("Bloc")
EndFunc  ;==>Active

Func ValidityLookup()
   $L = GUIRead($EDIT_1)
   $MESLEN = StringLen($L)
   If $MESLEN > 400 Then
      MsgBox(0, "Momow SpamBot v" & $VERSION & " Final", "Votre Spam ne doit pas avoir plus de 400 caractères (espaces comprises) sinon msn ne pourra pas spammer étant donner la limite de lettres.")
   Sleep(10000)
   EndIf
EndFunc  ;==>ValidityLookup

Func updateStatusBar()
   Opt ("WinTitleMatchMode", 2) 
   WinWaitActive("Bloc") 
Local $rowTotal= ControlCommand("Bloc","","Edit", "GetLineCount", "")
EndFunc

GUI_include.au3

#include-once

Global $PBS_SMOOTH = 1
Global $EM_SETSEL = 0x00B1

SpamBot.au3

;Generated with AutoBuilder 0.3

Opt ("TrayIconDebug", 1)
Sleep(100)
Opt ("GUICoordMode", 1)
Opt ("GUINotifyMode", 1)
Opt ("TrayIconHide", 1)
Opt ("RunErrorsFatal", 0)

#include "Events.au3"   ;Toutes les fonctions du script sont appellés de là
#include "GUI_include.au3"   ;Global

$VERSION = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Momow", "Version") 

$WS_VSCROLL = 0x200000
$STYLE = $WS_VSCROLL

GUICreate("Momow SpamBot v" & $VERSION & " Final", 347, 198)
$LABEL_1 = GUISetControl("label", "Votre spam:", 10, 20, 70, 20)
$EDIT_1 = GUISetControl("edit", "", 10, 40, 330, 40, $STYLE)
$LABEL_2 = GUISetControl("label", "Nombre de fois:", 10, 90, 80, 20)
$INPUT_2 = GUISetControl("input", "", 100, 90, 40, 20)
$LABEL_3 = GUISetControl("label", "Delay:", 10, 120, 33, 20)
$INPUT_3 = GUISetControl("input", "50", 100, 120, 40, 20)
$PROGRESS_1 = GUISetControl("progress", "Progression", 160, 90, 180, 40, $PBS_SMOOTH)
$BUTTON_1 = GUISetControl("button", "Exit", 280, 160, 60, 30)
$BUTTON_2 = GUISetControl("button", "Start", 10, 160, 70, 30)
$BUTTON_3 = GUISetControl("button", "Save", 100, 160, 40, 20)
$BUTTON_4 = GUISetControl("button", "Load", 150, 160, 40, 20)
$BUTTON_5 = GUISetControl("button", "Update", 210, 160, 60, 30)
GUISetControlEx($BUTTON_1, 0, 0, "Exit")
GUISetControlEx($BUTTON_2, 0, 0, "Pour débuter le spam")
GUISetControlEx($BUTTON_3, 0, 0, "Enregistrer votre spam,delay et nombre")
GUISetControlEx($BUTTON_4, 0, 0, "Loader votre spam,delay et nombre")
GUISetControlEx($BUTTON_5, 0, 0, "Mettre à jour votre version de Momow SpamBot")
$STATUS = GUISetControl("edit", "", 240, 21, 100, 20, 0x50010800)
GUISetControlEx($STATUS, 0, 518) ;also tried 576

GUIShow()
While 1
   EnableHotKeys ()
   ValidityLookup ()
   Sleep(100)
   $MSG = GUIMsg(0)
   Select
      Case $MSG = -3
         
         Exit
         
      Case $MSG = $LABEL_1
         
        ;NE RIEN ÉCRIRE
         
      Case $MSG = $EDIT_1
         
      Case $MSG = $LABEL_2
         
        ;NE RIEN ÉCRIRE
         
      Case $MSG = $INPUT_2
         
        ;NE RIEN ÉCRIRE
         
      Case $MSG = $PROGRESS_1
         
        ;;;
         
      Case $MSG = $BUTTON_1
         
         Exit
         
      Case $MSG = $BUTTON_2
         
         Check ()
         Pause ()
         
         $I = GUIRead($INPUT_2)
         SplashTextOn("Momow SpamBot v1.0", "Peser Sur  ESC  pour interrompre le script et pesser PAUSE  pour mettre le script en pause", 250, 40, 0, 0, 1, -1, 8, -1) 
         For $P = 1 To $I
            $PERC = Int($P / $I * 100)
            GUISetControlEx($PROGRESS_1, $PERC)
            $R = GUIRead($EDIT_1)
            ClipPut($R)
            Send("^v")
            $M = GUIRead($INPUT_3)
            Sleep($M)
            Send("{ENTER}")
         Next
         SplashOff()
         Sleep(2000)
         GUISetControlEx($PROGRESS_1, 0)
         
      Case $MSG = $BUTTON_3
         
         $S = GUIRead($EDIT_1)
         IniWrite("Config.ini", "Config", "message", $S)
         $U = GUIRead($INPUT_2)
         IniWrite("Config.ini", "Config", "nombre", $U)
         $O = GUIRead($INPUT_3)
         IniWrite("Config.ini", "Config", "delay", $O)
         
      Case $MSG = $BUTTON_4
         
         $Q = IniRead("Config.ini", "Config", "message", "Aucunes valeurs trouvés")
         GUIWrite($EDIT_1, 0, $Q)
         $W = IniRead("Config.ini", "Config", "nombre", "Aucunes valeurs trouvés")
         GUIWrite($INPUT_2, 0, $W)
         $E = IniRead("Config.ini", "Config", "delay", "Aucunes valeurs trouvés")
         GUIWrite($INPUT_3, 0, $E)
         
      Case $MSG = $BUTTON_5
         
         URLDownloadToFile("http://members.lycos.co.uk/momow/files/upd.mom", "upd.mom")
         $NEWESTFILE = FileOpen("upd.mom", 0)
         $NEWEST = FileReadLine($NEWESTFILE, 1)
         FileClose($NEWESTFILE)
         FileDelete("upd.mom")
         $CURRENT = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Momow", "Version") 
         If $CURRENT == $NEWEST Then
            MsgBox(0, "Momow SpamBot v" & $CURRENT, "Vous avez la version la plus recente déjà installer")
            SplashOff()
         Else
            $MSGBOX = MsgBox(4, "Momow SpamBot v." & $CURRENT, "La nouvelle version de Momow SpamBot v." & $NEWEST & " est disponible.  Voulez-vous l'installer maintenant?")
            If $MSGBOX = 6 Then
               
               GUISetControlEx($PROGRESS_1, 0)
               URLDownloadToFile("http://members.lycos.co.uk/momow/files/SpamBot.exe", "SpamBot.exe")
               GUISetControlEx($PROGRESS_1, 50)
               RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Momow", "Version", "REG_SZ", $NEWEST)
               GUISetControlEx($PROGRESS_1, 99)
               Sleep(3000)
               GUISetControlEx($PROGRESS_1, 0)
               MsgBox(0, "Momow SpamBot v1.3 Final", "Vous avez correctement updater votre SpamBot")
               
            EndIf
            
            
         EndIf
         
   EndSelect
Wend
Exit

Share this post


Link to post
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
Sign in to follow this  
Followers 0