I need to make this toggle able

Ask gaming related questions (AHK v1.1 and older)
Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

I need to make this toggle able

Post by Mandit_Gamer » 29 Aug 2021, 08:45

Hey I want to add a toggle option to this code, if you can edit the code and send it to me it will be helpful. The key I want to make this toggle is *r*
And here's the code:

Code: Select all

Lbutton::
settitlematchmode,2
IfWinActive, Chrome
click
sleep,0.000000000000000000000000001
click
[Mod edit: [code][/code] tags added.]
Last edited by BoBo on 31 Aug 2021, 06:46, edited 1 time in total.
Reason: Moved to Gaming section.

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: I need to make this toggle able

Post by mikeyww » 29 Aug 2021, 09:15

Code: Select all

r::
on := !on
SoundBeep, 1000 + 500 * on
Return

#If mouseOver("chrome") && on
LButton::
Click
Sleep, 0
Click
SoundBeep, 1500
Return
#If

mouseOver(proc) {
 MouseGetPos,,, uid
 WinGet, thisProc, ProcessName, ahk_id %uid%
 Return thisProc = proc ".exe"
}

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: I need to make this toggle able

Post by Mandit_Gamer » 29 Aug 2021, 09:18

mikeyww wrote:
29 Aug 2021, 09:15

Code: Select all

r::
on := !on
SoundBeep, 1000 + 500 * on
Return

#If mouseOver("chrome") && on
LButton::
Click
Sleep, 0
Click
SoundBeep, 1500
Return
#If

mouseOver(proc) {
 MouseGetPos,,, uid
 WinGet, thisProc, ProcessName, ahk_id %uid%
 Return thisProc = proc ".exe"
}
Will this also turn it off if I press r again?

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: I need to make this toggle able

Post by Mandit_Gamer » 29 Aug 2021, 09:26

mikeyww wrote:
29 Aug 2021, 09:15

Code: Select all

r::
on := !on
SoundBeep, 1000 + 500 * on
Return

#If mouseOver("chrome") && on
LButton::
Click
Sleep, 0
Click
SoundBeep, 1500
Return
#If

mouseOver(proc) {
 MouseGetPos,,, uid
 WinGet, thisProc, ProcessName, ahk_id %uid%
 Return thisProc = proc ".exe"
}
Can I remove the soundbeep things? @mikeyww

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: I need to make this toggle able

Post by mikeyww » 29 Aug 2021, 09:27

I can think of only one way to find out....

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: I need to make this toggle able

Post by Mandit_Gamer » 30 Aug 2021, 05:04

mikeyww wrote:
29 Aug 2021, 09:27
I can think of only one way to find out....
Can you gib some other way this didn't work. if it can be made a bit simpler it would be helpful

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: I need to make this toggle able

Post by mikeyww » 30 Aug 2021, 05:18

Here is an update for you. When you press R in Chrome, the left button will click twice when your mouse is over the Chrome window. Press R again to toggle. It's not a great hotkey, because you cannot use the key for anything else in Chrome.

Code: Select all

#IfWinActive ahk_exe chrome.exe
r::
on := !on
SoundBeep, 1000 + 500 * on ; OK to remove this line
Return

#If mouseOver("chrome") && on
LButton::
Click
Sleep, 0
Click
Return
#If

mouseOver(proc) {
 MouseGetPos,,, uid
 WinGet, thisProc, ProcessName, ahk_id %uid%
 Return thisProc = proc ".exe"
}

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: I need to make this toggle able

Post by Mandit_Gamer » 30 Aug 2021, 05:41

Uh, thanks for all the effort but I want a simple thing can you do it? Like just add an toggle thing when I press *r* or else add *r* to start the script nd *z* to stop it if you can make it simpler it will be helpfull for my smol brain to understand it, + I will not only use this for chrome, I will use the for games like Lunar Client [Minecraft client] and other games, so I set it like that so I can edit the *chrome* in my script to something like *Lunar* or *Minecraft*

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: I need to make this toggle able

Post by mikeyww » 30 Aug 2021, 06:01

If you have a different question than the one that you posted, then you will get a different answer. Nonetheless, if this script did not work for you in Chrome, then I do not have the answer. Sorry. The script works at my end. Others might be able to solve the issue for you.

You have not provided any description of what the entire script should do. I think that this will help other readers.

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: I need to make this toggle able

Post by Mandit_Gamer » 30 Aug 2021, 06:42

mikeyww wrote:
30 Aug 2021, 06:01
If you have a different question than the one that you posted, then you will get a different answer. Nonetheless, if this script did not work for you in Chrome, then I do not have the answer. Sorry. The script works at my end. Others might be able to solve the issue for you.

You have not provided any description of what the entire script should do. I think that this will help other readers.
Ok so lemme tell you I want this script to do this: if I click my right click mouse button it sends 1 more right click mouse button press packet to my computer which takes it as 1 click = 2cps can you set it to title match mode and if any application haves the words *Lunar* in its a apps title, so it will make it like it will only work on lunar client/minecraft, thats all I want I hope you can now help with it.
Hope you understand now
Thanks.

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: I need to make this toggle able

Post by mikeyww » 30 Aug 2021, 06:57

It seems that your initial post has nothing to do with your question. The script below worked when I tested it.

Code: Select all

SetTitleMatchMode, 2
#IfWinActive Lunar
RButton::
Click, R
Sleep, 500
Click, R
SoundBeep, 1000 ; OK to delete
Return
#IfWinActive

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: I need to make this toggle able

Post by Mandit_Gamer » 30 Aug 2021, 09:11

mikeyww wrote:
30 Aug 2021, 06:57
It seems that your initial post has nothing to do with your question. The script below worked when I tested it.

Code: Select all

SetTitleMatchMode, 2
#IfWinActive Lunar
RButton::
Click, R
Sleep, 500
Click, R
SoundBeep, 1000 ; OK to delete
Return
#IfWinActive
Whats the key to toggle it?

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: I need to make this toggle able

Post by mikeyww » 30 Aug 2021, 09:30

The trigger is the right mouse button. AHK denotes this button as RButton.

What the script does: "if I click my right click mouse button it sends 1 more right click mouse button press packet to my computer which takes it as 1 click = 2cps ... and if any application haves the words *Lunar* in its a apps title" :)

If you click on commands in the posted script, you can see more details about the commands, to learn how they work.

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: I need to make this toggle able

Post by Mandit_Gamer » 31 Aug 2021, 00:49

mikeyww wrote:
30 Aug 2021, 09:30
The trigger is the right mouse button. AHK denotes this button as RButton.

What the script does: "if I click my right click mouse button it sends 1 more right click mouse button press packet to my computer which takes it as 1 click = 2cps ... and if any application haves the words *Lunar* in its a apps title" :)

If you click on commands in the posted script, you can see more details about the commands, to learn how they work.
I meant like if I could stop it for like 5secs

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: I need to make this toggle able

Post by Mandit_Gamer » 31 Aug 2021, 01:38

mikeyww wrote:
30 Aug 2021, 06:57
It seems that your initial post has nothing to do with your question. The script below worked when I tested it.

Code: Select all

SetTitleMatchMode, 2
#IfWinActive Lunar
RButton::
Click, R
Sleep, 500
Click, R
SoundBeep, 1000 ; OK to delete
Return
#IfWinActive
Hey, I've made a code can you test this? I don't have access to my pc rn so I can't test it the code:

Code: Select all

Rbutton::
settitlematchmode,2
IfWinActive, Lunar
{
click, R
sleep,0.000000000000000000000000001
click, R
sleep,0.000000000000000000000000001
click, R
}
r::
 Pause, Toggle
return
^b:: ExitApp

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: I need to make this toggle able

Post by mikeyww » 31 Aug 2021, 04:42

Nor do I, but give it a go. Others may like to know if this works. The pause seems like it should be effective. Multi-line hotkey routines generally end in Return. I prefer my approach with the directive, but you have your choice of whatever works. One difference is that you have disabled your button in other programs.

Mandit_Gamer
Posts: 16
Joined: 21 Aug 2021, 02:30

Re: I need to make this toggle able

Post by Mandit_Gamer » 31 Aug 2021, 06:13

mikeyww wrote:
31 Aug 2021, 04:42
Nor do I, but give it a go. Others may like to know if this works. The pause seems like it should be effective. Multi-line hotkey routines generally end in Return. I prefer my approach with the directive, but you have your choice of whatever works. One difference is that you have disabled your button in other programs.
yea I only want this in lunar client

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: I need to make this toggle able

Post by mikeyww » 31 Aug 2021, 07:12

I don't mean that the subroutine is disabled in other programs. I mean that the button is disabled in other programs, because without the directive, you now have a global hotkey that works only in your program, because that is how the subroutine is coded. An alternative to the directive is Else Click, R.

You can verify my comments by running your script and pressing the right button in another program. I recommend fixing the problem with the Return first.

Post Reply

Return to “Gaming Help (v1)”