Jump to content
dtmajors

Active only while holding key?

Recommended Posts

dtmajors

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
;________________________________________________
;________________________________________________
;________________________________________________

Share this post


Link to post
Share on other sites
Somerset

HotKeySet

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


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites
dtmajors
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

Share this post


Link to post
Share on other sites
dtmajors

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
;________________________________________________
;________________________________________________
;________________________________________________

Share this post


Link to post
Share on other sites
water

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 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
dtmajors

It's work related on a stock market app i use
I have deuteranopia a very rare form of color blindness. 

Share this post


Link to post
Share on other sites
dtmajors

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

Share this post


Link to post
Share on other sites
water

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 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
dtmajors
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

Share this post


Link to post
Share on other sites
water

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 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
dtmajors
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, 

Share this post


Link to post
Share on other sites
water

:)


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

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

×