PlasticJesus Posted May 16, 2015 Posted May 16, 2015 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 ErrorLine 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() EndSwitchWEndFunc _Mouse1() Local $Times Do $Times += 1 MouseClick("left") Sleep(1000) Until $Times = GUICtrlRead($Input1) Or $Escape = 1EndFuncFunc _Escape() $Escape = 1EndFunc
water Posted May 16, 2015 Posted May 16, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted May 16, 2015 Posted May 16, 2015 Your error is caused by the missing @ in @SW_SHOWNORMAL. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
PlasticJesus Posted May 16, 2015 Author Posted May 16, 2015 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 = 0Local $Escape = 0HotKeySet("F1", "_Mouse1")HotKeySet("{ESC}", "_Escape")While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Go _Mouse1() EndSwitchWEndFunc _Escape() $Escape = 1EndFuncFunc _Mouse1() Do $Times += 1 MouseClick("left") Sleep(1000) Until $Times = GUICtrlRead($Input1) Or $Escape = 1EndFunc
water Posted May 16, 2015 Posted May 16, 2015 Could you please anwer my question in my first post? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Developers Jos Posted May 16, 2015 Developers Posted May 16, 2015 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 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
water Posted May 16, 2015 Posted May 16, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
SadBunny Posted May 16, 2015 Posted May 16, 2015 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.
PlasticJesus Posted May 16, 2015 Author Posted May 16, 2015 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.
water Posted May 16, 2015 Posted May 16, 2015 I can't imagine where such a script could be useful 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
PlasticJesus Posted May 16, 2015 Author Posted May 16, 2015 I can't imagine where such a script could be useful 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.
Moderators Melba23 Posted May 16, 2015 Moderators Posted May 16, 2015 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts