Photoshop : MMB + LMB = hotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cedric3d
Posts: 15
Joined: 23 Feb 2018, 14:49

Photoshop : MMB + LMB = hotkey

15 Oct 2018, 04:11

Hi..

I try to tweak my photoshop for a better workflow.

I have already a MMB for PAN with that :

Code: Select all

#IfWinActive ahk_exe Photoshop.exe
    MButton::
    Send {Space Down}{LButton Down}
    Keywait, MButton
    Send {LButton Up}{Space Up}
    Return
Now I want to improve it by : MMB + LMB will do a CTRL + '+'
Do you know how I can do That starting from this script?

Thanks!! :)
WingbtZ
Posts: 22
Joined: 09 Aug 2018, 04:41

Re: Photoshop : MMB + LMB = hotkey

15 Oct 2018, 04:23

Try this

Code: Select all

#IfWinActive ahk_exe Photoshop.exe
    MButton::
    Send {Space Down}{LButton Down}
    Keywait, MButton
    Send {LButton Up}{Space Up}
    Return
MButton & LButton::^+
return
EDIT:
cedric3d
Posts: 15
Joined: 23 Feb 2018, 14:49

Re: Photoshop : MMB + LMB = hotkey

15 Oct 2018, 04:39

thx for your help!!

it says : error : invalid hotkey :/
WingbtZ
Posts: 22
Joined: 09 Aug 2018, 04:41

Re: Photoshop : MMB + LMB = hotkey

15 Oct 2018, 05:42

cedric3d wrote:
15 Oct 2018, 04:39
thx for your help!!

it says : error : invalid hotkey :/
Hmm wierd. I tryd the whole script and had no problem.

You sure you dident miss any spelling?

Code: Select all

MButton & LButton::^+
eelrod
Posts: 65
Joined: 10 Apr 2018, 11:17

Re: Photoshop : MMB + LMB = hotkey

15 Oct 2018, 11:02

The + character is special, so you will probably need to use an escape character or use braces around it. How about something like this:

Code: Select all

MButton & LButton::
Send , ^{+}
Return
cedric3d
Posts: 15
Joined: 23 Feb 2018, 14:49

Re: Photoshop : MMB + LMB = hotkey

15 Oct 2018, 14:10

th both...

weird... doesn't work neither :/
eqv
Posts: 72
Joined: 18 Sep 2018, 22:17

Re: Photoshop : MMB + LMB = hotkey

15 Oct 2018, 16:25

cedric3d wrote:
15 Oct 2018, 14:10
th both...

weird... doesn't work neither :/
Try this:

Code: Select all

MButton & LButton::
Send, ^=
Return
(note; press fast: first MButton, then LButton)

Hope it helps,
cedric3d
Posts: 15
Joined: 23 Feb 2018, 14:49

Re: Photoshop : MMB + LMB = hotkey

16 Oct 2018, 01:47

Not much...

What is really weird is that if I create a simple ahk file with only this for exemple :

MButton & LButton::a

I will get the same error message. I tried to see if the error was coming from the ^.

Any idea why I get this error?
cedric3d
Posts: 15
Joined: 23 Feb 2018, 14:49

Re: Photoshop : MMB + LMB = hotkey

18 Oct 2018, 03:46

Hi all!!

Finally I get it work! I was selecteing ANSI code AND put spaces around the &!
No error message BUT, the script itself doesnt work.

I guess it's because I have a MButton:: AND LButton&Mbutton::

Is it possible to have something like this :

Code: Select all

Mbutton::
  if Lbutton not pressed : 
    My old Code
  if Lbutton pressed :
    send ctrl+
I try several things with getkeystate, but cannot make it works :/

Thx :)
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Photoshop : MMB + LMB = hotkey

18 Oct 2018, 08:14

If you're interested, you can also try this:

Code: Select all

mbutton::
while GetKeyState("mbutton", "P") ; While mbutton is being pressed:
{
  mode = 1 ; Set mode to 1 (ON)
} ; After mbutton has been released::
mode = 0 ; Set mode to 0 (OFF)
return

#if mode = 1 ; If mode is 1 (ON):
$lbutton::
Send ^{lbutton down} ; Ctrl+lbutton down
KeyWait, mbutton ; Wait until mbutton has been released
Send {lbutton up} ; lbutton up
return
Works for me.
Ctrl doesn't need to have a down/up state - at least it worked fine for me.

You can add any other additional keys and buttons within the mode 1 block.

Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
cedric3d
Posts: 15
Joined: 23 Feb 2018, 14:49

Re: Photoshop : MMB + LMB = hotkey

18 Oct 2018, 08:33

So finally I gezt something a bit working.

what I want :
With MMB I pan
Keeping the MMB and clic hold LMB activate the zoom (CTRL+SPACE)

I almost work. BUT with that, somehow I I guess the MMB is still down (it is physically, but I want to put it up virtually to have MMB + LMB = CTRL+SPACE+LMB

Code: Select all

#IfWinActive ahk_exe Photoshop.exe
    ~MButton::
		Send {Space Down}{LButton Down}
		Keywait, MButton
		Send {LButton Up}{Space Up}
    Return
	
	~LButton::
		GetKeyState, state, MButton
		if state = D 
		{
			Send {Ctrl Down}{Space Down}{MButton Up}
			Keywait, Control  
			Send {Ctrl Up}{Space Up}{MButton Down}
		}		
	Return
Any idea???

Thx
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Photoshop : MMB + LMB = hotkey

18 Oct 2018, 09:29

Have you seen my post?

Try this:

Code: Select all

mbutton::
while GetKeyState("mbutton", "P") ; While mbutton is being pressed:
{
  mode = 1 ; Set mode to 1 (ON)
} ; After mbutton has been released::
mode = 0 ; Set mode to 0 (OFF)
return

#if mode = 1 ; If mode is 1 (ON):
$lbutton::
Send {LCtrl down} ; Hold down LCtrl
Send {Space down} ; Hold down Space
Send {lbutton down} ; Hold down left mouse button
KeyWait, mbutton ; Wait till mbutton has been released
Send {LCtrl up} ; Release LCtrl
Send {Space up} ; Release Space
Send {lbutton up} ; Release left mouse button
return
Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
cedric3d
Posts: 15
Joined: 23 Feb 2018, 14:49

Re: Photoshop : MMB + LMB = hotkey

18 Oct 2018, 14:56

OMG yes... it works!! Thx a lot :)

