Skip to content

Commit

Permalink
try to fix error: Can’t get window 1 of process . Invalid index
Browse files Browse the repository at this point in the history
  • Loading branch information
Maigo Erit committed Jan 8, 2017
1 parent 5a6906e commit 761b237
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/get-foreground-window-title.osa
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
global frontApp, frontAppName, windowTitle
set windowTitle to ""
global frontApp, frontAppName, windowTitle

set windowTitle to ""
tell application "System Events"

set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp

tell process frontAppName
set windowTitle to title of 1st window
end tell
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
tell process frontAppName
tell (1st window whose value of attribute "AXMain" is true)
set windowTitle to value of attribute "AXTitle"
end tell
end tell
end tell

return {frontAppName, windowTitle, frontApp}
7 changes: 7 additions & 0 deletions app/testscript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
for i in `seq 1 5`;
do
echo $i
echo `osascript get-foreground-window-title.osa`
sleep 1
done

0 comments on commit 761b237

Please sign in to comment.