I'm trying to do something very simple. But I do not succeed
If the app Scrivener is in front --> hide
If the app Scrivener is not the front app --> show
The problem seems to be: Scrivener can activate a floating window. In this case the window is visible (but not highlighted) even if Scrivener is not the front app. But I don't understand what difference this should make for the if conditions.
I have tried countless variants. This one works fine when „floating window“ is enabled but not otherwise. I am very grateful for your help
tell application "System Events"
if visible of process "Scrivener" is true then
set visible of process "Scrivener" to false
else
set visible of process "Scrivener" to true
end if
end tell
is this an Apple script? I have no idea about that...
The question is, why does the if condition work only when the window floats? If Scrivener is not the front app, it doesn't matter if you see the window or not.
Might not work, but it's worth a shot. If it doesn't... Are you able to automate disabling the floating window when you hide the app, then re-enabling it when you unhide?
Thanks noisneil, just tried it. Unfortunately, the script does not work either. It hides, but it does not show...
And no, I can't turn it on and off as I want because Scrivener is buggy here.
and well, a window is a window. It may or may not float above all other apps
"can you send a screenshot of the floating window that shows when the app is meant to be hidden?"
note, if the float function is not switched on, the window appears briefly and disappears again immediately. If I toggle a few times, it eventually settles down.
No problem. I'm glad you give me some of your time Yes, exactly, Stickies note is a good example.
And yes, Scrivener behaves the way I want using the Dock.
To mention that again: The macro above, works when the window floats, but it doesn't work when the window behaves "normally". Maybe this is a bug in Scrivener.
Nige_S gave me the idea to try the same macro with Stickies note. There it works with floating window or without. Does this mean it's a bug in Scrivener?
It gives you a full length screenshot of the whole macro.
I was just checking you weren't using it as part of your original macro with conditions. It's intended to work as a standalone toggle. Evidently it's not working for you. Hmm....
I have to admit I'm not 100% clear on what the situation is. Correct me if I'm wrong:
You can hide the app, but because a floating window remains visible (even when the app is 'hidden'), you can't unhide the app because KM/Applescript still think it's visible...?
Is there a differentiator in the window titles of the floating window and the main window? That might get us somewhere.
Not necessarily a bug -- there are different types of floating windows, which probably means different behaviours.
I think @noisneil is on the right track. And it might help if there's some way for KM to indicate which "if" branch it's taking each time -- @noisneil, is it possible to drop in AS display dialogs or system beeps (one for true, two for false or something) to troubleshoot?
I generally just watch returned values in Script Debugger for errors.
I've just downloaded the Scrivener trial and set the window to float (Window > Float Window).
Both the applescript above and this basic macro (below) work perfectly, so I don't think I quite understand what the situation is that @Frankb is dealing with yet.