Jump to content

Situation


Recommended Posts

hey guys,

I've got this situation:

i've got a script running in a script.

This is the gui script (which include the other script: dossing paint)

As u can see:

u have to input a value, which decides how many times the "dossing paint" will run

At a certain point: the dossing paint programm will stop, i want it to go back to the gui script and let it start over again.

But with the "exit" code i'm using right now: it just stop the whole programm (all though i just mention it in the dossing paint.au3 :s

It's quite diffecult to explain, but i hope you get it:

résumé:

So: how can i let a script stop working, but let the greater programm continue

#include <GUIConstants.au3>

;settings: exit and start keys

HotKeySet ( "{F6}", 'end')


;=====================================

GUICreate("Dossing paint", 250, 150)
GUISetFont(12)



$pass = InputBox ("Dossing paint", "please enter your password","","*",250,150)

GUICtrlCreateLabel("how many games should I run?", 4, 4)
$put1 = GUICtrlCreateInput("number", 4, 25, 200, 25)

$send = GUICtrlCreateButton("Start", 4, 60, 150, 25)

GUISetState()



While  1
    $msg = GUIGetMsg()
    If $pass <> "password" Then
            $WrongPass = MsgBox (1,"warning" , "incorrect password" & @CRLF & "TRY AGAIN ?")
            If  $WrongPass = 1 Then
                $pass = InputBox ("enter password", "please enter your password","","*",250,150)
            ElseIf $WrongPass = 2 Then
                $Exting = MsgBox (0,"Exiting" , "Due to cancelation by user.." & @CRLF & "Now exiting the programm")
                ExitLoop
            EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $send Then SendMyData ()
     
WEnd




      

Func SendMyData()
$i = 0
do
    #include <dossing paint.au3> ; 
sleep (50)  
    $i = $i + 1
until $i = GUICtrlRead ($put1)

EndFunc

Func end()
    Exit 0
endfunc

This is dossing paint.au3

$pixel1 = pixelsearch ( 515, 241, 890, 322, 0xFFF46A ) 
If IsArray ($pixel1) = true then
    MouseClick("left",695,560,2)
    sleep (15000)
    mouseclick ( "left", 1048, 733, 1, 2)
    Exit
EndIf

So as u can see: if the color changed into 0xfff46A than i would just like to stop this dossing paint.au3 and let the gui script do it all over again (do, untill loop)

closer look @the do untill loop

Func SendMyData()
$i = 0
do
    #include <dossing paint.au3> ; 
sleep (50)  
    $i = $i + 1
until $i = GUICtrlRead ($put1)

EndFunc

So let's say i input a value 7, than i want dossing paint to run 7x.

If dossing paint ends, than i would just like to do it another 6x

Any solution for the "exit script problem"?

Edited by Qsert18
Link to comment
Share on other sites

hey guys,

I've got this situation:

i've got a script running in a script.

This is the gui script (which include the other script: dossing paint)

As u can see:

u have to input a value, which decides how many times the "dossing paint" will run

At a certain point: the dossing paint programm will stop, i want it to go back to the gui script and let it start over again.

But with the "exit" code i'm using right now: it just stop the whole programm (all though i just mention it in the dossing paint.au3 :s

It's quite diffecult to explain, but i hope you get it:

résumé:

So: how can i let a script stop working, but let the greater programm continue

#include <GUIConstants.au3>

;settings: exit and start keys

HotKeySet ( "{F6}", 'end')


;=====================================

GUICreate("Dossing paint", 250, 150)
GUISetFont(12)



$pass = InputBox ("Dossing paint", "please enter your password","","*",250,150)

GUICtrlCreateLabel("how many games should I run?", 4, 4)
$put1 = GUICtrlCreateInput("number", 4, 25, 200, 25)

$send = GUICtrlCreateButton("Start", 4, 60, 150, 25)

GUISetState()



While  1
    $msg = GUIGetMsg()
    If $pass <> "password" Then
            $WrongPass = MsgBox (1,"warning" , "incorrect password" & @CRLF & "TRY AGAIN ?")
            If  $WrongPass = 1 Then
                $pass = InputBox ("enter password", "please enter your password","","*",250,150)
            ElseIf $WrongPass = 2 Then
                $Exting = MsgBox (0,"Exiting" , "Due to cancelation by user.." & @CRLF & "Now exiting the programm")
                ExitLoop
            EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $send Then SendMyData ()
     
