I have a script to take a picture of the desktop of my blind server (MM 2018) that is not working if I am not logged in as in connected to it. If I am logged in and observing the screen it works fine. The MM has a dongle (Brand MI TV) in the screen port. I needed to do this since screen sharing (via remote management) does not work good without a monitor connected.
So, if I run the script while connected it works as should. As soon as I disconnect it stops working. See pic for the notification I get.
Any idea as to why?
This is the part of the script that makes the picture.
-- Activate windows
tell application "Finder"
set visible of every process whose visible is false and name is not "Finder" to true
end tell
delay 3 -- remove if not needed however it seems to be needed to make it run properly
-- Make DT pic
set dFolder to "~/Desktop/"
do shell script ("mkdir -p " & dFolder)
set i to 1
repeat 1 times -- interval put in any repeat you like
do shell script ("screencapture " & dFolder & "DT-Server-Pic-" & i & ".png")
delay 1 -- wait for xx seconds - remove if not needed
set i to i + 1
end repeat
-- Send a message - here follows the sending part of the script
I could agree with that seems a logical conclusion. So the question is how to work around that.
See in the control panel it sees the dongle as a screen. If I remove it it reverts to build-in display (see pics and of course the MM has no display build in). One would think the MM sees a screen and screenshots should work.
I have done some more experimenting. Tried 2 different brand dongles, no success.
Found Shottr on the internet, installed it and it makes perfect pictures of the screen and on its own (as in when I am not logged in). It can be scripted with keyboard commands. Not the most elegant solution but it works.
Strange or? I do not understand why one works and the other not.