python - Open text file and search on OS X -
python - Open text file and search on OS X -
i open text file , search string , highlight it.
i use:
command ="open "+'"'+ file +'"' os.system(command) but want like:
command ="open "+'"'+ file +'"' + "then"+ "ctrl-f(string)" obviously doesn't work, there way this? want text in string highlighted normal ctrl+f.
you're on right track open; utilize ⌘+f (i'm assuming you're on os x tags), can utilize applescript tell the system events application perform keystroke:
os.system("open " + filename) # may need add together sleep() here if application not open , hence needs time load os.system("""osascript -e 'tell application "system events" keystroke "f" using {command down}'""") os.system("""osascript -e 'tell application "system events" keystroke \"""" + search_term + "\"'") python osx terminal
Comments
Post a Comment