WEnd




    

Func SendMyData()
$i = 0
do
    #include <dossing paint.au3> ; 
sleep (50)  
    $i = $i + 1
until $i = GUICtrlRead ($put1)

EndFunc

Func end()
    Exit 0
endfunc

This is dossing paint.au3

$pixel1 = pixelsearch ( 515, 241, 890, 322, 0xFFF46A ) 
If IsArray ($pixel1) = true then
    MouseClick("left",695,560,2)
    sleep (15000)
    mouseclick ( "left", 1048, 733, 1, 2)
    Exit
EndIf

So as u can see: if the color changed into 0xfff46A than i would just like to stop this dossing paint.au3 and let the gui script do it all over again (do, untill loop)

closer look @the do untill loop

Func SendMyData()
$i = 0
do
    #include <dossing paint.au3> ; 
sleep (50)  
    $i = $i + 1
until $i = GUICtrlRead ($put1)

EndFunc

So let's say i input a value 7, than i want dossing paint to run 7x.

If dossing paint ends, than i would just like to do it another 6x

Any solution for the "exit script problem"?

AT a quick look I think you have misunderstood what th einclude is doing. All #include does is to replace the #iclude line with the text that is in the include file. SO you don't have another script running at all so exit stops the script not just the function you called.

. I think you need to change it to something like this

Func SendMyData()
$i = 0
do
  _DosPaint();dossing paint.au3> ; 
sleep (50)  
    $i = $i + 1
until $i = GUICtrlRead ($put1)

EndFunc

Add

#iclude "dossing paint.au3"

at the top of your script with other includes, then change dossingpaint.au3 to something like this

Func _DosPaint()
$pixel1 = pixelsearch ( 515, 241, 890, 322, 0xFFF46A ) 
If IsArray ($pixel1) = true then
    MouseClick("left",695,560,2)
    sleep (15000)
    mouseclick ( "left", 1048, 733, 1, 2)
    return; not exit
EndIf
endfunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

euhm ok...but it still ain't doing what i would like it to do.

I made a simplified version of the scripts.

I'll post them here 1st:

(the gui.au3 file)

#include <GUIConstants.au3>


;settings: exit and start keys

HotKeySet ( "{F6}", 'end')


;=====================================

GUICreate("Dossing paint", 250, 150)
GUISetFont(12)



$pass = InputBox ("Dossing paint", "please enter your password","","*",250,150)

GUICtrlCreateLabel("how many games should I run?", 4, 4)
$put1 = GUICtrlCreateInput("number", 4, 25, 200, 25)

$send = GUICtrlCreateButton("Start", 4, 60, 150, 25)

GUISetState()



While  1
    $msg = GUIGetMsg()
    If $pass <> "password" Then
            $WrongPass = MsgBox (1,"warning" , "incorrect password" & @CRLF & "TRY AGAIN ?")
            If  $WrongPass = 1 Then
                $pass = InputBox ("enter password", "please enter your password","","*",250,150)
            ElseIf $WrongPass = 2 Then
                $Exting = MsgBox (0,"Exiting" , "Due to cancelation by user.." & @CRLF & "Now exiting the programm")
                ExitLoop
            EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $send Then SendMyData ()
     
WEnd




      

Func SendMyData()
$i = 0
do
  _DosPaint();dossing paint.au3> ; 
sleep (50)  
    $i = $i + 1
until $i = GUICtrlRead ($put1)

EndFunc

Func end()
    Exit 0
endfunc

and now the function itself:

;
; AutoIt Version: 3.0
; Language:       English
; Author:         Stefan
;
; Script Function:
;dossing paint
;settings: type slower
AutoItSetOption ("SendKeyDelay", 100)

;var'
$Pixel1 = PixelGetColor(769, 532)


sleep (5000)

MouseClick("left", 304, 871, 1)
sleep (500)

MouseClick("left", 845,236, 2)
sleep (500)

MouseClick("left", 910,237, 2)
sleep (500)

MouseClick("left", 304, 871, 1)
sleep (1000)

;---------------------------------------------------------------------------------------------------------------------------------
Func _DosPaint()
$pixel1 = pixelsearch ( 515, 241, 890, 322, 0xFFF46A ) 
If IsArray ($pixel1) = true then
    MouseClick("left",695,560,2)
    sleep (15000)
    mouseclick ( "left", 1048, 733, 1, 2)
    return; not exit
EndIf
endfunc

$pixel2 = pixelsearch ( 515, 241, 890, 322, 0xAA0303 ) 
If IsArray ($pixel1) = true then
    MouseClick("left",695,560,2)
    sleep (15000)
    mouseclick ( "left", 1048, 733, 1, 2)
EndIf





MouseClick("left", 304, 871, 1)
sleep (500)

MouseClick("left", 845,236, 2)
sleep (500)

MouseClick("left", 910,237, 2)
sleep (500)

MouseClick("left", 304, 871, 1)

sleep (5000)

I don't think i can use "endfunc" in this, since it has to be something INSIDE the if/endif statement (endfunc can only be put after endif :s).

So what i basically want:

1. u start the gui

2. it will ask u a password ( just cool stuff :unsure:)

3. it will ask you how many times u want to run dospaint.au3

4. it will run dospaint.au3

5. it will make 4 clicks

6. If the color is gold/red in the paint window than i would like it to stop the dospaint.au3 BUT continue with the gui.au3 (and so restart the dospaint.au3).

So for example: i wanted it to run dospaint.au3 3x, than dospaint.au3 will end in the middle of the script and than run another 2x :>

Thanks in advance

kind regards,

stefan

PS: thanks for ur fast reply of yesterday

Edited by Qsert18
Link to comment
Share on other sites

I'm not 100% sure of what you are trying to accomplish, but why not build the dossingpaint.au3 into your script as one function? This runs it and when it's finished, the GUI continues to run:

#include <GUIConstants.au3>

;settings: exit and start keys

HotKeySet ( "{F6}", 'end')


;=====================================

GUICreate("Dossing paint", 250, 150)
GUISetFont(12)


$pass = InputBox ("Dossing paint", "please enter your password","","*",250,150)

GUICtrlCreateLabel("how many games should I run?", 4, 4)
$put1 = GUICtrlCreateInput("number", 4, 25, 200, 25)

$send = GUICtrlCreateButton("Start", 4, 60, 150, 25)

GUISetState()

While  1
    $msg = GUIGetMsg()
    If $pass <> "password" Then
            $WrongPass = MsgBox (1,"warning" , "incorrect password" & @CRLF & "TRY AGAIN ?")
            If  $WrongPass = 1 Then
                $pass = InputBox ("enter password", "please enter your password","","*",250,150)
            ElseIf $WrongPass = 2 Then
                $Exting = MsgBox (0,"Exiting" , "Due to cancelation by user.." & @CRLF & "Now exiting the programm")
                ExitLoop
            EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $send Then SendMyData ()
     
WEnd

Func SendMyData()
$i = 0
do
    
  _DosPaint();dossing paint.au3> ; 
sleep (50)  
    $i = $i + 1
until $i = GUICtrlRead ($put1)

EndFunc

Func end()
    Exit 0
endfunc


Func _DosPaint()
AutoItSetOption ("SendKeyDelay", 100)

;var'
$Pixel1 = PixelGetColor(769, 532)


sleep (5000)

MouseClick("left", 304, 871, 1)
sleep (500)

MouseClick("left", 845,236, 2)
sleep (500)

MouseClick("left", 910,237, 2)
sleep (500)

MouseClick("left", 304, 871, 1)
sleep (1000)

$pixel1 = pixelsearch ( 515, 241, 890, 322, 0xFFF46A ) 
If IsArray ($pixel1) = true then
    MouseClick("left",695,560,2)
    sleep (15000)
    mouseclick ( "left", 1048, 733, 1, 2)
    return; not exit
EndIf

