Change Keys only in photoshop? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SoupLover
Posts: 3
Joined: 24 Jun 2017, 12:53

Change Keys only in photoshop?  Topic is solved

24 Jun 2017, 13:06

I just got a surface pen, and it has a right click button on the side. I want to change it so that instead of right clicking, the button is undo, (ctrl z). But I don't want all right clicks to be undo, only when I click the right button on the pen, not on a mouse. If that's not possible, is there anyway to make the right click button be ctrl z only in Photoshop and adobe animate, and then stop the script when I get out of those programs? I have no idea how to script, so if someone could just put a completed script, that would be great.
robertcollier4
Posts: 33
Joined: 09 Apr 2016, 22:14

Re: Right click only in photoshop?

24 Jun 2017, 13:44

You will need to first get the Window Class of the two applications (look for the string after ahk_class) using the following tool:
https://github.com/fincs/SciTE4AutoHotk ... owInfo.ahk

Code: Select all

#IfWinActive, ahk_class MyWinClass1
RButton::SendInput, ^z
#IfWinActive

#IfWinActive, ahk_class MyWinClass2
RButton::SendInput, ^z
#IfWinActive
SoupLover
Posts: 3
Joined: 24 Jun 2017, 12:53

Re: Change Keys only in photoshop?

24 Jun 2017, 14:11

I get the script, but how would I find the class? Would I need to have the applications open?
robertcollier4
Posts: 33
Joined: 09 Apr 2016, 22:14

Re: Change Keys only in photoshop?

24 Jun 2017, 14:19

SoupLover wrote:I get the script, but how would I find the class? Would I need to have the applications open?
1. Install AutoHotkey
2. Download the following file (click on "Raw" then Save As from your browser)- https://github.com/fincs/SciTE4AutoHotk ... owInfo.ahk
3. Run the file ActiveWindowInfo.ahk - this will open a window called "Active Window Info"
4. Open your Photoshop application, resize the Photoshop window so that it is next to "Active Window Info" window. Now click anywhere inside the Photoshop window and you will see the ahk_class in the "Active Window Info" window.
SoupLover
Posts: 3
Joined: 24 Jun 2017, 12:53

Re: Change Keys only in photoshop?

24 Jun 2017, 14:27

Thanks, it worked! For some reason, I have to click the stroke to undo, but it works! Thank you!
robertcollier4
Posts: 33
Joined: 09 Apr 2016, 22:14

Re: Change Keys only in photoshop?

24 Jun 2017, 14:36

There's actually a better way I just thought of. On "RButton" you can check for the window underneath the mouse's position and see if its Photoshop or Adobe Animate and if so, then send the ^z. Otherwise if its not one of those two applications, then send a RButton as normal.
This would allow you to still right click on the Windows Task Bar while Photoshop is the "active window" (but not the window under the mouse cursor current position). See:
https://autohotkey.com/docs/commands/MouseGetPos.htm - MouseGetPos - you would need to get the ahk_class from OutputVarWin

Try this:

Code: Select all

RButton::
MouseGetPos, MyX, MyY, MyWinID
WinGetClass, MyWinClass, ahk_id %MyWinID%
If( (MyWinClass == "PhotoshopXYZ123") || (MyWinClass == "AnimateXYZ123") ) {
    SendInput, ^z
} Else {
    SendInput, {RButton}
}
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada and 223 guests