Jump to content
PlasticJesus

Simple Looping Mouseclick

Recommended Posts

PlasticJesus

Hi all,

I have been trying to get a simple looping mouseclick script to work depending on the quantity you put into a popup box. I would also like the escape key to be a fallback to exit the loop as well as the count. I am getting errors when trying to run the .exe once compiled.

AutoIt Error
Line 4 (File "...\gomouse.exe):
Error: Unknown function name.

Here is the file


$Main = GUICreate("Enter Desired Clicks", 100, 100, 810, 200)
$Input1 = GUICtrlCreateInput("0", 40, 40, 33, 21)
$Go = GUICtrlCreateButton("Go", 40, 64, 33, 17, 0)
GUISetState(SW_SHOWNORMAL)

HotKeySet("F1", "_Mouse1")
HotKeySet("{ESC}", "_Escape")

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit
      Case $Go
         _Mouse1()
   EndSwitch
WEnd

Func _Mouse1()
   Local $Times
   Do
      $Times += 1
      MouseClick("left")
      Sleep(1000)
   Until $Times = GUICtrlRead($Input1) Or $Escape = 1
EndFunc

Func _Escape()
   $Escape = 1
EndFunc

Share this post


Link to post
Share on other sites
water

Welcome to AutoIt and the forum!
Is this script for learning purpose or do you want to solve a real problem? As you do not specify a mouse position it clicks whereever the mouse is at the moment you run your script.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

Your error is caused by the missing @ in @SW_SHOWNORMAL.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
PlasticJesus

Ok, caught a couple mistakes but I still can't seem to get it completed. Once compiled now it does not stop the mouse click loop if it reached the number entered in the GUI box, it also does not exit if I press the window close button however pressing escape closes the window and program. Not sure what I am still missing to finish this script. Any help is appreciated!

#include <GUIConstantsEx.au3>

$Main = GUICreate("Enter Desired Clicks", 100, 100, 810, 200)
$Input1 = GUICtrlCreateInput("0", 40, 40, 33, 21)
$Go = GUICtrlCreateButton("Go", 40, 64, 33, 17, 0)
GUISetState()
Local $Times = 0
Local $Escape = 0
HotKeySet("F1", "_Mouse1")
HotKeySet("{ESC}", "_Escape")

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit
      Case $Go
         _Mouse1()
   EndSwitch
WEnd

Func _Escape()
   $Escape = 1
EndFunc

Func _Mouse1()
   Do
      $Times += 1
      MouseClick("left")
      Sleep(1000)
   Until $Times = GUICtrlRead($Input1) Or $Escape = 1
EndFunc

Share this post


Link to post
Share on other sites
water

Could you please anwer my question in my first post?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jos

It works one time as you do not reset $Escape=0 when you have hit ESC, so the second time it will Escape right away.

This however doesn't close your script but returns to its GUI.

Jos

 

 

 


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
water

BTW: Could you please enclose AutoIt code in code tags (the "<>" icon in the editor)? That greatly enhances readability ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
SadBunny
  • Clicking the close button will not work while the script is in the loop inside _Mouse1(), as you are not polling GUIGetMsg there. The message will get registered as soon as you leave the loop. I don't know if you meant it like that.
  • Like Jos said, reset your $Escape, otherwise all runs after the first will only have exactly 1 loop iteration.
  • Even then, $Times is a global variable and just keeps on counting upwards. So if you reset $Escape, the script will stay in the loop forever after the first run. Meaning: also reset your $Times counter before you enter that loop.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
PlasticJesus

Could you please anwer my question in my first post?

​Hi Water,

The mouse function should be clicking statically on the screen where the user selects it's location.

Share this post


Link to post
Share on other sites
water

I can't imagine where such a script could be useful :huh: Clicking n times with a break of 1 second. Why wouldn't the user click himself?
Is this for a game?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
PlasticJesus

I can't imagine where such a script could be useful :huh: Clicking n times with a break of 1 second. Why wouldn't the user click himself?
Is this for a game?

​Yes, needing to open a specific amount of items prior to running out, if it runs out then you start to purchase.

Share this post


Link to post
Share on other sites
Melba23

PlasticJesus,

Welcome to the AutoIt forum.

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked.

See you soon with a legitimate question I hope.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×