$pixel2 = pixelsearch ( 515, 241, 890, 322, 0xAA0303 ) 
If IsArray ($pixel1) = true then
    MouseClick("left",695,560,2)
    sleep (15000)
    mouseclick ( "left", 1048, 733, 1, 2)
EndIf

MouseClick("left", 304, 871, 1)
sleep (500)

MouseClick("left", 845,236, 2)
sleep (500)

MouseClick("left", 910,237, 2)
sleep (500)

MouseClick("left", 304, 871, 1)

sleep (5000)
endfunc

#include <ByteMe.au3>

Link to comment
Share on other sites

bump

First please be a little more patient. Bumping your post after only a few hours is daft IMO. Bumping a post is not like rubbing a magic lantern :unsure:.

You need to grasp some fundamentals, and you need to pay attention. I say that because what I showed in my first reply was largely lost or not understood.

Ignore what you want to do in your script for a minute.

Imagine you have this script.

For $n = 1 To 100
    If Mod($n, 3) = 0 Then
        ConsoleWrite($n * $n / 3 & @CRLF)
    EndIf
Next
MsgBox(262144, "All done", "ok")

That can be done like this

For $n = 1 To 100
    _DoTheIfBit($n)
Next
_SayBye()


func _DoTheIfBit($i)
    If Mod($i, 3) = 0 Then
        _WriteAns($i * $i / 3)
    EndIf
EndFunc


Func _WriteAns($a)
    ConsoleWrite($a & @CRLF)
EndFunc

func _SayBye()
    MsgBox(262144, "All done", "ok")
EndFunc

.. and that can be done like this

#include "myAmazingFunctions.au3"

For $n = 1 To 100
    _DoTheIfBit($n)
Next
_SayBye()

where there is a file called "myAmazingFunctions.au3" as below

func _DoTheIfBit($i)
    If Mod($i, 3) = 0 Then
        _WriteAns($i * $i / 3)ConsoleWrite($i * $i / 3 & @CRLF)
    EndIf
EndFunc


Func _WriteAns($a)
    ConsoleWrite($a & @CRLF)
EndFunc

func _SayBte()
    MsgBox(262144, "All done", "ok")
EndFunc

When you have understood that, which means reading it, thinking about it, changing it and convincing yourself that you get it and that you can do it, and you could explain to someone else how to do it, then look at what you want to do with your script again.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

i dont really get what it should do but anyways...

I'm not 100% sure of what you are trying to accomplish

I'm just trying some stuff out in paint, so i can make the programm i have in mind later (paint is quite easy for the color stuff :unsure:)

but why not build the dossingpaint.au3 into your script as one function?

Well: my script was becoming quite a chaos (a bit big) i just posted a simplified version of it.

Though, i'm putting my both scripts together now, since the script u posted works like i wanted it to.

Thanks for ur replies, problem solved now =)

#include <dossing paint.au3> at the top of the gui.au3

If i do this, than it will 1st run dossing paint.au3 and afterwards my gui.au3.
Link to comment
Share on other sites

i was just bumping my post cause it was at the bottom of the list :unsure: (so i thought nobody would read it anymore)

You need to grasp some fundamentals, and you need to pay attention.

100% true :>

atm: checking the post u just posted, will edit this msg afterwards

what text editor supports this console write? Ain't working in notepad, notepad++, or anything else :D

i'm not fully understanding this "console write"...never saw it before and the help file is quite vague about it (well quite vague to me = i don't understand it ;))

Edited by Qsert18
Link to comment
Share on other sites

i was just bumping my post cause it was at the bottom of the list :unsure: (so i thought nobody would read it anymore)

100% true :>

atm: checking the post u just posted, will edit this msg afterwards

what text editor supports this console write? Ain't working in notepad, notepad++, or anything else :D

i'm not fully understanding this "console write"...never saw it before and the help file is quite vague about it (well quite vague to me = i don't understand it ;))

Have a look at SciTE. I think most people in these forums use it. It will make your life a lot easier. Install it, open a file, or start a new one and save as an au3 file. Use Ctrl T to format the code, it works brilliantly, use F1 to open the AutoIt help at the word under the cursor, use F5 to run a script, use Ctrl F7 to compile it. Many many more features.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...