Jump to content

Mouse click <First ever script>


Recommended Posts

Started a new topic as not to take over someone elses thread, Copy paste

http://www.torrez.org/projects/xumouse.shtml

With the above app I can set a Delay before the mouse clicks agian but I need something like a delay 45 sec to 55 sec and its just clicks at a random time inbetween 45 and 55 sec?

I posted on another board and was sent to AutoIt but I have never scripted before so am real lost.

Can this be done using AutoIt? Wheres a good place to start?

Thanks

SupraNatural Today, 03:44 PM Post #10

A good place to start is telling us what you want done. Saying delay the mouse 45 secs doesn't help much, I'd reccomend reading the helpfile and searching it for "mouse" and "sleep"

--------------------

Wepwawet Today, 04:07 PM Post #11

All I want it to do is click the Left mouse button, But I dont want it at set rate like 45 sec so every 45 it clicks= bad for me

What i would like is say variables are 45 sec and 55 sec so every 45-55 sec it just clicks the left mouse button but i need the values of the time between the two set variables to change.

exp

45 sec first click

49 sec sec click

47 sec third click

54 sec forth click

so basicly just random picking of when the mouse is clicked without a static value. I have read the help and think i could do most of it myself but dont see where/how to get it to pick a random number between the time variables.

I hope I explained it well, but have a habit of making things sound more complacted then they really are.

Thanks for the help

Saunders Today, 04:54 PM Post #12

Check out the Random function. It has a minimum and maximum setting.

CODE$delay = Random(45, 55, 1)(the 1 ensures the return will be an integer, no decimal places)

This post has been edited by Saunders: Today, 04:54 PM

--------------------

It's like that old "knock-knock" joke where you say "banana" several times. Then, you say "orange" and the other person says, "Orange who?" And you say, "Orange you glad I didn't say 'Banana?'" Well, the computer just keeps saying "banana" Rob. Do you get it? I never get my orange. It's just "banana" and "banana who?" and "banana" and "banana who?" - Source

--------------------

AutoIt3 Documentation - Read Please!!!

Quick Links: Beta Download / Beta Thread» / IsPressed UDF / Active Topics / My Posts / My Site

My UDF's: Unix Time Functions / NumBaseConvert / WinGetProcessName / WinProcessClose

Wepwawet Today, 07:46 PM Post #13

Cpl quick questions

1) Is this the right form to keep asking lots of questions form a total new to script writing person such as myself?

2) Expression in this script here can i put anything?? like to end the looping I would like to hit a key on my keyboard- How would i put the key in so the program sees that i pushed it so it will stop the script?

3) Am I on the right track for what I want this to do?

4) Should I make a GUI like XUMOUSE above so i can just enter my variables and have a start/stop button for ease of use? Where now I would have to edit the script everytime to change my variables($delay = Random( [55 [,60 [,0 ]]] ))

5) Being that this is my first ever script would 4 be WAY to hard to where I am pulling my hair out trying to figure it out?

; Script Start -

MouseClick ( "Left" [, 29, 85 [, 1 [, 10 ]]] )

$delay = Random( [55 [,60 [,0 ]]] )

While <expression>

statements

...

WEnd

Thanks for everyones time that is helping me, If there is a better place to be posting these types of questions please let me know where.

herewasplato Today, 08:42 PM Post #14

It would have been better to start a new post for this round of questions. This string of posts (thread) belongs to Zithen. It makes a difference to the way some users read the forum and how some are notified of when another member posts to "their" thread.

1) Other than that, yes - this is the correct forum (place) to ask.

2) See help file under HotKeySet - steal the code at the bottom of that page.

3) Yes

4) Stay away from GUI on first script - use InputBox function

5) Not too hard at all... stick with it.

The brackets "[" in your lines of code are not correct... they specify [optional] parameters.

You might want to start a new post for your next round of questions......

SupraNatural Today, 08:46 PM Post #15

*applauds herewasplato*

Nicely put.

The brackets "[" in your lines of code are not correct... they specify [optional] parameters.