I post it here with the tweak to get the pan with MMB!! and other features!!

Thx a lot :)

Code: Select all


;----------------------------------
; Photoshop Hack. For Wacom in use purpose. 
; october. 2018, cedric3d [email protected]
; www.cedric3d.com 
; www.puppetsoul.com
; www.cedricphotos.com
:  Thx to Scr1pter from autohotkey forum for the Zoom feature
;----------------------------------
;
; MMB = Pan (space)
; MMB+LMB = Zoom (Space + Ctrl + LMB)
; Double press e = brush mode to erase
; Double press b = brush mode to Normal
;


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

#IfWinActive ahk_exe Photoshop.exe
	MButton::
		while GetKeyState("MButton", "P") ; While mbutton is being pressed:
		{
			mode = 1 ; Set mode to 1 (ON)
			Send {Space Down}{LButton Down}
			Keywait, MButton
			Send {LButton Up}{Space Up}
		} ; After mbutton has been released::
		mode = 0 ; Set mode to 0 (OFF)
	return

	#if mode = 1 ; If mode is 1 (ON):
	$LButton::
		Send {LCtrl down} ; Hold down LCtrl
		Send {Space down} ; Hold down Space
		Send {LButton down} ; Hold down left mouse button
		KeyWait, MButton ; Wait till mbutton has been released
		Send {LCtrl up} ; Release LCtrl
		Send {Space up} ; Release Space
		Send {LButton up} ; Release left mouse button
	return

	
	
#IfWinActive, ahk_class Photoshop
	;---------------------------------------------------
	; Double b = brush in normal mode
	~b::
		KeyWait, b		         	; wait for z to be released
		KeyWait, b, D T0.2		    ; and pressed again within 0.2 seconds
		if (!ErrorLevel){ 			; double press
			Send !+n
			;msgbox, It worked!
			}
	Return

	;---------------------------------------------------
	; Double e = brush in erase mode
	~e::
		KeyWait, e			        ; wait for z to be released
		KeyWait, e, D T0.2	       	; and pressed again within 0.2 seconds
		if (!ErrorLevel){ 			; double press
			Send b
			Send !+r
			;msgbox, It worked!
			}
	Return

	;---------------------------------------------------
	; Double l = deselect (not working with Wacom button still :/ )
	~l::
		KeyWait, l			        ; wait for z to be released
		KeyWait, l, D T0.2	     	; and pressed again within 0.2 seconds
		if (!ErrorLevel){ 			; double press
			Send ^d
			;msgbox, It worked!
			}
		
	/*
		HOPE TO MAKE IT WORK A DAY
	;---------------------------------------------------
	; Double a = select all
	~a::
		KeyWait, a			        ; wait for z to be released
		KeyWait, a, D T0.2	     	; and pressed again within 0.2 seconds
		if (!ErrorLevel){ 			; double press
			Send ^a
			msgbox, It worked!
			}
			
	;---------------------------------------------------
	; Double {BackSpace} = fill
	~Backspace::
		KeyWait, Backspace			        ; wait for z to be released
		KeyWait, Backspace, D T0.2	     	; and pressed again within 0.2 seconds
		if (!ErrorLevel){ 			; double press
			Send ^Backspace
			;msgbox, It worked!
			}
	*/
	Return
cedric3d
Posts: 15
Joined: 23 Feb 2018, 14:49

Re: Photoshop : MMB + LMB = hotkey

02 Jan 2019, 07:18

Hi everyone who helped me beforer !!

So know I wo uld like to have the script working for... illustratore!!
The Pan feature is working, not the zoom, and I don't have any idea why. I tweaked it, try different scenarios... nothing

MMB = pan, it's working
LMB+MMB (and scroll) = zoom, not working...

Thx for your help :)

Code: Select all

#IfWinActive ahk_exe illustrator.exe
	MButton::
		while GetKeyState("MButton", "P") ; While mbutton is being pressed:
		{
			; ---- set var
			mode = 1 ; Set mode to 1 (ON)
			
			;----- send keys
			Send {Space Down}{LButton Down}
			Keywait, MButton
			Send {LButton Up}{Space Up}
		
		} ; After mbutton has been released::
		mode = 0 ; Set mode to 0 (OFF)

		; ----double press MMB
		KeyWait, MButton		         	; wait for z to be released
		KeyWait, MButton, D T0.1		    ; and pressed again within 0.2 seconds
		if (!ErrorLevel){ 			; double press
			Send {Tab} 
		}

	return

	#if mode = 1 ; If mode is 1 (ON):
	$LButton::
		Send {Space down} ; Hold down Space
		Send {RCtrl down} ; Hold down LCtrl
		Send {LButton down} ; Hold down left mouse button
		KeyWait, MButton ; Wait till mbutton has been released
		Send {Space up} ; Release Space
		Send {RCtrl up} ; Release LCtrl
		Send {LButton up} ; Release left mouse button
	return


Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ArkuS and 94 guests