I put together a script which is a total mess and a hack job, but for what it's worth it works on my end, although it's flakey and I think it's susceptible to errors and bugs simply because of the way Photoshop is so sensitive in its interface. But you could always examine the code and improve on it. Before running it:
-make sure your options bar is visible, docked and not floating. If it's floating (ie. if it's not attached just below the top menu bar) then it messes with the ahk_class and it changes from 'ahk_class Photoshop' to 'ahk_class OWL.ControlBarContainer'. If you must have the options bar floating and you like to move it around the screen, then change the class name in the script wherever it appears. But I think it's safest to keep it docked and use the script as is.
-pressing 1 will decrease the brush opacity, and pressing 2 will increase it. Don't press 1 or 2 too fast in succession, wait a few milliseconds before pressing a second, third, fourth time etc. If it's pressed too quickly I'm not sure what happens but I think it might bug out- it can be fixed but this is just a start. But of greater interest is that if I simply hold down 1 or 2, then the opacity continues to increase or decrease until I let go of 1 or 2. For some reason pressing it repeatedly too fast seems to not work as well, but holding it down works fine. Try both.
-close all other scripts that are running so you have a clean access to hotkeys keys 1 and 2. Or, just change the hotkeys to whatever you want
I wrote in a clause that if the opacity exceeds 100%, it will avoid the error pop up message the Photoshop throws, and keep the opacity at 100%. Same goes for 0%. I was going to add in a tooltip to display the current opacity, (which is pretty easy actually) but I can add that in later after being sure this actually works for you.
And last, if you get problems, try re-enabling both 'sleep, 250' lines to see if it helps - it works on my sytsem without it but I've been working with Photoshop long enough to know that what works today might not work tomorrow when automating it with AHK. Here it is (again it ain't pretty but she works):
1::
winactivate, ahk_class Photoshop
Controlgettext, ValueB, Edit2, ahk_class Photoshop
String := ValueB
StringTrimRight, OutputVarB, String, 1
Value2B := OutputVarB
Adjustment02 := Value2B-10
ControlSetText, Edit2, %Adjustment02%, ahk_class Photoshop
;sleep, 250
Controlgettext, Adjustment04, Edit2, ahk_class Photoshop
If Adjustment04 <= 0
{
ControlSetText, Edit2, 1`%, ahk_class Photoshop
sendinput, {enter}
SoundPlay, %A_WinDir%\Media\ding.wav
winactivate, ahk_class Photoshop
}
else
{
ControlClick, Edit2, ahk_class Photoshop
sendinput {right 4}
sendinput, {lshift down}{sc006}{lshift up}
sendinput {enter}
SoundPlay, %A_WinDir%\Media\ding.wav
winactivate, ahk_class Photoshop
return
}
return
2::
winactivate, ahk_class Photoshop
Controlgettext, ValueA, Edit2, ahk_class Photoshop
String := ValueA
StringTrimRight, OutputVarA, String, 1
Value2A := OutputVarA
Adjustment01 := Value2A+10
ControlSetText, Edit2, %Adjustment01%, ahk_class Photoshop
;sleep, 250
Controlgettext, Adjustment03, Edit2, ahk_class Photoshop
If Adjustment03 > 100
{
ControlSetText, Edit2, 100`%, ahk_class Photoshop
sendinput {enter}
SoundPlay, %A_WinDir%\Media\ding.wav
winactivate, ahk_class Photoshop
}
else
{
ControlClick, Edit2, ahk_class Photoshop
sendinput {right 4}
sendinput, {lshift down}{sc006}{lshift up}
sendinput {enter}
SoundPlay, %A_WinDir%\Media\ding.wav
winactivate, ahk_class Photoshop
return
}
return