key toggle (but keep function for once) / how to pixel detect toggle?

Ask gaming related questions (AHK v1.1 and older)
Lagi
Posts: 7
Joined: 24 Aug 2017, 10:57

key toggle (but keep function for once) / how to pixel detect toggle?

19 Sep 2018, 01:38

in game key Q open (and close) window with Spells.

Only In this Spell window, i would like by pressing keys to click specific position on screen. Problem is I want to do it also with Q key.

I try it like that:
  • script is from start suspend
    key Q un-suspend it (but also open spell window)
    script is suspend again with space & esc
if i use ~q:: then the Spell window is open everything works, but when I press Q again i'm closing window (which I dont want), because its native game key function.

if i use q:: then I can not open Spell window

tldr:
i want pressing Q to work once like Q, and then as D (until other key reset it):
f.ex. [Q pressed 4x times]: qddd

Code: Select all

Suspend, on

space::Suspend on
esc::Suspend on

q::
Suspend off
WinGetActiveStats, Title, W, H, a, b 
mousegetpos, x, y
mousemove, 84, 380
click
mousemove, x, y
return
======================
2.
other problem:
I have also other keys scripted, I would like some of them (mouse f.ex) to not be affected by this Q toggling


======================
3.
right now i see on this forum function "pixel get color":

how to toggle key set automatically, if certain pixel on screen have specific color?
is it reliable method? (in game screen brightness not affect it ?)
User avatar
Onimuru
Posts: 107
Joined: 08 Sep 2018, 18:35
Contact:

Re: key toggle (but keep function for once) / how to pixel detect toggle?

19 Sep 2018, 03:08

Code: Select all

#SingleInstance Force
CoordMode, Mouse, Screen
SendMode Input

Exit

~*$Space::Toggle_Variable := False

~*$Esc::Toggle_Variable := False

*$q::
	Send, % ((!Toggle_Variable) ? "q" : "d")
	If !Toggle_Variable
	{
		Toggle_Variable := True
		MouseGetPos, x, y
		Sleep 50			;Give the UI time to register q
		Click, 84, 380		;Check if these coords match "CoordMode, Mouse, Screen"
		MouseMove, x, y, 0
	}
	Return
Add your other keys and functions, they will not be affected. No need for Suspend.

I have no experience with PixelSearch but presumably you will need an image to search for in an area on screen (for performance, rather than the entire screen) on a timer and if ErrorLevel then: Action

Please note, you will need to add an exception for "If GetKeyState("Shift", "P")" to capatalize q while this is running.
Lagi
Posts: 7
Joined: 24 Aug 2017, 10:57

Re: key toggle (but keep function for once) / how to pixel detect toggle?

19 Sep 2018, 09:21

Arigatō Onimuru,

I'm cooking now my script.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: jameswrightesq and 124 guests