Jump to content

Help with my hotkeys :(


Recommended Posts

Hello,

I know theres alot autoclicker around here, but I tried to make my own. This autoclicker works fully and it can be turned on by pressing the hotkey. The problem is after pressing pause it still runs, the only way to stop this autoclick is to close my autoclicker :unsure:

Can anyone help me out with this autoclick by fixing the pause hotkey :>

;In this little example pressing n will pop up a message
;pressing Esc will leave.
While 1
   If _IsPressed('1b') = 1 Then ToolTip("Pause",0,0) ;The hotkey of this function is ESC
       sleep(30)
   If _IsPressed('4e') = 1 Then ToolTip("Clicking",0,0) ;The hotkey of this function is N
        MouseClick("left")
        Sleep(30)
       
   Sleep(10)
Wend

Exit
Func _IsPressed($hexKey)
  ; $hexKey must be the value of one of the keys.
  ; _IsPressed will return 0 if the key is not pressed, 1 if it is.
  ; $hexKey should entered as a string, don't forget the quotes!n
  ; (yeah, layer. This is for you)
   
   Local $aR, $bO
   
   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
      $bO = 1
   Else
      $bO = 0
   EndIf
   
   Return $bO
EndFunc  ;==>_IsPressed

#cs
   01 Left mouse button
   02 Right mouse button
   04 Middle mouse button (three-button mouse)
   05 Windows 2000/XP: X1 mouse button
   06 Windows 2000/XP: X2 mouse button
   08 BACKSPACE key
   09 TAB key
   0C CLEAR key
   0D ENTER key
   10 SHIFT key
   11 CTRL key
   12 ALT key
   13 PAUSE key
   14 CAPS LOCK key
   1B ESC key
   20 SPACEBAR
   21 PAGE UP key
   22 PAGE DOWN key
   23 END key
   24 HOME key
   25 LEFT ARROW key
   26 UP ARROW key
   27 RIGHT ARROW key
   28 DOWN ARROW key
   29 SELECT key
   2A PRINT key
   2B EXECUTE key
   2C PRINT SCREEN key
   2D INS key
   2E DEL key
   30 0 key
   31 1 key
   32 2 key
   33 3 key
   34 4 key
   35 5 key
   36 6 key
   37 7 key
   38 8 key
   39 9 key
   41 A key
   42 B key
   43 C key
   44 D key
   45 E key
   46 F key
   47 G key
   48 H key
   49 I key
   4A J key
   4B K key
   4C L key
   4D M key
   4E N key
   4F O key
   50 P key
   51 Q key
   52 R key
   53 S key
   54 T key
   55 U key
   56 V key
   57 W key
   58 X key
   59 Y key
   5A Z key
   5B Left Windows key
   5C Right Windows key
   60 Numeric keypad 0 key
   61 Numeric keypad 1 key
   62 Numeric keypad 2 key
   63 Numeric keypad 3 key
   64 Numeric keypad 4 key
   65 Numeric keypad 5 key
   66 Numeric keypad 6 key
   67 Numeric keypad 7 key
   68 Numeric keypad 8 key
   69 Numeric keypad 9 key
   6A Multiply key
   6B Add key
   6C Separator key
   6D Subtract key
   6E Decimal key
   6F Divide key
   70 F1 key
   71 F2 key
   72 F3 key
   73 F4 key
   74 F5 key
   75 F6 key
   76 F7 key
   77 F8 key
   78 F9 key
   79 F10 key
   7A F11 key
   7B F12 key
   7C-7F F13 key - F16 key
   80H-87H F17 key - F24 key
   90 NUM LOCK key
   91 SCROLL LOCK key
   A0 Left SHIFT key
   A1 Right SHIFT key
   A2 Left CONTROL key
   A3 Right CONTROL key
   A4 Left MENU key
   A5 Right MENU key
#ce
Link to comment
Share on other sites

Try

HotKeySet ( "{PAUSE}", "_Exit" )

;In this little example pressing n will pop up a message
;pressing Esc will leave.
While 1
   If _IsPressed('1b') = 1 Then ToolTip("Pause",0,0) ;The hotkey of this function is ESC
       sleep(30)
   If _IsPressed('4e') = 1 Then ToolTip("Clicking",0,0) ;The hotkey of this function is N
        MouseClick("left")
        Sleep(30)
       
   Sleep(10)
Wend

Exit

Func _Exit ( )
    Exit
EndFunc 

Func _IsPressed($hexKey)
  ; $hexKey must be the value of one of the keys.
  ; _IsPressed will return 0 if the key is not pressed, 1 if it is.
  ; $hexKey should entered as a string, don't forget the quotes!n
  ; (yeah, layer. This is for you)
   
   Local $aR, $bO
   
   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
      $bO = 1
   Else
      $bO = 0
   EndIf
   
   Return $bO
EndFunc  ;==>_IsPressed

Press "pause" and script will exit

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

It works but is it possible to not make the autoit exit since I want it to be turn it on/off able :unsure:

like this ?

Global $_Pause = True

HotKeySet ( "{PAUSE}", "_Pause" )
;In this little example pressing n will pop up a message
;pressing Esc will leave.
While 1
    If $_Pause = True Then
        If _IsPressed('1b') = 1 Then ToolTip("Pause",0,0) ;The hotkey of this function is ESC
            sleep(30)
        If _IsPressed('4e') = 1 Then
            ToolTip("Clicking",0,0) ;The hotkey of this function is N
            MouseClick("left")
            ConsoleWrite ( 'MouseClick("left")' & @Crlf )
        EndIf
        Sleep(30)
    EndIf
    Sleep(10)
Wend

Exit

Func _Pause ( )
    $_Pause = Not $_Pause
    ConsoleWrite ( "$_Pause : " & $_Pause & @Crlf )
EndFunc

Func _IsPressed($hexKey)
  ; $hexKey must be the value of one of the keys.
  ; _IsPressed will return 0 if the key is not pressed, 1 if it is.
  ; $hexKey should entered as a string, don't forget the quotes!n
  ; (yeah, layer. This is for you)

   Local $aR, $bO

   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
      $bO = 1
   Else
      $bO = 0
   EndIf

   Return $bO
EndFunc  ;==>_IsPressed

Now the "Pause" enable or disable the autoclick.

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I tried the hotkeyset method, it works but when I am in full screen it doesn't work thats why I am using a different method @

try this

Global $_Pause = True

;In this little example pressing n will pop up a message
;pressing Esc will leave.
While 1
    If _IsPressed('1b') = 1 Then Exit ; esc
    If _IsPressed('13') = 1 Then ; pause
        ToolTip("Pause",0,0) ;The hotkey of this function is Pause
        $_Pause = Not $_Pause
    EndIf
    If $_Pause = True Then
        If _IsPressed('4e') = 1 Then
            ToolTip("Clicking",0,0) ;The hotkey of this function is N
            MouseClick("left")
            ConsoleWrite ( 'MouseClick("left")' & @Crlf )
        EndIf
        Sleep(30)
    EndIf
    Sleep(10)
Wend

Exit

Func _IsPressed($hexKey)
  ; $hexKey must be the value of one of the keys.
  ; _IsPressed will return 0 if the key is not pressed, 1 if it is.
  ; $hexKey should entered as a string, don't forget the quotes!n
  ; (yeah, layer. This is for you)

   Local $aR, $bO

   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
      $bO = 1
   Else
      $bO = 0
   EndIf

   Return $bO
EndFunc  ;==>_IsPressed
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Thanks for helping me but now it only click once when I press 'N', This means I have to hold enter, can you help me to make a toggle button for the clicks, thank you ILY :unsure:

Global $_Pause = False

;In this little example pressing n will pop up a message
;pressing Esc will leave.
While 1
    If _IsPressed('1b') = 1 Then Exit ; esc
    If _IsPressed('4e') = 1 Then ; pause
        ToolTip("Pause",0,0) ;The hotkey of this function is Pause
        $_Pause = Not $_Pause
    EndIf
    If $_Pause = True Then
        ;If _IsPressed('4e') = 1 Then
            ToolTip("Clicking",0,0) ;The hotkey of this function is N
            MouseClick("left")
            ConsoleWrite ( 'MouseClick("left")' & @Crlf )
        ;EndIf
        Sleep(30)
    EndIf
    Sleep(10)
Wend

Exit

Func _IsPressed($hexKey)
  ; $hexKey must be the value of one of the keys.
  ; _IsPressed will return 0 if the key is not pressed, 1 if it is.
  ; $hexKey should entered as a string, don't forget the quotes!n
  ; (yeah, layer. This is for you)

   Local $aR, $bO

   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
      $bO = 1
   Else
      $bO = 0
   EndIf

   Return $bO
EndFunc  ;==>_IsPressed

So :

press n and click are starting

press n and click are stopping

esc for exit

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

it just ignores the stop button and it keeps clicking i had to exit it :unsure:

Global $_Pause = False

;In this little example pressing n will pop up a message
;pressing Esc will leave.
While 1
    If _IsPressed('1b') = 1 Then Exit ; esc
    If _IsPressed('4e') = 1 Then ; pause
        ToolTip("Pause",0,0) ;The hotkey of this function is Pause
        $_Pause = Not $_Pause
        ConsoleWrite ( '$_Pause : ' & $_Pause & @Crlf )
        Sleep ( 250 )
    EndIf
    If $_Pause = True Then
        ;If _IsPressed('4e') = 1 Then
            ToolTip("Clicking",0,0) ;The hotkey of this function is N
            MouseClick("left")
            ;ConsoleWrite ( 'MouseClick("left")' & @Crlf )
        ;EndIf
        Sleep(30)
    EndIf
    Sleep(30)
Wend

Exit

Func _IsPressed($hexKey)
  ; $hexKey must be the value of one of the keys.
  ; _IsPressed will return 0 if the key is not pressed, 1 if it is.
  ; $hexKey should entered as a string, don't forget the quotes!n
  ; (yeah, layer. This is for you)

   Local $aR, $bO

   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
      $bO = 1
   Else
      $bO = 0
   EndIf

   Return $bO
EndFunc  ;==>_IsPressed

It's the good one ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

The answer to your PM

Global $_Pause = False

;In this little example pressing n will pop up a message
;pressing Esc will leave.
While 1
    If _IsPressed('1b') = 1 Then Exit ; esc
    If _IsPressed('4e') = 1 Then ; pause
        ToolTip("Pause",0,0) ;The hotkey of this function is Pause
        $_Pause = Not $_Pause
        ConsoleWrite ( '$_Pause : ' & $_Pause & @Crlf )
        Sleep ( 250 )
    EndIf
    If $_Pause = True Then
        ToolTip("Clicking",0,0)
        $color = PixelGetColor(@DesktopWidth / 2, @DesktopHeight / 2) ; center
        ConsoleWrite ( "$color : " & $color & @Crlf )
        If $color = 16711680 Or $color = 16646144 Then ;clicks when center turns red
            MouseClick("left")
        EndIf
    EndIf
    Sleep(30)
Wend

Exit

Func _IsPressed($hexKey)
  ; $hexKey must be the value of one of the keys.
  ; _IsPressed will return 0 if the key is not pressed, 1 if it is.
  ; $hexKey should entered as a string, don't forget the quotes!n
  ; (yeah, layer. This is for you)

   Local $aR, $bO

   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
      $bO = 1
   Else
      $bO = 0
   EndIf

   Return $bO
EndFunc  ;==>_IsPressed

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Heh thank you very much, I appreciate it alot!!

You are the best ^^

I will not hesitate to ask!! Can you add a different hotkey for the start/pause. thanks haha :unsure:

Edited by Kayozu
Link to comment
Share on other sites

F9=starting and F10 is pausing <3

Like this ?

Global $_Pause = False

;In this little example pressing n will pop up a message
;pressing Esc will leave.

While 1
    If _IsPressed('1b') = 1 Then Exit ; esc
    If _IsPressed('78') = 1 Then 
         $_Pause = True ; F9=starting
        ToolTip ( "Starting", 0, 0 ) ;The hotkey of this function is Pause
        Sleep ( 250 )
    EndIf
    If _IsPressed('79') = 1 Then
         $_Pause = False ; F10 is pausing
        ToolTip ( "Pausing", 0, 0 ) ;The hotkey of this function is Pause
        Sleep ( 250 )
    EndIf   
    
    If $_Pause = True Then
        ToolTip("Clicking",0,0)
        $color = PixelGetColor(@DesktopWidth / 2, @DesktopHeight / 2) ; center
        ConsoleWrite ( "$color : " & $color & @Crlf )
        If $color = 16711680 Or $color = 16646144 Then ;clicks when center turns red
            MouseClick("left")
        EndIf
    EndIf
    Sleep(30)
Wend

Exit

Func _IsPressed($hexKey)
  ; $hexKey must be the value of one of the keys.
  ; _IsPressed will return 0 if the key is not pressed, 1 if it is.
  ; $hexKey should entered as a string, don't forget the quotes!n
  ; (yeah, layer. This is for you)

   Local $aR, $bO

   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
      $bO = 1
   Else
      $bO = 0
   EndIf

   Return $bO
EndFunc  ;==>_IsPressed
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
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
 Share

  • Recently Browsing   0 members

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