Jump to content
Sign in to follow this  
James

Ending a loop

Recommended Posts

That doesn't work :P

My code is:

Case $start
            For $i = 1 to 100
            WinWaitActive("- Conversation")
        If WinExists("- Conversation") Then
            WinActivate("- Conversation")
            Send(IniRead("Text.ini", "MSN Text", "TXT"," Not Found") & "{enter}")
            WinClose("- Conversation")
        EndIf
    Next  
        Case $stop
             ExitLoop

I included the loop code aswell

Share this post


Link to post
Share on other sites

That is my only loop.

#include <GUIConstants.au3>

Opt("WinTitleMatchMode", 2)
HotKeySet("{F3}". "NextWhile")
Global $trigger = 0

#Region ### START Koda GUI section ### Form=c:\documents and settings\james\my documents\codes\koda_1.6.0.2\forms\msn msg.kxf
$window = GUICreate("MSN Auto-Reply", 339, 417, -1, -1)
$start = GUICtrlCreateButton("Start MSN Message", 8, 152, 121, 57, 0)
$stop = GUICtrlCreateButton("Stop MSN Message", 8, 224, 121, 57, 0)
$setText = GUICtrlCreateButton("Set text to send", 8, 80, 121, 57, 0)
$start1 = GUICtrlCreateLabel("Start the Message Replier", 144, 168, 185, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
$stop1 = GUICtrlCreateLabel("Stop the Message Replier", 144, 240, 185, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
$help = GUICtrlCreateButton("Help me!!!!", 8, 296, 321, 81, 0)
$welcome = GUICtrlCreateEdit("", 9, 8, 322, 57, BitOR($ES_CENTER,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetData(-1, StringFormat("Welcome to the MSN Auto Replier by Secure_ICT. To start press \r\nSet Text and enter the text you wish to be entered when someone \r\ntalks to you.\r\n"))
$disclaimer = GUICtrlCreateEdit("", 8, 384, 321, 25, BitOR($ES_CENTER,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetData(-1, StringFormat("This is a free script. Edit it to suit your needs.\r\n"))
$setlabel = GUICtrlCreateLabel("Set the text you wish to be sent", 144, 96, 177, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $help
            SplashTextOn ( "Help me", "" & @CRLF & """Welcome to the MSN Auto Message Help."& @CRLF &"It's simple to make this run. All you need to do, is click the Set Text "& @CRLF &"button and "& @CRLF &"enter the text that you wish to be displayed when someone speaks to "& @CRLF &"you."& @CRLF &"You only have to set the text once as it saves the text as a .ini"& @CRLF &" "& @CRLF &"Then just press start and it will enter the message to any open MSN "& @CRLF &"conversation "& @CRLF &"window."& @CRLF &"Need more help? Just ask me on the topic."& @CRLF &""& @CRLF &"Secure_ICT")
            Sleep(10000)
            SplashOff()
        Case $setText
        Case $start
            For $i = 1 to 100
            WinWaitActive("- Conversation")
        If WinExists("- Conversation") Then
            WinActivate("- Conversation")
            Send(IniRead("Text.ini", "MSN Text", "TXT"," Not Found") & "{enter}")
            WinClose("- Conversation")
        EndIf
    Next 
        Case $stop
             Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

This "Next" statement does not have the "For" statement. I also don't believe you can do a loop inside of a "Switch" command (not 100% sure).

EDIT: By inside the Switch I mean when it is NOT after a Case statement. Either way you need the FOR $i = 1 to 5 (example) after a "Case".

Next
        Case $stop
             Exit

Kohr

Edited by Kohr

Share this post


Link to post
Share on other sites

For some reason my Iniwrite wasn't included

#include <GUIConstants.au3>

Opt("WinTitleMatchMode", 2)
            $i = 0 

#Region ### START Koda GUI section ### Form=c:\documents and settings\james\my documents\codes\koda_1.6.0.2\forms\msn msg.kxf
$window = GUICreate("MSN Auto-Reply", 339, 417, -1, -1)
$start = GUICtrlCreateButton("Start MSN Message", 8, 152, 121, 57, 0)
$stop = GUICtrlCreateButton("Stop MSN Message", 8, 224, 121, 57, 0)
$setText = GUICtrlCreateButton("Set text to send", 8, 80, 121, 57, 0)
$start1 = GUICtrlCreateLabel("Start the Message Replier", 144, 168, 185, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
$stop1 = GUICtrlCreateLabel("Stop the Message Replier", 144, 240, 185, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
$help = GUICtrlCreateButton("Help me!!!!", 8, 296, 321, 81, 0)
$welcome = GUICtrlCreateEdit("", 9, 8, 322, 57, BitOR($ES_CENTER,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetData(-1, StringFormat("Welcome to the MSN Auto Replier by Secure_ICT. To start press \r\nSet Text and enter the text you wish to be entered when someone \r\ntalks to you.\r\n"))
$disclaimer = GUICtrlCreateEdit("", 8, 384, 321, 25, BitOR($ES_CENTER,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetData(-1, StringFormat("This is a free script. Edit it to suit your needs.\r\n"))
$setlabel = GUICtrlCreateLabel("Set the text you wish to be sent", 144, 96, 177, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $help
            SplashTextOn ( "Help me", "" & @CRLF & """Welcome to the MSN Auto Message Help."& @CRLF &"It's simple to make this run. All you need to do, is click the Set Text "& @CRLF &"button and "& @CRLF &"enter the text that you wish to be displayed when someone speaks to "& @CRLF &"you."& @CRLF &"You only have to set the text once as it saves the text as a .ini"& @CRLF &" "& @CRLF &"Then just press start and it will enter the message to any open MSN "& @CRLF &"conversation "& @CRLF &"window."& @CRLF &"Need more help? Just ask me on the topic."& @CRLF &""& @CRLF &"Secure_ICT")
            Sleep(10000)
            SplashOff()
        Case $setText
            IniWrite("Text.ini", "MSN Text", "TXT", InputBox("What text should be entered?", "Type : ", "", "", 200, 50) )   
        Case $start
        Do
            WinWaitActive("- Conversation")
        If WinExists("- Conversation") Then
            WinActivate("- Conversation")
            Send(IniRead("Text.ini", "MSN Text", "TXT"," Not Found") & "{enter}")
            WinClose("- Conversation")
        EndIf
            $i += 1
        Until $i >= 5
        
        Case $stop
             ExitLoop   
    EndSwitch
WEnd

What am I doing with that code?

Share this post


Link to post
Share on other sites

I restructured it a little bit, hope it still does what you wanted :P... also you should add a status label somewhere, to tell the user if the script is waiting for a conversation or not...

#include <GUIConstants.au3>

Opt("WinTitleMatchMode", 2)
;HotKeySet("{F3}", "NextWhile")     <==== gave me an error, what for?
Global $trigger = 0

#Region ### START Koda GUI section ### Form=c:\documents and settings\james\my documents\codes\koda_1.6.0.2\forms\msn msg.kxf
$window = GUICreate("MSN Auto-Reply", 339, 417, -1, -1)
$start = GUICtrlCreateButton("Start MSN Message", 8, 152, 121, 57, 0)
$stop = GUICtrlCreateButton("Stop MSN Message", 8, 224, 121, 57, 0)
$setText = GUICtrlCreateButton("Set text to send", 8, 80, 121, 57, 0)
$start1 = GUICtrlCreateLabel("Start the Message Replier", 144, 168, 185, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
$stop1 = GUICtrlCreateLabel("Stop the Message Replier", 144, 240, 185, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
$help = GUICtrlCreateButton("Help me!!!!", 8, 296, 321, 81, 0)
$welcome = GUICtrlCreateEdit("", 9, 8, 322, 57, BitOR($ES_CENTER,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetData(-1, StringFormat("Welcome to the MSN Auto Replier by Secure_ICT. To start press \r\nSet Text and enter the text you wish to be entered when someone \r\ntalks to you.\r\n"))
$disclaimer = GUICtrlCreateEdit("", 8, 384, 321, 25, BitOR($ES_CENTER,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetData(-1, StringFormat("This is a free script. Edit it to suit your needs.\r\n"))
$setlabel = GUICtrlCreateLabel("Set the text you wish to be sent", 144, 96, 177, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $help
            SplashTextOn ( "Help me", "" & @CRLF & """Welcome to the MSN Auto Message Help."& @CRLF &"It's simple to make this run. All you need to do, is click the Set Text "& @CRLF &"button and "& @CRLF &"enter the text that you wish to be displayed when someone speaks to "& @CRLF &"you."& @CRLF &"You only have to set the text once as it saves the text as a .ini"& @CRLF &" "& @CRLF &"Then just press start and it will enter the message to any open MSN "& @CRLF &"conversation "& @CRLF &"window."& @CRLF &"Need more help? Just ask me on the topic."& @CRLF &""& @CRLF &"Secure_ICT")
            Sleep(10000)
            SplashOff()
        Case $setText
        Case $start
            while 1
                $nMsg = GUIGetMsg()
        ;WinWaitActive("- Conversation")        <=== paused the script!
                    If WinExists("- Conversation") Then
                        WinActivate("- Conversation")
                        Send(IniRead("Text.ini", "MSN Text", "TXT"," Not Found") & "{enter}")
                        WinClose("- Conversation")
                    EndIf
                if $nMsg = $stop Then
                    ExitLoop
                EndIf
            WEnd
    EndSwitch
WEnd
Edited by Polyphem

This post will be edited again by Polyphem: Tomorrow, 11:55 AM

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  

×
×
  • Create New...