Jump to content

Just started :( Cant stop loop


Romm
 Share

Recommended Posts

Hello all. Just started :) I want to make a restarter:

All is ok but i dont know how to stop script with "Stop button" (so then i could start it again)

#include <GUIConstants.au3>

$login = "k111"
$password = "d111"
$time = 1


GUICreate("My GUI Button"); will create a dialog box that when displayed is centered
Opt("GUICoordMode",2)
$Button_1 = GUICtrlCreateButton ("Start",  10, 30, 100)
$Button_2 = GUICtrlCreateButton ( "Stop",  0, -1)

GUISetState ()   ; will display an  dialog box with 2 button

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    Case $msg = $Button_1

While 2

If PixelGetColor(146, 706) = 16776191 Then; 
    MouseMove (715, 414)
    MouseClick("left")
    MouseClick("left")
    Send("{DEL 20}{BS 20}")
    Send($login) 
    Sleep(100*$time)
    Send("{TAB}{DEL 20}{BS 20}")
    Send($password) 
    Sleep (100*$time)
    Send("{ENTER 1}") 
    Sleep(5000*$time)
EndIf
If  PixelGetColor(98, 90) = 16762624 Then
    MouseMove(98, 90)
    MouseClick("left")
    Send("{ENTER 1}") 
    Send("{LCTRL}")
    Sleep(100)
    Send("{LCTRL}")
    Sleep(100)
    Send("{g}")
EndIf
Wend
           
EndSelect
Wend
Edited by Romm
Link to comment
Share on other sites

#include <GUIConstants.au3>

$login = "k111"
$password = "d111"
$time = 1

GUICreate("My GUI Button")
Opt("GUICoordMode",2)
$Button_1 = GUICtrlCreateButton ("Start",  10, 30, 100)
$Button_2 = GUICtrlCreateButton ( "Stop",  0, -1)

GUISetState ()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    Case $msg = $Button_1
        If PixelGetColor(146, 706) = 16776191 Then;
        MouseMove (715, 414)
        MouseClick("left")
        MouseClick("left")
        Send("{DEL 20}{BS 20}")
        Send($login)
        Sleep(100*$time)
        Send("{TAB}{DEL 20}{BS 20}")
        Send($password)
        Sleep (100*$time)
        Send("{ENTER 1}")
        Sleep(5000*$time)
        EndIf
        If    PixelGetColor(98, 90) = 16762624 Then
        MouseMove(98, 90)
        MouseClick("left")
        Send("{ENTER 1}")
        Send("{LCTRL}")
        Sleep(100)
        Send("{LCTRL}")
        Sleep(100)
        Send("{g}")
        EndIf
    EndSelect
