Wait Z pressed or Right Click Button released

Ask gaming related questions (AHK v1.1 and older)
pootz10
Posts: 5
Joined: 16 Sep 2015, 12:51

Wait Z pressed or Right Click Button released

20 Jul 2017, 23:35

Hello, I'm trying to do a ahk script to handle change dpi of my mouse automatically with logitech gaming software.

I'm trying to turn on Scroll Lock key and turn it off when Right click Button is released or after Z key be pressed and released.

In the game, I need to press and hold right click button to aim and press Z to zoom in / press it again to zoom out or release right click button to zoom out and stop aiming.
So, basically when I'm not aiming or I'm not zooming in, I'd like to turn off Scroll Lock key. And when I am aiming I'd like to wait zoom in to turn Scroll Lock key on.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


#If WinActive("Rise of the Tomb Raider") && ( RButtonState = D )
~z::SetScrollLockState,On

#If WinActive("Rise of the Tomb Raider") && GetKeyState("ScrollLock", "T") && ( RButtonState = D )
KeyWait, RButton
~z::SetScrollLockState,Off
The Scroll Lock "turn on" function is working, but the turn off it's not.

I've also tried the following:

Code: Select all

#If WinActive("Rise of the Tomb Raider") && GetKeyState("ScrollLock", "T") && ( RButtonState = D )
KeyWait, RButton
KeyWait, z
SetScrollLockState,Off
by the way I'm using a older version v1.1.22.06 if it's a problem I can update it just didn't do it, because I don't know if an older script that a I use would be outdated and wouldn't work on 1.1.26.01
mast4rwang
Posts: 141
Joined: 19 Jul 2017, 09:59

Re: Wait Z pressed or Right Click Button released

21 Jul 2017, 05:31

What I understand you need is this:

Hold right button does nothing but if you release it, you release scrolllock in case it is messed up.
Z button also presses the scroll button.

In your place I'd rebind the scrolllock key to Z so I can manually toggle it without having to go through the trouble and also send,{z down}sleep{z up}.

Also

Code: Select all

~*RButton Up::SetScrollLockState,Off
Easy.
pootz10
Posts: 5
Joined: 16 Sep 2015, 12:51

Re: Wait Z pressed or Right Click Button released

21 Jul 2017, 13:21

Thank you for your reply.
It's working, but it still does not turn off when I press and release Z.
Sometimes I am aiming with zoom in and I want to continue aiming, but zooming out, so z should turn off scroll lock also, and it's not working.

Code: Select all

#If WinActive("Rise of the Tomb Raider") && ( RButtonState = D )
~z::SetScrollLockState,On

#If WinActive("Rise of the Tomb Raider") && GetKeyState("ScrollLock", "T") && ( RButtonState = D )
~*RButton Up::SetScrollLockState,Off
~z::SetScrollLockState,Off
also just pressing z, without right click button be pressed (which does not do anything on the game if I'm not holding Right Click Button down) is turning on scroll lock key, that shouldn't happen I believe my check for Right Click Pressed Down isn't working right.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 53 guests