shshsh

IsPressed Pause function?

11 posts in this topic

#1 ·  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

 

Share this post


Link to post
Share on other sites



#2 ·  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

Share this post


Link to post
Share on other sites

#3 ·  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

Share this post


Link to post
Share on other sites

#4 ·  Posted

pressing alt,shift or ctrl*. I don't see edit option on this forum..

Share this post


Link to post
Share on other sites

#5 ·  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

Share this post


Link to post
Share on other sites

#6 ·  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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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

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

Share this post


Link to post
Share on other sites

#8 ·  Posted

shshsh,

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#9 ·  Posted

AHK's pixelsearch is terrible and doesn't work at all in the way that Autoits does

Share this post


Link to post
Share on other sites

#10 ·  Posted

Sorry for double post..

I've also tried

_WinAPI_GetAsyncKeyState and can't get it to work either.

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

No ideas?

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