Results 1 to 3 of 3

Thread: AutoClicker

  1. #1
    Senior Member Paranaix's Avatar
    Join Date
    Dec 2009
    Posts
    221

    AutoClicker

    I know, its not the first and its not going to be the last, but i wrote this since there wasnt anything fitting my particular needs. I just sharing the code with you guys cuz i think the lazy ones of you will be happy about it when they need a quick more advanced automation. There are plenty of features one could implement; to list some: Parameter checks, saves, controlled clicks... But i dont need them atm so i leave it up to you whether you want to develope the code further.

    Code:
    #cs ----------------------------------------------------------------------------
    
     AutoIt Version: 3.3.6.1
     Author:     Paranaix
    
     Script Function:
    	Autoclicker for advanced tasks
    
    #ce ----------------------------------------------------------------------------
    
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    
    #include <Array.au3>
    #include <ListviewConstants.au3>
    
    
    $bRunning = false
    Dim $entrys[1] = [0]
    
    Opt(&quot;GUIOnEventMode&quot;,true)
    
    $gui = GUICreate(&quot;ACRT - by Paranaix&quot;,300,500)
    $table = GUICtrlCreateListView(&quot;X   |Y   |Doubleclick?   |Delay     |&quot;,0,0,300,400,BitXOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOSORTHEADER))
    $create = GUICtrlCreateButton(&quot;Create&quot;,3,403,75)
    $delete = GUICtrlCreateButton(&quot;Delete&quot;,80,403,75)
    $activator = GUICtrlCreateButton(&quot;Start&quot;,3,433,152,64)
    $activatorDummy = GUICtrlCreateDummy()
    GUICtrlSetTip($activator,&quot;Hotkey: ALT+A&quot;)
    
    GUICtrlCreateLabel(&quot;Repeat X times: (0 = endless)&quot;,157,456,138)
    $times = GUICtrlCreateInput(&quot;0&quot;,157,476,138,20)
    
    GUICtrlSetState($delete,$GUI_DISABLE)
    
    GUISetOnEvent($GUI_EVENT_CLOSE,&quot;guiEventClosed&quot;)
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,&quot;event&quot;)
    GUICtrlSetOnEvent($table,&quot;event&quot;)
    GUICtrlSetOnEvent($create,&quot;event&quot;)
    GUICtrlSetOnEvent($delete,&quot;event&quot;)
    GUICtrlSetOnEvent($activator,&quot;event&quot;)
    GUICtrlSetOnEvent($activatorDummy,&quot;event&quot;)
    GUICtrlSetOnEvent($gui,&quot;event&quot;)
    
    HotKeySet(&quot;!a&quot;,&quot;activatorHotkey&quot;)
    
    GUISetState(true)
    
    Local $step = 1
    Local $it = 0
    
    While 1
    	if($bRunning) Then
    		Local $t = GUICtrlRead($times)
    		if($t <> 0 And $it >= $t) Then 
    			GUICtrlSendToDummy($activatorDummy)
    			ContinueLoop
    		EndIf
    		if($step > UBound($entrys)-1) Then
    			$it += 1
    			$step = 1
    			ContinueLoop
    		EndIf
    		
    		$data = StringSplit(GUICtrlRead($entrys[$step]),&quot;|&quot;,2)
    		if($data[2] == 1) Then
    			MouseClick(&quot;primary&quot;,$data[0],$data[1],2)
    		Else
    			MouseClick(&quot;primary&quot;,$data[0],$data[1])
    		EndIf
    			
    		breakableSleep($data[3],$bRunning)
    		$step += 1
    	Else
    		$step = 1
    		$it = 0
    	EndIf
    	Sleep(1)
    WEnd
    
    Func breakableSleep($time,ByRef $condition)
    	Local $counter
    	Do
    		Sleep(10)
    		$counter += 10
    	Until $counter >= $time Or $condition <> True
    EndFunc
    
    Func guiEventClosed()
    	Exit
    EndFunc
    
    Func event()
    	ConsoleWrite(&quot;test&quot; &amp; @CRLF)
    	Switch @GUI_CTRLID
    	Case $activator
    		if($bRunning) Then
    			GUICtrlSetData($activator,&quot;Start&quot;)
    			$bRunning = False
    		ElseIf(UBound($entrys) > 1) Then
    			GUICtrlSetData($activator,&quot;Stop&quot;)
    			$bRunning = True
    		Else
    			GUICtrlSetState($create,$GUI_FOCUS)
    		EndIf
    	Case $activatorDummy
    		if($bRunning) Then
    			GUICtrlSetData($activator,&quot;Start&quot;)
    			$bRunning = False
    		ElseIf(UBound($entrys) > 1) Then
    			GUICtrlSetData($activator,&quot;Stop&quot;)
    			$bRunning = True
    		Else
    			GUICtrlSetState($create,$GUI_FOCUS)
    		EndIf
    	Case $delete
    		Local $line = 0
    		for $i = 1 to UBound($entrys)-1 Step 1
    			if($entrys[$i] == GUICtrlRead($table)) Then
    				$line = $i
    				ExitLoop
    			EndIf
    		Next
    		GUICtrlDelete($entrys[$line])
    		_ArrayDelete($entrys,$line)
    	Case $create
    		Local $x = InputBox(&quot;Parameter&quot;,&quot;The X coordinate&quot;,&quot;0&quot;)
    		Local $y = InputBox(&quot;Parameter&quot;,&quot;The Y coordinate&quot;,&quot;0&quot;)
    		Local $double = InputBox(&quot;Parameter&quot;,&quot;Doubleclick? (1=true,0=false)&quot;,&quot;0&quot;)
    		Local $delay = InputBox(&quot;Parameter&quot;,&quot;How long do you want to wait? (1000 = 1 second)&quot;,&quot;1000&quot;)
    		Local $handle = GUICtrlCreateListViewItem($x &amp; &quot;|&quot; &amp; $y &amp; &quot;|&quot; &amp; $double &amp; &quot;|&quot; &amp; $delay &amp; &quot;|&quot;,$table)
    		_ArrayAdd($entrys,$handle)
    		GUICtrlSetOnEvent($handle,&quot;event&quot;)
    	EndSwitch
    	
    	if($bRunning) Then
    		GUICtrlSetState($create,$GUI_DISABLE)
    		GUICtrlSetState($delete,$GUI_DISABLE)
    		GUICtrlSetState($table,$GUI_DISABLE)
    		GUICtrlSetState($times,$GUI_DISABLE)
    	Else
    		GUICtrlSetState($create,$GUI_ENABLE)
    		GUICtrlSetState($delete,$GUI_ENABLE)
    		GUICtrlSetState($table,$GUI_ENABLE)
    		GUICtrlSetState($times,$GUI_ENABLE)
    	EndIf 
    	
    	if(GUICtrlRead($table) = 0) Then GUICtrlSetState($delete,$GUI_DISABLE)
    EndFunc
    
    Func activatorHotkey()
    	GUICtrlSendToDummy($activatorDummy)
    EndFunc

  2. #2
    Senior Member
    Join Date
    Sep 2011
    Posts
    230

    Re: AutoClicker

    Thank you

  3. #3
    Senior Member gotmilk's Avatar
    Join Date
    Apr 2010
    Posts
    455

    Re: AutoClicker

    Just a heads up, you can attach files to posts for people to download. It's arguably no simpler than c/p coding into a blank AutoIt script for something on this scale, but it's what people usually do around here ^___^
    Moo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •