Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

davestovies

macrumors newbie
Original poster
Jan 1, 2024
2
0
Hi everyone.

I'm here with a slightly odd question regarding using Apple Script to carry out timed commands on the Playstation Remote Play application in a game. There's a post from a few years ago with a similar problem I've been trying to use as a guide, but I need help getting the script to run. For context, I have no previous experience with programming, so I've been using guides online to help with no success.

The idea was to use Apple Script to carry out timed commands through the PS Remote Play app, which would trigger in my game. The game is Yakuza 0, and there's a baseball minigame with fairly precise timing that's hard for me to pull off. Here's a video of the game for reference.

While looking around online, I found a post about using scripts for this exact purpose, inspired by the post from this site I linked earlier. I copied the Apple Script code left in the comments and tried running it, and nothing happened. I start the code and then switch to the Remote Play window, and nothing happens. I experimented with changing "System Event" to "RemotePlay" in the code, thinking that would trigger it, but it doesn't make any difference.

Below is the code that is supposed to work with Yakuza 0's batting minigame.
display dialog "Bring up your window where you want to play Baseball, you have 5 seconds to do so after pressing OK"

delay 5





if shiftKeyPressed() is true then exit repeat

tell
application "System Events" to keystroke return

delay 5.2

tell application "System Events" to keystroke return

delay 5

tell application "System Events" to keystroke return

delay 5

tell application "System Events" to keystroke return

delay 7

tell application "System Events" to keystroke return

delay 5.248

tell application "System Events" to keystroke return

delay 5

tell application "System Events" to keystroke return

delay 5.1

tell application "System Events" to keystroke return

delay 5

tell application "System Events" to keystroke return

delay 5.72

tell application "System Events" to keystroke return









display dialog "Script Ended"



--Actual shift key detection below

use framework "Foundation"

use framework "AppKit"



on shiftKeyPressed()

set |DnS| to current application

set cMods to |DnS|'s class "NSEvent"'s modifierFlags()

return (cMods div (get |DnS|'s NSShiftKeyMask) mod 2 is 1)

end shiftKeyPressed

All the code is meant to do is press x (or whatever the equivalent is on the keyboard through Remote Play) at a set time to hit the ball at the right time to pass the minigame. This post has the specific timings and an explanation of the Windows equivalent of the code.

I hope I have provided enough information to help solve this. As I've mentioned, the code I'm using is supposed to work, but I still need to get it to do something; it just runs in the background without doing anything in Remote Play like it's meant to.
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
Well, this Apple Script would hit the enter/return key to do the batting. Does that key work when used manually in Yakuza 0 on PS RemotePlay? It may be intended for the PC version of the game not through PlayStation RemotePlay. System Events is correct in there. It shouldn't be changed. The keystroke is a system event not an application event. I doubt the PS RemotePlay application receives Apple Script events for cheating reasons as well as them just not putting time into implementing that.

You may also need to give Apple Script a few permissions like Accessibility and input monitoring.
 

davestovies

macrumors newbie
Original poster
Jan 1, 2024
2
0
Well, this Apple Script would hit the enter/return key to do the batting. Does that key work when used manually in Yakuza 0 on PS RemotePlay? It may be intended for the PC version of the game not through PlayStation RemotePlay.
So when I use Remote Play normally, the enter/return key works as a select button alongside my controller when I have it plugged into my Mac. As for the code, I've only ever seen this specific code mentioned in reference to using it with Remote Play, not the regular PC version of the game, since I think there are other methods for making it easier on PC.

I doubt the PS RemotePlay application receives Apple Script events for cheating reasons as well as them just not putting time into implementing that.
I have seen other posts online mentioning using Apple Script with Remote Play since it's essentially just using my Mac as a second screen over wifi.

You may also need to give Apple Script a few permissions like Accessibility and input monitoring.
How would I change the permissions for Apple Script?
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
So when I use Remote Play normally, the enter/return key works as a select button alongside my controller when I have it plugged into my Mac. As for the code, I've only ever seen this specific code mentioned in reference to using it with Remote Play, not the regular PC version of the game, since I think there are other methods for making it easier on PC.


I have seen other posts online mentioning using Apple Script with Remote Play since it's essentially just using my Mac as a second screen over wifi.


How would I change the permissions for Apple Script?
When you say select do you mean the intended button or the Select PlayStation button?

You misunderstand in the middle part. I am not saying it can’t be done. I am explaining why it should be system events and not remote play that is the receiver of events. Because the remote play app is not written to receive Apple script events. So you use system events to interact with it indirectly.

As for permissions, use the privacy and security pane in system settings to add apple script under the relevant permission sections. If further instructions are needed let me know and I’ll provide screenshots when home
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.