Jump to content

How to...?


 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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
Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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.
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
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...