Not all things you can do in Photoshop's UI can be done in actions and Scripts. Some thing do not record or have menu items to use to perform what you want to do. You may be able to do the with some external application that can automate some device events like mouse clicks. I believe I have seem appends where users have used something like AutoHotKey to do things that can not be done with Photoshop's automation Actions and Scripts. AutoHotKey is windows only there may be something like it for the Mac.
I do not use AutoHotKey so I doe not know if it can be used to do what you want to to.