I took the code from the top I take it [ should be ( ??? Editing those now. Also I am using the help file a ton but somethings im just like Whoa what did that say :blink:

Edited by Wepwawet
Link to comment
Share on other sites

While 1
$rand = Random(45,55)
MouseClick("left",x,y,1,0)
Sleep($rand)
Wend

<{POST_SNAPBACK}>

OK I understand three lines of that. what does While 1 do and what does Wend do?? I will take the code and see if i can fig it out :whistle:

Ok I tried it and get pretty much the same error I get when I try to run scripts i make

Line 14 (File "C:\Documents and Settings\Troy\Desktop\NONYA\trail.au3):

MouseClick("left",x,y,1,0)

MouseClick("left",^ERROR

Error: Unknown function name

Thanks again

Edited by Wepwawet
Link to comment
Share on other sites

I took the code from the top I take it [ should be ( ??? Editing those now.

<{POST_SNAPBACK}>

Nice job of bringing the info into another post.

Let's look at the help file for MouseClick

At the "top" of that page is:

MouseClick("button" [, x, y [, clicks [, speed ]]] )

You can write the code as:

MouseClick("left")

The rest of the line is optional.

MouseClick("left") will just send one click to the application directly under the mouse - where ever it happens to be at the time that the script runs that line of code.

MouseClick("button", 0, 0) will send one click to the coordinates 0,0

(The upper left corner of the desktop or the upper left corner of the active application window depending on this setting: MouseCoordMode)

MouseClick("left", 0, 0, 2) will send two clicks.......

MouseClick("left", 150, 100, 15, 50) will move to 150,100 pretty slowly because of the 50 optional setting and will send 15 clicks.......

See where Im going with this?

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

Link to comment
Share on other sites

...what does While 1 do and what does Wend do??...

<{POST_SNAPBACK}>

The "While 1" just makes a infinite loop of all of the code between the While and the WEnd lines. Edited by herewasplato

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

Link to comment
Share on other sites

Also I am using the help file a ton but somethings im just like Whoa what did that say

<{POST_SNAPBACK}>

I will not be online much longer but there are plenty of others around the world to help you out. If you cannot sleep some night and want to read a different kind of "help file" look thru the forum for scripts that attempt to explain what each line or section of code does via comment lines... like this really wordy post from me:

http://www.autoitscript.com/forum/index.php?showtopic=14395

later...

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

Link to comment
Share on other sites

herewasplato I see what you are saying thanks for explaining that. I can be a little slow on the pick up.

While 1<<<<< Used for the loop

$delay = Random(55,60,0)<<<<<<Does this need to be in Mill Sec?

MouseClick ("Left")<<<<<<<<<<<Clicks button

Sleep($delay)<<<<<<<<<<<<<<tells it to wait on the set delay?

WEnd<<<<<< Used for the loop

Am I understanding this right? When i run the script its just clicking at a million times a sec. Do i need to put a set time in Sleep(55000) << 55 sec? If so how do I make it click the mouse randomly in 45-55 sec intervols?

Edited by Wepwawet
Link to comment
Share on other sites

$delay = Random(55,60,0)<<<<<<Does this need to be in Mill Sec?

yes, milliseconds --- but you might want a 1 as the last option

...and you can just put the random function inside of the Sleep function:

While 1
    MouseClick("Left")
    Sleep(Random(55000,60000,1))
WEnd

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

Link to comment
Share on other sites

#include <GuiConstants.au3>;Include this when you use Opt("GUIOnEventMode", 1)

Opt("GUIOnEventMode", 1); Opt means option, sets an option for the script. In this case the option is setting the GUI for on event mode so that we may use GUICtrlSetOnEvent functions.
$GUI = GUICreate("WepMouse",400,400);Please read the helpfile for "GUICreate" and "GUIOnEventMode"
$inputCoords = GUICtrlCreateInput("Format X,Y",20,20,100,20)
$getInfo = GUICtrlCreateButton("OK",130,20,60,20,$BS_DEFPUSHBUTTON);look up GUICtrlCreateButton
GuiCtrlSetOnEvent($getinfo,"getCoords")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE");Tells the gui to call our "close" function (below) when the X is pushed
GUISetState(@SW_SHOW);Makes the GUI Visible :)

While 1;This while loop gives the GUI something to do while it waits for input
    Sleep(1000)
WEnd

Func getCoords();This is the function that we get the coords from the input box
    $coords = GUICtrlRead($inputCoords);Read what is in the input area and store it in the $coords variable
    $fcoords =StringSplit($coords,",");Splits the $coord variable (Which should be X,Y) into $fcoords[1]=x and $fcoords[2]=Y
    MouseMove($fcoords[1],$fcoords[2],10);You can replace/add actions here
    MsgBox(0,"Coords",$fcoords[1]&","&$fcoords[2]&" has been clicked")
EndFunc

Func CLOSE();Closes the gui
    Exit
EndFunc

This a simple GUI for your program, all it does is move the mouse to the specified x,y.

Edit: Watch for the word wrap!

Edited by SupraNatural

Visit http://www.blizzedout.com/forums/register....referrerid=8306 for the top blizzard hacks. WoW, TfT, D2/LOD, CS. You name it we got it!

Link to comment
Share on other sites

LoL that's beautiful, well you can use the gui i posted above for a start.

P.S. This is my 100 post, lol

( 9.1 posts per day / 0.10% of total forum posts ) I feel like ive given so much :whistle: ....(I promised myself i wouldn't do this! :dance: )

P.S.2 ^ = comes from sleep deprevation and boredom..evil mix

Edited by SupraNatural

Visit http://www.blizzedout.com/forums/register....referrerid=8306 for the top blizzard hacks. WoW, TfT, D2/LOD, CS. You name it we got it!

Link to comment
Share on other sites

Ok have the GUI size I like <its small> have my value feilds and start button in. Now all i have to do is tie them all together so that it works :whistle: should be fun to toy with most of the night but anyways heres what i have so far. Feel free to suggest changes for style this is plain jane :dance: but think it ill do the job in the end.

; Script Start - Add your code below here

#include <GuiConstants.au3>;Include this when you use

Opt("GUIOnEventMode", 1)

Opt("GUIOnEventMode", 1); Opt means option, sets an option for the script.

In this case the option is setting the GUI for on event mode so that we

may use GUICtrlSetOnEvent functions.

$GUI = GUICreate("WepMouse",285,130);Please read the helpfile for

"GUICreate" and "GUIOnEventMode"

GUICtrlCreateInput("10",20,20,30,20,$ES_NUMBER)

GUICtrlCreateInput ("15",100,20,30,20,$ES_NUMBER)

GUICtrlCreateButton ( "Start", 201,94,75,23,$BS_VCENTER)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE");Tells the gui to call our "close"

function (below) when the X is pushed

GUISetState(@SW_SHOW);Makes the GUI Visible :dance:

While 1;This while loop gives the GUI something to do while it waits for

input

Sleep(1000)

WEnd

Func getCoords();This is the function that we get the coords from the

input box

$coords = GUICtrlRead($inputCoords);Read what is in the input area and

store it in the $coords variable

$fcoords =StringSplit($coords,",");Splits the $coord variable (Which

should be X,Y) into $fcoords[1]=x and $fcoords[2]=Y

MouseMove($fcoords[1],$fcoords[2],10);You can replace/add actions here

MsgBox(0,"Coords",$fcoords[1]&","&$fcoords[2]&" has been clicked")

EndFunc

Func CLOSE();Closes the gui

Exit

EndFunc

Link to comment
Share on other sites

Close, you need to define the input box with a variable ($inputCoords) so that we can use the GUICtrlSetOnEvent($inputCoords,"getcoords") command, which is basically the most important part.

Do this for all the ctrl's you made. (buttons,input's,etc)

EDIT:

Hint::

Func getCoords()
        $x = GUICtrlRead($inputCoords1)
        $y = GUICtrlRead($inputCoords2)
MouseMove($x,$y,10);You can replace/add actions here
MsgBox(0,"Coords",$x&","&$y&" have been clicked")
EndFunc
Edited by SupraNatural

Visit http://www.blizzedout.com/forums/register....referrerid=8306 for the top blizzard hacks. WoW, TfT, D2/LOD, CS. You name it we got it!

Link to comment
Share on other sites

#include <GuiConstants.au3>

Opt("GUIOnEventMode", 1)
$GUI = GUICreate("WepMouse",285,130)
$inputTS1 = GUICtrlCreateInput("10",20,20,30,20,$ES_NUMBER)
$inputTE2 = GUICtrlCreateInput ("15",100,20,30,20,$ES_NUMBER)
$start = GUICtrlCreateButton ( "Start", 201,94,75,23,$BS_VCENTER)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
GUICtrlSetOnEvent($start,"getCoords")
GUISetState(@SW_SHOW)

While 1
Sleep(1000)
WEnd


Func getCoords()
    $TS = GUICtrlRead($inputTS1)
    $TE = GUICtrlRead($inputTE2)
    $sleep = Random($TS*1000,$TE*1000,1)
    Sleep($sleep)
    $pos = MouseGetPos()
    MouseClick("Left")
    MsgBox(0,"Clicked!","Slept for "&$sleep&"Second(s)"&@CRLF& "Then clicked at "&$pos[0]&","&$pos[1])
EndFunc

Func CLOSE()
Exit
EndFunc

Replace WHOLE script with this!

EDIT:

Paste this over the above MSGBOX:

MsgBox(0,"Clicked!","Slept for "&$sleep/1000&"Second(s)"&@CRLF& "Then clicked at "&$pos[0]&","&$pos[1])
Edited by SupraNatural

Visit http://www.blizzedout.com/forums/register....referrerid=8306 for the top blizzard hacks. WoW, TfT, D2/LOD, CS. You name it we got it!

Link to comment
Share on other sites

Ok I see how some of how you set it up. I edited out the msg box

While 1

Func getCoords()

$TS = GUICtrlRead($inputTS1)

$TE = GUICtrlRead($inputTE2)

$sleep = Random($TS*1000,$TE*1000,1)

Sleep($sleep)

$pos = MouseGetPos()

MouseClick("Left")

WEnd

Will cause it to look the clicking at random times till stoped correct? Should I make a stop button or copy XU and make the start also the stop button?

PS Night thanks for the help

Edited by Wepwawet
Link to comment
Share on other sites

I went a different route:

Min and Max are set low to let you test the script quickly

(Quick and dirty - I know that there are better ways to code this.)

AutoItSetOption("MouseCoordMode", 1)


$S_running = "Mouse-It-Desktop";name the script
If WinExists($S_running) Then
    MsgBox(0, "AutoIt", "This script is already running")
    Exit
EndIf
AutoItWinSetTitle($S_running)


$Min = 1000
$Max = 2000
$Min_Adjust = 0
$Max_Adjust = 0
$Offset = 0
$Clear = "No"
$Random_Mouse = "Start_paused"

AdlibEnable("Tool_Tip", 500)
Func Tool_Tip()
    $pos = MouseGetPos()
    $delay = Random($Min + $Min_Adjust + $Offset, $Max + $Max_Adjust + $Offset, 1)
    If $Clear = "No" Then
        ToolTip("X: " & $pos[0] & "  Y: " & $pos[1] & _
                "        Press Esc to Exit." & @CR & _
                "1 Adjust Max via Ctrl-Left/Right arrow  Max=" & (($Max + $Max_Adjust + $Offset) / 1000) & @CR & _
                "...Possible random seconds between clicks=" & (StringFormat("%.0f", $delay / 1000)) & @CR & _
                "2 Adjust Min via Alt-Left/Right arrow  Min=" & (($Min + $Min_Adjust + $Offset) / 1000) & @CR & _
                "3 Alt-Page Up/Dn  Min/Max offset=" & ($Offset / 1000) & @CR & _
                "4 Position mouse where you want the script to click." & @CR & _
                "5 Use Alt-Del to start the clicking." & @CR & _
                "Alt-Page Up adds time between mouse clicks." & @CR & _
                "Alt-Page Dn subtracts time between mouse clicks." & @CR & _
                "Alt-End to shrink this ToolTip." & @CR & _
                "Alt-Home to restore this ToolTip." & @CR & _
                "Alt-Insert for random mouse moves with clicks." & @CR & _
                "Alt-Delete remove random mouse moves." & @CR & _
                "Alt-Pause for random mouse moves without clicks." & @CR & _
                "Press Pause to pause this script.")
    Else
        ToolTip("Esc2exit or Alt-Home")
    EndIf
EndFunc  ;==>Tool_Tip

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    Exit
EndFunc  ;==>Terminate

HotKeySet("!{PGUP}", "Click_Faster")
Func Click_Faster()
    $Offset = $Offset + 1000
EndFunc  ;==>Click_Faster

HotKeySet("!{PGDN}", "Click_Slower")
Func Click_Slower()
    $Offset = $Offset - 1000
    If $Offset < 0 Then $Offset = 0
EndFunc  ;==>Click_Slower

HotKeySet("!{END}", "Clear_Tool_Tip")
Func Clear_Tool_Tip()
    $Clear = "Yes"
EndFunc  ;==>Clear_Tool_Tip

HotKeySet("!{HOME}", "Restore_Tool_Tip")
Func Restore_Tool_Tip()
    $Clear = "No"
EndFunc  ;==>Restore_Tool_Tip

HotKeySet("!{INSERT}", "Random_Mouse_Yes")
Func Random_Mouse_Yes()
    $Random_Mouse = "Yes"
EndFunc  ;==>Random_Mouse_Yes

HotKeySet("!{DEL}", "Random_Mouse_No")
Func Random_Mouse_No()
    $Random_Mouse = "No"
EndFunc  ;==>Random_Mouse_No

HotKeySet("!{PAUSE}", "Random_Mouse_Move_No_Click")
Func Random_Mouse_Move_No_Click()
    $Random_Mouse = "Move_No_Click"
EndFunc  ;==>Random_Mouse_Move_No_Click

HotKeySet("{PAUSE}", "TogglePause")
Global $Paused
Func TogglePause()
    AdlibDisable()
    $Paused = Not $Paused
    While $Paused
        ToolTip("Pause2start again, Esc2exit")
        Sleep(100)
    WEnd
    AdlibEnable("Tool_Tip", 500)
EndFunc  ;==>TogglePause

HotKeySet("!{RIGHT}", "Min_Adjust_Up")
Func Min_Adjust_Up()
    $Min_Adjust = $Min_Adjust + 1000
EndFunc  ;==>Min_Adjust_Up

HotKeySet("!{LEFT}", "Min_Adjust_Down")
Func Min_Adjust_Down()
    $Min_Adjust = $Min_Adjust - 1000
    If $Min_Adjust < 0 Then $Min_Adjust = 0
EndFunc  ;==>Min_Adjust_Down

HotKeySet("^{RIGHT}", "Max_Adjust_Up")
Func Max_Adjust_Up()
    $Max_Adjust = $Max_Adjust + 1000
EndFunc  ;==>Max_Adjust_Up

HotKeySet("^{LEFT}", "Max_Adjust_Down")
Func Max_Adjust_Down()
    $Max_Adjust = $Max_Adjust - 1000
    If $Max_Adjust < 0 Then $Max_Adjust = 0
EndFunc  ;==>Max_Adjust_Down


While 1
    $delay = Random($Min + $Min_Adjust + $Offset, $Max + $Max_Adjust + $Offset, 1)
    If $Random_Mouse = "No" Then
        ToolTip("CLICK")
        MouseClick("Left")
    EndIf
    If $Random_Mouse = "Yes" Then
        ToolTip("CLICK")
        MouseClick("Left", Random(0, @DesktopHeight, 1), Random(0, @DesktopWidth, 1))
    EndIf
    If $Random_Mouse = "Move_No_Click" Then
        MouseMove(Random(0, @DesktopHeight, 1), Random(0, @DesktopWidth, 1))
    EndIf
    Sleep($delay)
WEnd
"Happily driving nails with cars."

Edit 1:

P.S. I do not usually give out such a script to a new AutoIt user...

It is not the best way for them to learn...

...but SupraNatural started it, so there. :-)

...and besides, Wepwawet (Troy is it?) is learning just fine.

Edit2: Fixed ToolTip CLICK when there was no click.

Edit3: Made it more complicated.

Edited by herewasplato

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

Link to comment
Share on other sites

Yes my real name is Troy. :whistle:

All I can say is WOW that is some scripting there WOW!

Will decode it so I understand how things work/ Why lines are where they are Will tackle this one after I get the one super is feeding me fully understood.

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