Need help using same key in different loops

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
beautiful_blood2
Posts: 4
Joined: 27 Nov 2021, 14:36

Need help using same key in different loops

27 Nov 2021, 14:45

Hello guys, I want to make a program with the following logic:

While I'm holding the MButton, I want autohotkey to hold the Ctrl+MButton.

While I'm holding Mbutton + Rbutton at the same time, I want autohotkey to just hold MButton, but MButton should do the original program's functionality and not the one programmed by me in the first loop.

With the following code I managed to correctly execute the first while loop, but the second loop never gets executed.

Code: Select all

#IfWinActive, ahk_exe SLDWORKS.exe

While getkeystate ("MButton","P")
{
MButton::^Mbutton
}
Return

While getkeystate ("MButton","P") & getkeystate("RButton", "P")
{
~MButton & RButton::MButton
}
Return
Does anyone know how to proceed in a case like this?

Thank you very much in advance for your help!
beautiful_blood2
Posts: 4
Joined: 27 Nov 2021, 14:36

Re: Need help using same key in different loops

27 Nov 2021, 17:09

Hello guys, I'll reply this post because I made some advances in the problem.

I would like to make a program with the following logic:

While I hold MButton pressed, I would like to autohotkey map this to mantain pressed Ctrl+MButton

While I hold MButton and RButton, I would like to autohotkey map this to mantain pressed MButton, with MButton having the original program's functionality.

My code at the moment is this:

Code: Select all

#If WinActive("ahk_exe SLDWORKS.exe")

MButton::
send, {ctrl down}{Mbutton down}
return
MButton up::
send, {ctrl up}{Mbutton up}
return


mbutton & rbutton::
var = 1
send, {ctrl up}
send, {MButton down}
return

#if var 
rbutton up::
mbutton up::
send, {MButton up}
var = 0
return
#if
What is the problem?: When I press and hold MButton, nothing happens untill I release it. Then it does what holding MButton is supposed to do but only for an brief instant.

When pressing and holding MButton and RButton at same time, everything works fine.

Hope someone can give me some advice about how to deal with this.

Thank you guys in advance.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: rc76 and 221 guests