Ich habe ein AppleScript, das die Position und die Größe des Anwendungsterminals ändert:
Wie hier:
tell application "Terminal"
set position of front window to {1, 1}
set size of front window to {1, 1}
end tell
Wenn ich die Größe des Fensters auf setze {1, 1}
, wird es so klein, dass es nicht besser sichtbar ist.
Meine Frage ist, wie kann ich den Fokus des Fensters für eine bestimmte Zeit festlegen, sodass weder Benutzeraktivitäten noch Anwendungen den Fokus des Terminalfensters erfassen können?
Der beste Weg wäre mit AppleScript, aber jede programmgesteuerte Lösung mit Python wäre schön.
activate application "Terminal"
tell application "Terminal"
set position of front window to {1, 1}
set size of front window to {1, 1}
end tell
tell application "System Events" to keystroke "your message here\rexit\r"
Zusätzlich können Sie Hilfe von AppleScript erhalten, um eine aktive Anwendung zu erhalten
um den Fokus wieder auf die ursprüngliche Anwendung zu richten
Mit Hilfe von javadevg und der Antwort von AppleScript get active Application habe ich folgende Lösung erstellt:
tell application "Terminal"
activate
set position of front window to {1, 1}
set size of front window to {111, 111}
end tell
tell application "System Events"
set frontmostProcess to first process where it is frontmost
set visible of frontmostProcess to false
repeat while (frontmostProcess is frontmost)
delay 0.1
end repeat
set secondFrontmost to name of first process where it is frontmost
set frontmost of frontmostProcess to true
end tell
tell application "System Events"
set activeApp to name of first application process whose frontmost is true
repeat while (get name of every application process) contains "Terminal"
try
activate application "Terminal"
end try
end repeat
end tell
Ich arbeite nicht viel mit AppleScript, entschuldigen Sie bitte meinen Programmierstil usw.
Mit diesem Skript wird ein Terminal geöffnet, und es verliert den Fokus nicht, bis das Terminal geschlossen wird.
Jozef Legény
Oni1
Benutzer14492
Oni1
Stan Hutcheon