Jump to content

Recommended Posts

Posted

So like this?

While 1
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Heyheyheyheyheyheyheyheyhey.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")
Wend

Will it only repeat once?

Posted (edited)

yeah, like that. and no, it will repeat forever...

if u want it to repeat once u would do:

For $i = 1 to 2
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Heyheyheyheyheyheyheyheyhey.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")
Next
Edited by CHRIS95219
Posted (edited)

Or

$loop = 0
While $loop < 5
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Heyheyheyheyheyheyheyheyhey.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")
$loop = $loop + 1
Wend
Edited by =sinister=
Posted

Or

$loop = 0
While $loop < 5
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Heyheyheyheyheyheyheyheyhey.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")
$loop = loop + 1
Wend
you forgot to put "$" before loop... $loop + 1. lol.

just thought i'd point that out, so bucky does'nt get confused...

$loop = 0
While $loop < 5
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Heyheyheyheyheyheyheyheyhey.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")
$loop = $loop + 1
Wend
Posted

Like this?

Loop
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Heyheyheyheyheyheyheyheyhey.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")
Exit

Thanks.

Posted

Like this?

Loop
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Heyheyheyheyheyheyheyheyhey.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")
Exit

Thanks.

nope...

while 1
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Heyheyheyheyheyheyheyheyhey.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")
ExitLoop
wend
;then whatever code you want here...

but the ExitLoop should be in a function like:

while 1
If _isPressed("01") then MouseClicked()
else
;;
endif
wend

Func MouseClicked()
MsgBox(0, "", "")
ExitLoop
EndFunc

np..

Posted

nope...

while 1
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Heyheyheyheyheyheyheyheyhey.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")
ExitLoop
wend
;then whatever code you want here...

but the ExitLoop should be in a function like:

while 1
If _isPressed("01") then MouseClicked()
else
;;
endif
wend

Func MouseClicked()
MsgBox(0, "", "")
ExitLoop
EndFunc

np..

Hmm...

This didn't work for me. It just stopped after the first time.

while 1
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Heyheyheyheyheyheyheyheyhey.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")
ExitLoop
wend
;then whatever code you want here...

Thanks again.

Posted

but would'nt 1 to 1 loop it 0 times?

which would mean it would'nt loop at all?

nope... just run the code that you wrote and see how many times it runs. :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Posted

yeah, u need to have the exit loop in a function... here is an example.. with a GUI and stuff.

#include <GuiConstants.au3>;Functions needed for most GUI Code
GuiCreate("Your GUI", 472, 188);Create GUI Window with the width of 472 and height of 188

$Button_1 = GuiCtrlCreateButton("Exit", 10, 130, 130, 50);Button_1 is the Exit Button
$Button_2 = GuiCtrlCreateButton("Execute Script", 250, 100, 210, 80); Button_2 is the Execute Script function

GuiSetState()
While 1;your LOOP
    $msg = GuiGetMsg();retrieves the button or control that was pressed
    Select; starts a case statement
    Case $msg = $GUI_EVENT_CLOSE;case statement, its like an if statement but better when you have alot of statements
    ExitLoop; If the program is exited it will exit the loop.
Case $msg = $Button_1
    ExitLoop;Exits the Loop
Case $msg = $Button_2
    ExecuteScript(); goes to the Execute Script function
    EndSelect; ends the case statements
WEnd

Func ExecuteScript();Creats the Execute Script Function
;Your Code
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Heyheyheyheyheyheyheyheyhey.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")
EndFunc
Posted

nope... just run the code that you wrote and see how many times it runs. :-)

i don't get it...

would'nt it be logical for

1 to 2 make it loop once?

because 2-1 = 1

not trying to argue, its just a bit mind boggeling...

  • Moderators
Posted

i don't get it...

would'nt it be logical for

1 to 2 make it loop once?

because 2-1 = 1

not trying to argue, its just a bit mind boggeling...

If that's mind boggeling ... look out!! :o ... just run the 2 loops below.

For $i = 1 To 2
    MsgBox(0, 'Test', $i)
Next

For $x = 1 To 1
    MsgBox(0, 'Test2', $x)
Next

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.

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
×
×
  • Create New...