Find easier way to inject into app without menubar
Currently I am using modified shell script(opens browser after load) and manually invoke it with pid
#!/bin/bash
lldb --attach-pid "$1" <<EOF
p (char)[[NSBundle bundleWithPath:@"/Library/Frameworks/FScript.framework"] load]
p (void)[FScriptMenuItem insertInMainMenu]
p (void)[[FSInterpreter interpreter] browse]
detach
quit
EOF
I tried to invoke it with service trough global hotkey but it not work everywhere.
tell application "System Events"
set pid to unix id of the first process whose frontmost is true
end tell
do shell script POSIX path of (path to current user folder) & "Library/Services/fscript-inject " & pid with administrator privileges
Maybe write helper app to choose from list of process to inject into ?
Automator allows you to program simple dialog boxes. Popup button would be sufficient in this case. But again, service requires an active app and context to be executed. Separate script is preffered for this approach.
You could use EasySIMBL, that's what I do
@perfaram Nice, can you share your solution ?
Yep, gonna post it this evening (I'll make a repo)
Steps :
- Download EasySIMBL (https://github.com/norio-nomura/EasySIMBL/releases)
- Extract and move EasySIMBL.app into /Applications or ~/Applications
- Launch EasySIMBL.app and check Use SIMBL, then quit EasySIMBL.app
- Download FScript (https://github.com/Kentzo/F-Script/releases) and put it in
/Library/Frameworks/ - Use my very own SIMBL plugin that loads FScript (https://github.com/perfaram/SIMBL-fscript)
- Compile it (xCode)
- Add it into EasySIMBL's Plugin Folder (usually, `~/Library/Application Support/SIMBL/Plugins/"
- Activate it in EasySIMBL
- Profit !
- Star my repo :star:
NB : This will load FScript into all applications. To load it into one specific app, open my project in xCode, and edit Info.plist's BundleIdentifier key (into SIMBLTargetApplications array) to match your app's identifier.
Thanks, I see it use insertInMainMenu but some apps don't have main menu to inject into, background or menubar icon only.
Then, wait a minute. I'm gonna add something to my repo
Okay, thougher than expected... Currently trying to work with shortcuts. EDIT : OKAY !! Shortcuts added ! ⌘ + ⌥ + ⇧ + C to show console, ⌘ + ⌥ + ⇧ + O to show Object explorer. In my repo as always : https://github.com/perfaram/SIMBL-fscript
Finally, if you're not pleased with shortcuts, then use the UDP socket at port 7138 :
echo -n "console" | nc -4u -w0 localhost 7138
Replace console by browser if needed ;-)