WendoÝ÷ Ù«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì((ÀÌØí±½¥¸ôÅÕ½Ðí¬ÄÄÄÅÕ½Ðì(ÀÌØíÁÍÍݽÉôÅÕ½ÐíÄÄÄÅÕ½Ðì(ÀÌØíÑ¥µôÄ()U%
ÉÑ ÅÕ½Ðí5äU$    ÕÑѽ¸ÅÕ½Ðì¤)=ÁÐ ÅÕ½ÐíU%
½½É5½ÅÕ½Ðì°È¤(ÀÌØí  ÕÑѽ¹|ÄôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½ÐíMÑÉÐÅÕ½Ðì°ÄÀ°ÌÀ°ÄÀÀ¤(ÀÌØí   ÕÑѽ¹|ÈôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½ÐíMѽÀÅÕ½Ðì°À°´Ä¤()U%MÑMÑÑ ¤()]¡¥±Ä(ÀÌØíµÍôU%Ñ5Í ¤(M±Ð(
ÍÀÌØíµÍôÀÌØíU%}Y9Q}
1=M(á¥Ñ1½½À($%
ÍÀÌØíµÍôÀÌØí    ÕÑѽ¹|Ä(%]¡¥±È($$ÀÌØíµÍôU%Ñ5Í ¤($%%ÀÌØíµÍôÀÌØíU%}Y9Q}
1=MQ¡¸($$%á¥Ð($%¹%($%%A¥á±Ñ
½±½È ÄÐØ°ÜÀؤôÄØÜÜØÄäÄQ¡¸ì($%5½ÕÍ5½Ù ÜÄÔ°ÐÄФ($%5½ÕÍ
±¥¬ ÅÕ½Ðí±ÐÅÕ½Ðì¤($%5½ÕÍ
±¥¬ ÅÕ½Ðí±ÐÅÕ½Ðì¤($%M¹ ÅÕ½Ðíí0ÈÁõí   LÈÁôÅÕ½Ðì¤($%M¹ ÀÌØí±½¥¸¤($%M±À ÄÀÀ¨ÀÌØíÑ¥µ¤($%M¹ ÅÕ½ÐííQ   õí0ÈÁõí   LÈÁôÅÕ½Ðì¤($%M¹ ÀÌØíÁÍÍݽɤ($%M±À ÄÀÀ¨ÀÌØíÑ¥µ¤($%M¹ ÅÕ½Ðíí9QHÅôÅÕ½Ðì¤($%M±À ÔÀÀÀ¨ÀÌØíÑ¥µ¤($%¹%($%%A¥á±Ñ
½±½È äà°äÀ¤ôÄØÜØÈØÈÐQ¡¸($%5½ÕÍ5½Ù äà°äÀ¤($%5½ÕÍ
±¥¬ ÅÕ½Ðí±ÐÅÕ½Ðì¤($%M¹ ÅÕ½Ðíí9QHÅôÅÕ½Ðì¤($%M¹ ÅÕ½Ðíí1
QI1ôÅÕ½Ðì¤($%M±À ÄÀÀ¤($%M¹ ÅÕ½Ðíí1
QI1ôÅÕ½Ðì¤($%M±À ÄÀÀ¤($%M¹ ÅÕ½ÐííôÅÕ½Ðì¤(%¹%)]¹(%¹M±Ð)]¹

I didn't run the script but

Can I ask you why did you use loop inside the main loop?

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

Ok i just want something like this (loop) but for v. 3:

:START

If PixelGetColor(146, 706) = 16776191 Then;
        MouseMove (715, 414)
        MouseClick("left")
        MouseClick("left")
        Send("{DEL 20}{BS 20}")
        Send($login)
        Sleep(100*$time)
        Send("{TAB}{DEL 20}{BS 20}")
        Send($password)
        Sleep (100*$time)
        Send("{ENTER 1}")
        Sleep(5000*$time)
        EndIf
        If  PixelGetColor(98, 90) = 16762624 Then
        MouseMove(98, 90)
        MouseClick("left")
        Send("{ENTER 1}")
        Send("{LCTRL}")
        Sleep(100)
        Send("{LCTRL}")
        Sleep(100)
        Send("{g}")

GOTO START

but i need to start and stop this fragment with buttons

Edited by Romm
Link to comment
Share on other sites

so the first script I wrote will be OK for u

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

just add this under Select

Case $msg = $Button_2
            Exit
Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

tried...

still cant stop...(script #2)

script #1 is ok, but still no loop :)

I need very small script:

If start button - start loop

If stop button - stop loop

Start

Check. If ok - do

Then

Check. If ok - do

go to start

Link to comment
Share on other sites

#include <GUIConstants.au3>

$login = "k111"
$password = "d111"
$time = 1

GUICreate("My GUI Button")
Opt("GUICoordMode",2)
$Button_1 = GUICtrlCreateButton ("Start",  10, 30, 100)
$Button_2 = GUICtrlCreateButton ( "Stop",  0, -1)

GUISetState ()

While 1
    $msg = GUIGetMsg()
$color_val = PixelGetColor(146, 706)
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    Case $msg = $Button_1
        If $color_val  = 16776191 Then;
        MouseMove (715, 414)
        MouseClick("left")
        MouseClick("left")
        Send("{DEL 20}{BS 20}")
        Send($login)
        Sleep(100*$time)
        Send("{TAB}{DEL 20}{BS 20}")
        Send($password)
        Sleep (100*$time)
        Send("{ENTER 1}")
        Sleep(5000*$time)
        Else
        EndIf
        If    PixelGetColor(98, 90) = 16762624 Then
        MouseMove(98, 90)
        MouseClick("left")
        Send("{ENTER 1}")
        Send("{LCTRL}")
        Sleep(100)
        Send("{LCTRL}")
        Sleep(100)
        Send("{g}")
        EndIf
    Case $msg = $Button_2
        $color_val = 0
    EndSelect
Wend

sorry this one will work for u

dum ha !!

Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

If start button - start loop

If stop button - stop loop

Start

Check. If ok - do

Then

Check. If ok - do

go to start

The reason this will not work is that your main loop does not include a check to see if the button was pressed. You could use on event mode for you gui if this setup is necessary.

Link to comment
Share on other sites

BTW...the only problem is - buttons.

Without buttons all work cool...

But i want with buttons

how about this maybe you can try.

#include <GUIConstants.au3>

$login = "k111"
$password = "d111"
$time = 1


GUICreate("My GUI Button"); will create a dialog box that when displayed is centered
Opt("GUICoordMode",2)
$Button_1 = GUICtrlCreateButton ("Start",  10, 30, 100)
$Button_2 = GUICtrlCreateButton ( "Stop",  0, -1)

GUISetState ()     ; will display an  dialog box with 2 button

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    Case $msg = $Button_1
        While 2
            $msg = GUIGetMsg()
            Select  
                Case $msg = $GUI_EVENT_CLOSE
                    Exit
                Case $msg = $Button_2
                    ExitLoop(1)
            EndSelect
            
            If PixelGetColor(146, 706) = 16776191 Then;
            MouseMove (715, 414)
            MouseClick("left")
            MouseClick("left")
            Send("{DEL 20}{BS 20}")
            Send($login)
            Sleep(100*$time)
            Send("{TAB}{DEL 20}{BS 20}")
            Send($password)
            Sleep (100*$time)
            Send("{ENTER 1}")
            Sleep(5000*$time)
            EndIf
        
            If    PixelGetColor(98, 90) = 16762624 Then
            MouseMove(98, 90)
            MouseClick("left")
            Send("{ENTER 1}")
            Send("{LCTRL}")
            Sleep(100)
            Send("{LCTRL}")
            Sleep(100)
            Send("{g}")
            EndIf
        Wend
          
EndSelect
Wend
Edited by smooth
Link to comment
Share on other sites

how about this maybe you can try.

#include <GUIConstants.au3>

$login = "k111"
$password = "d111"
$time = 1


GUICreate("My GUI Button"); will create a dialog box that when displayed is centered
Opt("GUICoordMode",2)
$Button_1 = GUICtrlCreateButton ("Start",  10, 30, 100)
$Button_2 = GUICtrlCreateButton ( "Stop",  0, -1)

GUISetState ()     ; will display an  dialog box with 2 button

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    Case $msg = $Button_1
        While 2
            $msg = GUIGetMsg()
            Select  
                Case $msg = $GUI_EVENT_CLOSE
                    Exit
                Case $msg = $Button_2
                    ExitLoop(1)
            EndSelect
            
            If PixelGetColor(146, 706) = 16776191 Then;
            MouseMove (715, 414)
            MouseClick("left")
            MouseClick("left")
            Send("{DEL 20}{BS 20}")
            Send($login)
            Sleep(100*$time)
            Send("{TAB}{DEL 20}{BS 20}")
            Send($password)
            Sleep (100*$time)
            Send("{ENTER 1}")
            Sleep(5000*$time)
            EndIf
        
            If    PixelGetColor(98, 90) = 16762624 Then
            MouseMove(98, 90)
            MouseClick("left")
            Send("{ENTER 1}")
            Send("{LCTRL}")
            Sleep(100)
            Send("{LCTRL}")
            Sleep(100)
            Send("{g}")
            EndIf
        Wend
          
EndSelect
Wend
That is never going to work.

While 2

While what is 2 ??

While 1
    $msg = GUIGetMsg()
    Switch
       Case $GUI_EVENT_CLOSE
            ExitLoop
       Case $Button_1
          Select
             Case PixelGetColor(146, 706) = 16776191
        MouseMove (715, 414)
        MouseClick("left")
        MouseClick("left")
        Send("{DEL 20}{BS 20}")
        Send($login)
        Sleep(100*$time)
        Send("{TAB}{DEL 20}{BS 20}")
        Send($password)
        Sleep (100*$time)
        Send("{ENTER 1}")
        Sleep(5000*$time)
             Case PixelGetColor(98, 90) = 16762624
        MouseMove(98, 90)
        MouseClick("left")
        Send("{ENTER 1}")
        Send("{LCTRL}")
        Sleep(100)
        Send("{LCTRL}")
        Sleep(100)
        Send("{g}")
             Case Else
        ContinueLoop
          EndSelect
      EndSwitch
Wend

This is untested but I think I have it right if I understand what you want.

This part puzzles me a bit but if that's what you want then fine by me.

Send("{ENTER 1}")

Send("{LCTRL}")

Sleep(100)

Send("{LCTRL}")

Sleep(100)

Send("{g}")

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Ok what i mean :)

Start Button activates loop and only stop button can stop it.

Something like.

If Start button pressed   Then
Goto Start
EndIf

If Stop button pressed   Then
Goto End
EndIf

:Start

<bla bla bla>

If $1 = x Then
do something
EndIF

If $2 = y Then
do something
EndIf

goto Start

:End

I know this sounds dumb, but i need this script for 3.0 v to understand how loop works.

Sorry my noobness

Edited by Romm
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...