shshsh Posted July 15, 2017 Share Posted July 15, 2017 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 expandcollapse popup#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 Link to comment Share on other sites More sharing options...
TwistedXion Posted July 15, 2017 Share Posted July 15, 2017 (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 July 15, 2017 by TwistedXion Link to comment Share on other sites More sharing options...
shshsh Posted July 16, 2017 Author Share Posted July 16, 2017 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 Link to comment Share on other sites More sharing options...
shshsh Posted July 16, 2017 Author Share Posted July 16, 2017 pressing alt,shift or ctrl*. I don't see edit option on this forum.. Link to comment Share on other sites More sharing options...
TwistedXion Posted July 16, 2017 Share Posted July 16, 2017 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 Link to comment Share on other sites More sharing options...
water Posted July 16, 2017 Share Posted July 16, 2017 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
shshsh Posted July 16, 2017 Author Share Posted July 16, 2017 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 16, 2017 Moderators Share Posted July 16, 2017 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
shshsh Posted July 16, 2017 Author Share Posted July 16, 2017 AHK's pixelsearch is terrible and doesn't work at all in the way that Autoits does Link to comment Share on other sites More sharing options...
shshsh Posted July 16, 2017 Author Share Posted July 16, 2017 Sorry for double post.. I've also tried _WinAPI_GetAsyncKeyState and can't get it to work either. Link to comment Share on other sites More sharing options...
shshsh Posted July 17, 2017 Author Share Posted July 17, 2017 No ideas? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now