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
1 hour ago, 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

 

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

Posted
5 hours ago, shshsh said:

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

Hit F4 to pause the script

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:

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'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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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