F-Script icon indicating copy to clipboard operation
F-Script copied to clipboard

Find easier way to inject into app without menubar

Open diimdeep opened this issue 10 years ago • 9 comments

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 ?

diimdeep avatar Jan 29 '15 11:01 diimdeep

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.

Kentzo avatar Feb 25 '15 16:02 Kentzo

You could use EasySIMBL, that's what I do

perfaram avatar Apr 27 '15 07:04 perfaram

@perfaram Nice, can you share your solution ?

diimdeep avatar Apr 27 '15 08:04 diimdeep

Yep, gonna post it this evening (I'll make a repo)

perfaram avatar Apr 27 '15 10:04 perfaram

Steps :

  1. Download EasySIMBL (https://github.com/norio-nomura/EasySIMBL/releases)
  2. Extract and move EasySIMBL.app into /Applications or ~/Applications
  3. Launch EasySIMBL.app and check Use SIMBL, then quit EasySIMBL.app
  4. Download FScript (https://github.com/Kentzo/F-Script/releases) and put it in /Library/Frameworks/
  5. Use my very own SIMBL plugin that loads FScript (https://github.com/perfaram/SIMBL-fscript)
  6. Compile it (xCode)
  7. Add it into EasySIMBL's Plugin Folder (usually, `~/Library/Application Support/SIMBL/Plugins/"
  8. Activate it in EasySIMBL
  9. Profit !
  10. 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.

perfaram avatar Apr 27 '15 17:04 perfaram

Thanks, I see it use insertInMainMenu but some apps don't have main menu to inject into, background or menubar icon only.

diimdeep avatar Apr 28 '15 15:04 diimdeep

Then, wait a minute. I'm gonna add something to my repo

perfaram avatar Apr 28 '15 16:04 perfaram

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

perfaram avatar Apr 28 '15 19:04 perfaram

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 ;-)

perfaram avatar Apr 29 '15 13:04 perfaram