Sign in to follow this  
Followers 0
SilverSky

How to...?

10 posts in this topic

#1 ·  Posted (edited)

HI, I have a problem

How to insert my function on this script

Ok this is my script :

While 1
     $nMsg = GUIGetMsg()
     Switch $nMsg
             Case $GUI_EVENT_CLOSE
Case $Button1
For $i = 1 To 1000
MouseMove (356, 400)
Sleep(500)
MouseClick("primary", 356, 400)
Sleep(2000)
MouseMove(750, 654 )
Sleep(500)
MouseClick("primary", 750, 654)
Sleep(2000)
MouseMove(677, 612)
Sleep(500)
MouseClick("primary", 677, 612)
Sleep(2000)
MouseMove(677,612)
Sleep(500)
MouseClick("primary", 677, 612)
Sleep(2000)
MouseMove(866, 697)
Sleep(500)
MouseClick("primary", 866, 697)
Sleep(300000)
Next
                     <---I would like to have this function
EndSwitch
WEnd

My Function:

Func Pauza()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip("Text",0,0)
WEnd
EndFunc

SORRY FOR MY BAD ENGLISH

Edited by SilverSky

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi, SilverSky, welcome to the forum. First off, I would suggest a more descriptive title in the future. Secondly, have you looked at the examples for Func in the help file? They do a pretty good job of showing you how to properly call the function. All you need to do is add the call to the function (Pauza() in your case) at whatever point in the script you would like it to run.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I wish this function is called by the $Button2

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Case $Button1
For $i = 1 To 1000
MouseMove (356, 400)
Sleep(500)
MouseClick("primary", 356, 400)
Sleep(2000)
MouseMove(750, 654 )
Sleep(500)
MouseClick("primary", 750, 654)
Sleep(2000)
MouseMove(677, 612)
Sleep(500)
MouseClick("primary", 677, 612)
Sleep(2000)
MouseMove(677,612)
Sleep(500)
MouseClick("primary", 677, 612)
Sleep(2000)
MouseMove(866, 697)
Sleep(500)
MouseClick("primary", 866, 697)
Sleep(300000)
Next
Case $Button2
<---I would like to have this function
EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Then look at the example in the help file under Func and you'll see how to do it :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Ok, i'm stuck...

Func TogglePaused()
        $Paused = Not $Paused
        While $Paused
                Sleep(100)
                TrayTip("NosTale", "Pauza", 5, 1)
        WEnd
    EndFunc


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Case $Button1
For $i = 1 To 1000
MouseMove (356, 400)
Sleep(500)
MouseClick("primary", 356, 400)
Sleep(2000)
MouseMove(750, 654 )
Sleep(500)
MouseClick("primary", 750, 654)
Sleep(2000)
MouseMove(677, 612)
Sleep(500)
MouseClick("primary", 677, 612)
Sleep(2000)
MouseMove(677,612)
Sleep(500)
MouseClick("primary", 677, 612)
Sleep(2000)
MouseMove(866, 697)
Sleep(500)
MouseClick("primary", 866, 697)
Sleep(300000)
Next
Case $Button2
TogglePaused()
EndSwitch
WEnd

looks alright ? but when i open my script this error block me:

WARNING: $Paused: possibly used before declaration.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

SilverSky,

First, to get help you will need to post something that is runnable.

Secondly, when button 1 is actioned your script will become unresponive for the next 83+ hours, probably not what you want.

To solve this, see M23's excellent article for interrupting running functions. Do a search for it.

In case you want to test this for yourself, run the following

; *** Start added by AutoIt3Wrapper ***
#include <GUIConstantsEx.au3>
; *** End added by AutoIt3Wrapper ***

#AutoIt3Wrapper_Add_Constants=n

local $paused = false

Local $gui010 = GUICreate('Mouse Clicking Hell')
Local $Button1 = GUICtrlCreateButton('#1', 10, 10, 200, 20)
Local $Button2 = GUICtrlCreateButton('#2', 10, 50, 200, 20)
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            exit
        Case $Button1
            For $i = 1 To 1000
                MouseMove(356, 400)
                Sleep(500)
                MouseClick("primary", 356, 400)
                Sleep(2000)
                MouseMove(750, 654)
                Sleep(500)
                MouseClick("primary", 750, 654)
                Sleep(2000)
                MouseMove(677, 612)
                Sleep(500)
                MouseClick("primary", 677, 612)
                Sleep(2000)
                MouseMove(677, 612)
                Sleep(500)
                MouseClick("primary", 677, 612)
                Sleep(2000)
                MouseMove(866, 697)
                Sleep(500)
                MouseClick("primary", 866, 697)
                Sleep(300000)
            Next
        Case $Button2
             pauza()
    EndSwitch
WEnd

Func Pauza()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip("Text", 0, 0)
    WEnd
EndFunc   ;==>Pauza

kylomas

edit: clarification - have button 1 call a function and make that function interruptible following the doc that I pointed you to.

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

That warning message should say, "$Paused USED before declaration", and you should read the Help file.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

throw:

global $paused= 0

as the first line of your script, before the func TogglePaused()

Edited by Xandy

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Ok but when i run first option $Button1:

While 1
     $nMsg = GUIGetMsg()
     Switch $nMsg
             Case $GUI_EVENT_CLOSE
Case $Button1
For $i = 1 To 1000
MouseMove (356, 400)
Sleep(500)
MouseClick("primary", 356, 400)
Sleep(2000)
MouseMove(750, 654 )
Sleep(500)
MouseClick("primary", 750, 654)
Sleep(2000)
MouseMove(677, 612)
Sleep(500)
MouseClick("primary", 677, 612)
Sleep(2000)
MouseMove(677,612)
Sleep(500)
MouseClick("primary", 677, 612)
Sleep(2000)
MouseMove(866, 697)
Sleep(500)
MouseClick("primary", 866, 697)
Sleep(300000)

global $paused= 0

Func TogglePaused()
     $Paused = Not $Paused
     While $Paused
             Sleep(100)
             TrayTip("NosTale", "Pauza", 5, 1)
     WEnd
EndFunc
func. still doesent stop option 1 $Button1 :/ but when i click first option 2 $Button2 option works... Edited by SilverSky

Share this post


Link to post
Share on other sites

SilverSky,

It will be impossible to help you unless you read and understand each reply to your topic. Re-read reply #6.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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