AutoHotkey Community

It is currently May 27th, 2012, 1:13 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Auto-MouseClick
PostPosted: April 19th, 2005, 3:15 pm 
My right index finger sometimes gets very sore from clicking. I searched for a utility that would click the mouse for me every 'x' seconds but all I found was ShareWare. Then I figured writing an AHK program for this shouldn't be too difficult. When clicks aren't needed, the mouse pointer can be parked on a title bar.

Warning to expert AHK-ers: Extremely simplistic script ahead.

Code:
#Persistent
InputBox, Int, Mouse Click Interval, Enter the number of seconds between mouse clicks:, ,,,,,,, 5
If ErrorLevel <> 0
  ExitApp
If Int =
  ExitApp
EnvMult, Int, 1000
SetTimer, ClickIt, %Int%
Return
ClickIt:
MouseClick
Return


Report this post
Top
  
Reply with quote  
 Post subject: Another solutoion
PostPosted: April 20th, 2005, 12:35 am 
Offline

Joined: July 30th, 2004, 8:50 pm
Posts: 192
Here's another solution to the problem. It clicks the mouse when it stops moving for a user defined time.

Skrommel

Code:
;AutoClick
;
;Clicks the left mousebutton automatically
;when the mouse is in the same place for 10*100ms
 
pause=10
x2=0
y2=0
counter=0

START:
  Sleep,100
  counter+=1
  If counter=%pause%
    MouseClick,left
  MouseGetPos,x1,y1
  If x1=%x2%
    If y1=%y2%
      Goto,START
  counter=0
  x2=%x1%
  y2=%y1%
Goto,START


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2005, 1:07 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Here's a script I made for myself a while back called SuperClick, it just makes multiple clicks as long as I hold down a key/mouse-button:
Code:
#Persistent
#InstallMouseHook
SetKeyDelay -1

Delay = 100
hkeyClick = F8
hkeySend = LButton

Hotkey, %hkeyClick%, SuperClick, B0
Return
SuperClick:
GetKeyState, KeyState, %hkeyClick%
If KeyState = D
   Loop
   {
      Send, {%hkeySend%}
      Sleep, %Delay%
      GetKeyState, KeyState, %hkeyClick%
      If KeyState <> D
         Break
   }
Return

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Another solutoion
PostPosted: April 22nd, 2005, 1:18 am 
Offline

Joined: April 20th, 2005, 8:44 am
Posts: 25
skrommel wrote:
Here's another solution to the problem. It clicks the mouse when it stops moving for a user defined time.


Really cool. I plan on using this in some scripts. Here's a simple example using a g-label. How could this be made into a function, and then how could that function be called from the checkbox?
BTW, this is broken, because unchecking does not turn it off.

Code:
; AutoClickTest
Gui, Add, Checkbox, x40 y40 gAutoClickit, Auto-Click
Gui, Add, Checkbox, x40 y80, Test Checkbox
Gui, Add, Button, x150 y90 w40 h30 Default, &Quit
Gui, Show, h200 w300, AutoClickTest
Return


AutoClickit:
  {
   pause=10
   x2=0
   y2=0
   counter=0
START:
   Sleep,100
   counter+=1
   If counter=%pause%
   MouseClick,left
   MouseGetPos,x1,y1
   If x1=%x2%
   If y1=%y2%
   Goto,START
   counter=0
   x2=%x1%
   y2=%y1%
   Goto,START
  }


ButtonQuit:
Gui, Destroy

GuiClose:
GuiEscape:
ExitApp


Also, would it be possible to have the autoclick routine to work only within the confines of ahk script (or even a predefined area of an ahk script)?

_________________
Berserker


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Another solutoion
PostPosted: April 23rd, 2005, 1:50 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
olaf wrote:
How could this be made into a function, and then how could that function be called from the checkbox?
Probably the best way is to have the clicking loop periodically check the state of the checkbox. If's it's off, the loop should stop itself.

