Jump to content

Recommended Posts

Posted

Hello,

I'm trying to add a portion to my script that will pause the entire thing, but only when certain keys are held down(alt,ctrl or shift)

Func Pause()
    While 1
    If _IsPressed("12", $dll)) Then
        While _IsPressed("12", $dll)
            Sleep(50)
        WEnd
    EndIf
WEnd
EndFunc

however pressing alt(12) doesn't stop the script from sending keys when it finds the color

 

my entire script if it helps

#include <WinAPIEx.au3>
If WinExists(@ScriptName) Then Exit
AutoItWinSetTitle(@ScriptName)
Global $Paused, $counter = 0
HotKeySet("{F4}", "TogglePause")
HotKeySet("{F5}", "Terminate")
Opt("SendCapslockMode",0)
$dll = DllOpen("user32.dll")

Shoot()

Func Shoot()
   While 1
   Local $coord = PixelSearch(1040, 781, 1036, 751,0xff00f8,1,1)
      If Not @error Then
         Send("e")
         Sleep(Random(40, 50, 1))
      EndIf
   WEnd
EndFunc

Func Pause()
    While 1
    If _IsPressed("12", $dll)) Then
        While _IsPressed("12", $dll)
            Sleep(50)
        WEnd
    EndIf
WEnd
EndFunc

Func TogglePause()
      $Paused = NOT $Paused
      While $Paused
      sleep(100)
      Tooltip("Paused Paused Paused Paused Paused Paused Paused Paused ",0,0)    
   WEnd
      Tooltip("")    
EndFunc

Func Terminate()
   Exit 0
EndFunc

 

Posted (edited)
#include <WinAPIEx.au3>
Global $Paused, $counter = 0
If WinExists(@ScriptName) Then Exit
AutoItWinSetTitle(@ScriptName)
Global $Paused, $counter = 0
HotKeySet("{F4}", "TogglePause")
HotKeySet("{F5}", "Terminate")
Opt("SendCapslockMode",0)
$dll = DllOpen("user32.dll")

Shoot()

Func Shoot()
   While 1
   Local $coord = PixelSearch(1040, 781, 1036, 751,0xff00f8,1,1)
      If Not @error Then
         Send("e")
         Sleep(Random(40, 50, 1))
      EndIf
   WEnd
EndFunc

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

 

Edited by TwistedXion
Posted
  On 7/15/2017 at 10:30 PM, TwistedXion said:
#include <WinAPIEx.au3>
Global $Paused, $counter = 0
If WinExists(@ScriptName) Then Exit
AutoItWinSetTitle(@ScriptName)
Global $Paused, $counter = 0
HotKeySet("{F4}", "TogglePause")
HotKeySet("{F5}", "Terminate")
Opt("SendCapslockMode",0)
$dll = DllOpen("user32.dll")

Shoot()

Func Shoot()
   While 1
   Local $coord = PixelSearch(1040, 781, 1036, 751,0xff00f8,1,1)
      If Not @error Then
         Send("e")
         Sleep(Random(40, 50, 1))
      EndIf
   WEnd
EndFunc

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

 

Expand  

I'm asking for it to pause the script when I'm pressing. What you "added" is already in the script I linked

Posted

Can you please tell us which program you try to automate? PixelSearch and Send are not very reliable as they depend on screen size and resesolution, window position etc.
Most of the time there are more reliable ways to do what you want to do.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

I'll try to explain. I'm searching for that color in a small area, at all times. I want it to press E repeatedly whenever that color is found, but I want the script to stop sending E if I'm HOLDING down alt, shift or control. The reason for this is when I'm sending E and I try to alt tab to another window it won't let me until the color is gone.

 

I need a temporary pause in my script that is triggered only when Ctrl, Shift or Alt is held down. In AHK you can do this with

~*alt::
Suspend, On
while GetKeyState("alt", "P")
    Sleep, 1
Suspend, Off
return

I'm looking for something similiar with Autoit.

  • Moderators
Posted

shshsh,

So if you can do it in AHK, why do you need to do it in AutoIt?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

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