adding an extra key

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Hman
Posts: 32
Joined: 10 Apr 2018, 10:48

adding an extra key

26 May 2018, 11:22

Hi guys, i got the following script which works, it does does exactly what its ment to when i press the left mouse button.

now what I'm trying to do is add another button to this script, so i have to press both buttons for it to perform the same task.
So i'll have to press the left mouse button and another at the same time for it to work.

Many thanks


Code: Select all

Insert:: Hotkey, *~$LButton, Toggle
 
*~$LButton::
    while GetKeyState("LButton")
    {
        DllCall("mouse_event", uint, 1, int, 0, int, 5, uint, 0, int, 0)
        Sleep, 0
        DllCall("mouse_event", uint, 1, int, 0, int, 5, uint, 0, int, 0)
        Sleep, 5
    }
please place your code in [code][/code] tags!
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: adding an extra key

26 May 2018, 17:41

Try it like following:

Code: Select all

a & b::MsgBox % "yes"
Interesting enough, b isn't considered a hotkey on it's own like a is.

Alternatively, perhaps you could use following for slightly different outcome:

Code: Select all

#if GetKeyState()
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
Hman
Posts: 32
Joined: 10 Apr 2018, 10:48

Re: adding an extra key

29 May 2018, 08:42

i cant get this to work. how would you edit this into my code at the top?

how i want it to work is like the following...
i have to hold my right mouse button down to activate the above script. so it doesn't work on its own, then letting go of my right mouse button deactivates it
Hman
Posts: 32
Joined: 10 Apr 2018, 10:48

Re: adding an extra key

29 May 2018, 10:02

ok... how do I get this script to work by pressing and holding left mouse button & right mouse button at the same time and not just the left mouse button


~pgup::Suspend
Insert:: Hotkey, *~$LButton, Toggle

*~$LButton::
while GetKeyState("LButton")
{
DllCall("mouse_event", uint, 1, int, 0, int, 5, uint, 0, int, 0)
Sleep, 0
DllCall("mouse_event", uint, 1, int, 0, int, 5, uint, 0, int, 0)
Sleep, 5
}
Hman
Posts: 32
Joined: 10 Apr 2018, 10:48

Re: adding an extra key

29 May 2018, 11:18

anyone got an answer or i dea that i can work with please
Hman
Posts: 32
Joined: 10 Apr 2018, 10:48

Re: adding an extra key

29 May 2018, 11:44

someone please help, i tried a few combo's now but it either dont work or the script wont run due to an error


~pgup::Suspend
Insert:: Hotkey, *~$LButton & *~$RButton, Toggle

*~$LButton & *~$RButton::
while GetKeyState("LButton & RButton")
{
DllCall("mouse_event", uint, 1, int, 0, int, 5, uint, 0, int, 0)
Sleep, 0
DllCall("mouse_event", uint, 1, int, 0, int, 5, uint, 0, int, 0)
Sleep, 5
}
Hman
Posts: 32
Joined: 10 Apr 2018, 10:48

Re: adding an extra key

30 May 2018, 06:54

I did post this in the "HELP" section didnt I???
User avatar
donaldthejohn
Posts: 25
Joined: 27 Mar 2018, 20:23

Re: adding an extra key

30 May 2018, 08:29

this may work:

Code: Select all

Lbutton && Rbutton::
{
	DllCall("mouse_event", uint, 1, int, 0, int, 5, uint, 0, int, 0)
	Sleep, 0
	DllCall("mouse_event", uint, 1, int, 0, int, 5, uint, 0, int, 0)
	Sleep, 5
}
I am a noob at coding, PLEASE be patient with me :D
User avatar
donaldthejohn
Posts: 25
Joined: 27 Mar 2018, 20:23

Re: adding an extra key

30 May 2018, 08:33

what i posted will only run once, if it works. However, if you wanted a toggle, try adding an extra & to be a proper "and"
I am a noob at coding, PLEASE be patient with me :D
Hman
Posts: 32
Joined: 10 Apr 2018, 10:48

Re: adding an extra key

31 May 2018, 09:07

Hi donaldthejohn, thx for your replay. the code you posted does exactly what i wanted, thank you so much.

however i do need it to repeat as you suggested but i having a little trouble achieving that.

at the begining of your code - Lbutton && Rbutton:: - i had to take out the extra "&" for the script to run as it came up with an error.
so now i not quite sure what you mean when you say in your 2nd post - However, if you wanted a toggle, try adding an extra & to be a proper "and"

could you help out again please

thx
Hman
Posts: 32
Joined: 10 Apr 2018, 10:48

Re: adding an extra key

31 May 2018, 09:30

ok been messing around with it, what needs to happen is once ive pressed & held both mouse buttons, the mouse needs to continuosly move down until i let go.

thx again
Hman
Posts: 32
Joined: 10 Apr 2018, 10:48

Re: adding an extra key

31 May 2018, 11:47

ok this is what ive worked out

Insert:: Hotkey, ~RButton & LButton , Toggle

~RButton & LButton::
while GetKeyState("RButton")
{
DllCall("mouse_event", uint, 1, int, 0, int, 5, uint, 0, int, 0)
Sleep, 0
DllCall("mouse_event", uint, 1, int, 0, int, 5, uint, 0, int, 0)
Sleep, 5

}

this works in the way that i have to hold my RMB down then press and hold my LMB in order for it to activate, which is perfect.
now.... problem i have now is, when i let go of my LMB the script carries on, its not untill i let go of my RMB that the script stops

is there a way, maybe with the "pause" code, that when i let go of my LMB it stops, then carries on again when i press my LMB

thx for any help guys & girls, its much apreciated

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 125 guests