Quote:
Also, would it be possible to have the autoclick routine to work only within the confines of ahk script (or even a predefined area of an ahk script)?
You could use IfWinActive to check which window is active. If a non-script window becomes active, the clicking loop could stop itself.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 30th, 2005, 6:06 am 
based on Olaf script
is it possible to put in a set of mouse click *A
and a set of time *B to run *A ?
i have not seen any script like this in forum


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 30th, 2005, 6:46 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
Anonymous wrote:
based on Olaf script
is it possible to put in a set of mouse click *A
and a set of time *B to run *A ?
i have not seen any script like this in forum
Something like this?
Code:
; AutoClickTest
Gui, Add, Checkbox, x40 y40 vChkState gAutoClickit, Auto-Click
Gui, Add, Edit, w250 x20 y80, Test Data
Gui, Add, Button, x40 y120 w40 h30 Default, &Quit
Gui, Add, Button, x180 y120 w40 h30 gTestButton, &Test
Gui, Show, h200 w300, AutoClickTest

TimeBetweenSetsOfClicks = 4000   ; in milliseconds
NumberOfClicks = 4
MouseMovementTimeout = 2000    ; how long after mouse stops moving to start (in milliseconds)
Return

AutoClickit:
GuiControlGet, ChkState
if ChkState = 1
{
  LastNoMove := A_TickCount
  clickon = False
  SetTimer, ChkMouse, 250
}
else
{
  SetTimer, ChkMouse, Off
  SetTimer, Clickit, Off
}
Return

ChkMouse:
MouseGetPos,x1,y1
x3 := x1 - x2
y3 := y1 - y2
if (x3 = 0 and y3 = 0)
{
  NoMove := A_TickCount - LastNoMove
  if NoMove >= %MouseMovementTimeout%
  {
    if clickon = False
    {
      clickon = True
      Gosub, Clickit
      SetTimer, Clickit, %TimeBetweenSetsOfClicks%
    }
    LastNoMove := A_TickCount
  }
}
else
{
  SetTimer, Clickit, Off 
  clickon = False
  LastNoMove := A_TickCount
}
Sleep, 100
GuiControl,, Edit1, x1:%x1%  x2:%x2%  y1:%y1%  y2:%y2%  Click: %clickon%
x2 = %x1%
y2 = %y1%
Return

Clickit:
MouseClick, Left,,, %NumberOfClicks%
Return

TestButton:
SoundBeep
Return

ButtonQuit:
GuiClose:
ExitApp


Edit: bug squashing ;)


Last edited by corrupt on April 30th, 2005, 10:16 am, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 30th, 2005, 9:05 am 
ty corrupt~
erm..

TimeBetweenSetsOfClicks = 4000 ; in milliseconds -->timeout per click?
NumberOfClicks = 4 --> i set the amount of click per set?
MouseMovementTimeout = 10000 ;---> time out per set?

i have tried to edit them a little bit *sorry my programming is poor :cry:
and have little success
i'm trying to get like 4 right click per set
and 100 sceond timeout perset


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 30th, 2005, 10:05 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
Anonymous wrote:
ty corrupt~
erm..

NP :).

TimeBetweenSetsOfClicks = 100000 ; in milliseconds -->time between sets of clicks if mouse has not moved

NumberOfClicks = 4 --> amount of clicks per set

MouseMovementTimeout = 2000 ---> The amount of time that the mouse must stay in the same place before clicking will start

Anonymous wrote:
i'm trying to get like 4 right click per set
and 100 sceond timeout perset
The only issue I can see with using this script to right click would be if after right clicking the mouse needs to be moved to select an item (since moving the mouse would reset the timer). If not this should work ok:
Code:
; AutoClickTest
Gui, Add, Checkbox, x40 y40 vChkState gAutoClickit, Auto-Click
Gui, Add, Edit, w250 x20 y80, Test Data
Gui, Add, Button, x40 y120 w40 h30 Default, &Quit
Gui, Add, Button, x180 y120 w40 h30 gTestButton, &Test
Gui, Show, h200 w300, AutoClickTest

