Jump to content

Recommended Posts

Posted

Hi,

After much reading and trying to figure it out myself i cannot.

How can i make this script only left click while holding a hotkey?
Thanks in advance

Click()
;________________________________________________
;________________________________________________
;________________________________________________
Func Click()
While 1
Local $coord = PixelSearch(926,475,987,535,0xff2220,30)
If Not @error Then
MouseClick("Left") 
EndIf
WEnd
EndFunc
;________________________________________________
;________________________________________________
;________________________________________________
While 1
$counter +=1
WEnd
;________________________________________________
;________________________________________________
;________________________________________________
Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
;ToolTip('Script is "Paused"',0,0, $counter, 1)
WEnd
ToolTip("")
EndFunc
;________________________________________________
;________________________________________________
;________________________________________________
Func Terminate()
Exit 0
EndFunc
;________________________________________________
;________________________________________________
;________________________________________________

Posted
1 hour ago, Somerset said:

HotKeySet

Iif this is about a bot, you will find this thread locked.

I thought hotkeyset was if i wasn't holding the key down? I think its 

  If _IsPressed

But i don't know how to properly implement it into this script, do you think you can help? Not for a bot btw

Posted

I tried and the hotkey still isn't working

HotKeySet("{Z}", "Start")
HotKeySet("{ESC}", "_Exit")
Click()
;________________________________________________
;________________________________________________
;________________________________________________
Func Click()
While 1
Local $coord = PixelSearch(926,475,987,535,0xff2220,30)
If Not @error Then
MouseClick("Left") 
EndIf
WEnd
EndFunc
;________________________________________________
;________________________________________________
;________________________________________________
While 1
$counter +=1
WEnd
;________________________________________________
;________________________________________________
;________________________________________________
Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
;ToolTip('Script is "Paused"',0,0, $counter, 1)
WEnd
ToolTip("")
EndFunc
;________________________________________________
;________________________________________________
;________________________________________________
Func Terminate()
Exit 0
EndFunc
;________________________________________________
;________________________________________________
;________________________________________________

Posted

Welcome to AutoIt and the forum!

First of all:
Which program do you try to automate? Somerset is quite right about game automation.
Make sure you read and understood the forum rules!

Second:
Where are functions Start and _Exit in your script?

Third:
Please use the AutoIt code tags in the editor (button "<>") when posting code. makes it much more readable ;)

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

 

Posted

I was searching for pixelsearch and this script was the first one that popped up.

I'm sorry I'm very ignorant when it comes to these things

Posted

How often do you want to click when the wanted color is found?
Doing it in a loop without a Sleep statement doesn't make much sense.

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

 

Posted
1 hour ago, water said:

How often do you want to click when the wanted color is found?
Doing it in a loop without a Sleep statement doesn't make much sense.

Every couple seconds is fine, yea i understand i don't want it spamming my program

Posted

Something like this. It waits 5 seconds before clicking again.

Global $Paused = False

HotKeySet("{Z}", "TogglePause")
HotKeySet("{ESC}", "_Exit")

While 1
    If Not $Paused Then
        ToolTip("Pixelsearch is running", 0, 0, "", 1)
        PixelSearch(926, 475, 987, 535, 0xff2220, 30)
        If Not @error Then
            MouseClick("Left")
            Sleep(5000)
        EndIf
    Else
        ToolTip("Script is Paused", 0, 0, "", 1)
    EndIf
    Sleep(100)
WEnd

Func TogglePause()
    $Paused = Not $Paused
EndFunc   ;==>TogglePause

Func _Exit()
    Exit 0
EndFunc   ;==>_Exit

 

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

 

Posted
5 hours ago, water said:

Something like this. It waits 5 seconds before clicking again.

Global $Paused = False

HotKeySet("{Z}", "TogglePause")
HotKeySet("{ESC}", "_Exit")

While 1
    If Not $Paused Then
        ToolTip("Pixelsearch is running", 0, 0, "", 1)
        PixelSearch(926, 475, 987, 535, 0xff2220, 30)
        If Not @error Then
            MouseClick("Left")
            Sleep(5000)
        EndIf
    Else
        ToolTip("Script is Paused", 0, 0, "", 1)
    EndIf
    Sleep(100)
WEnd

Func TogglePause()
    $Paused = Not $Paused
EndFunc   ;==>TogglePause

Func _Exit()
    Exit 0
EndFunc   ;==>_Exit

 

Thank you so much, 

Posted

:)

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

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...