1

I want to send click when I press hold Alt key + 1, and then, still holding the alt key send right-click when press the 2 key

my code

!q::

Send {LButton Down}

KeyWait q

Send {LButton Up}

Return

!w::

Send {RButton Down}

KeyWait w

Send {RButton Up}

Return

the idea is to always have pressed the ALT key,

example :

!:: { q::
Send {LButton Down}

KeyWait q 

Send {LButton Up}

w:: 

Send {RButton Down} 

KeyWait w 

Send {RButton Up} 

KeyWait ! 

Return 

}

Help me please

Syscall
  • 19,327
  • 10
  • 37
  • 52
dcaro
  • 49
  • 6
  • the second code does not work – dcaro Sep 10 '15 at 16:08
  • Why not "Kick off" the script with Alt+1, do your thing, then wait for "just" 2 (not Alt+2) to continue the script. You could test the next input and if it is not a number (i.e. you started doing something else), break out of the script. Alternatively, if you want to use Alt+2, you could first test the key state of Alt (Down). – Robert Ilbrink Sep 11 '15 at 14:20

2 Answers2

1

Is this what you are looking for?

!1::Click

!2::Click Right
errorseven
  • 2,672
  • 2
  • 14
  • 20
  • good, but holding click? and [hold alt] + [1] (send click) and still holding alt, press 2 to send Click Right :( maybe is imposible – dcaro Sep 10 '15 at 20:50
1

I tested some code and I came to this conclusion.
You should avoid using alt key cause (you can test it) it will cause to disappear the right click menu (right click in desktop without any ahk app running. then press alt, you see that the menu disappears.)
So here I use the Ctrl key.

The only thing you had to add was a $ prefix. same as below:

$^1::
    send, {lbutton down}
    keywait, 1
    send, {lbutton up}
return

$^2::
    send, {rbutton down}
    keywait, 2
    send, {rbutton up}
return

Its with Ctrl key and you can not use Alt key cause it disables the flying out menu. You can use ! alt key instead of ctrl key but you have to first release alt then release 2 to prevent that menu from disappearing.

I think what you want is something like this. I figured out why it was sending repetitively and took care of it. but it does not work either. maybe the alt key is autosending itself (i mean naturally its behavior is like this).

$ALT::
    send, {alt down}
    keywait, ALT
return

$ALT UP::
    send, {alt up}
return

$!1::
    send, {lbutton down}
    keywait, 1
    send, {lbutton up}
return

$!2::
    send, {rbutton down}
    keywait, 2
    send, {rbutton up}
return

Another Solution is to use a key in place of the modifier:

$1::
    if GetKeyState("z", "p") {
        send, {lbutton down}
        keywait, 1
        send, {lbutton up}
    }
    else {
        SetKeyDelay, -1
        Send {Blind}{1 DownTemp}
    }
return

$1 up::
    SetKeyDelay, -1
    Send {Blind}{1 Up}
return

$2::
    if GetKeyState("z", "p") {
        send, {rbutton down}
        keywait, 2
        send, {rbutton up}
    }
    else {
        SetKeyDelay, -1
        Send {Blind}{2 DownTemp}
    }
return

$2 up::
    SetKeyDelay, -1
    Send {Blind}{2 Up}
return

you can use any key instead of "z". z is like the alt key.