TimeBetweenSetsOfClicks = 100000   ; in milliseconds
NumberOfClicks = 4
MouseMovementTimeout = 2000    ; how long after mouse stops moving to start (in milliseconds)
Return

AutoClickit:
GuiControlGet, ChkState
if ChkState = 1
{
  LastNoMove := A_TickCount
  clickon = False
  SetTimer, ChkMouse, 250
}
else
{
  SetTimer, ChkMouse, Off
  SetTimer, Clickit, Off
}
Return

ChkMouse:
MouseGetPos,x1,y1
x3 := x1 - x2
y3 := y1 - y2
if (x3 = 0 and y3 = 0)
{
  NoMove := A_TickCount - LastNoMove
  if NoMove >= %MouseMovementTimeout%
  {
    if clickon = False
    {
      clickon = True
      Gosub, Clickit
      SetTimer, Clickit, %TimeBetweenSetsOfClicks%
    }
    LastNoMove := A_TickCount
  }
}
else
{
  SetTimer, Clickit, Off 
  clickon = False
  LastNoMove := A_TickCount
}
Sleep, 100
GuiControl,, Edit1, x1:%x1%  x2:%x2%  y1:%y1%  y2:%y2%  Click: %clickon%
x2 = %x1%
y2 = %y1%
Return

Clickit:
MouseClick, Right,,, %NumberOfClicks%
Return

TestButton:
SoundBeep
Return

ButtonQuit:
GuiClose:
ExitApp


You could also change the action performed by changing the Clickit: subroutine. For example, you could put a delay between clicks with this change:
Code:
Clickit:
Loop, %NumberOfClicks%
{
MouseClick, Right
Sleep, 1000
}
SetTimer, Clickit, %TimeBetweenSetsOfClicks%
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 30th, 2005, 10:39 am 
i can't thanks u enough~ ty! ty! :oops:
ur edited clickit actually solves the delays :lol:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 10th, 2005, 4:53 am 
Offline

Joined: May 4th, 2005, 7:07 pm
Posts: 16
Could u help me :?: :roll:

Am also working with checkbox but having some trouble & think i will need 2 create a mouse function 2 get it fully operational:

Code:

#c::

NoTSPassFound = Team Speak
EnterTSPass = Please enter Password.

ifnotexist SETTINGS.INI

iniread, RemTSPass, SETTINGS.INI,Remember,TSPass,0
iniread, TSPass, SETTINGS.INI, DATA, TSPass, 00
iniread, RemTSPassState, SETTINGS.INI, Remember, TSPassState, 1
iniread, TSPassState, SETTINGS.INI, DATA, TSPassState, 1

ifequal, TSPass, 00
   TSPass =

start:

Gui, Add, Checkbox, x185 y82 w20 h20 vTSPassState Checked%TSPassState%
Gui, Add, Text, x45 y10 w145 h20, %EnterTSPass%
ifequal, TSPassState, 1
Gui, Add, Edit, x20 y35 w160 h20 vTSPass Password, %TSPass%
ifnotequal, TSPassState, 1
Gui, Add, Edit, x20 y40 w160 h20 vTSPass, %TSPass%
Gui, Add, Button, x35 y70 w50 h20, OK
Gui, Add, Button, x120 y70 w50 h20, Cancel
ifequal, DialogCaption, 0
gui, -caption
Gui, Show, h100 w200, %NoTSPassFound%
Return

GuiClose:
ButtonCancel:
gui, submit
gui, destroy
return

ButtonOK:
Gui, submit
gui, destroy
ifequal, RemTSPassState, 1
iniwrite, %TSPassState%, SETTINGS.INI, DATA, TSPassState
 
             Run,teamspeak://69.93.130.100/nickname=Nick?password=pass?channel=chan?channelpassword="%TSPass%"
return



So far the code seems 2 work but when i click on checkbox it doesn't toggle show/hide password while in gui.Only when i press on "OK" it saves settings 2 ether show or hide password then will only change settings when I open gui again. :(


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group