Page 1 of 1

Take Screenshot on other monitor (Solved)

Posted: Sat Jan 25, 2025 3:28 pm
by mrcoollion
Hello LC specialist.

For me it is afternoon so good afternoon :D .
Does anybody know how to make a snapshot of a screen on another monitor than my main monitor.
My application is placed on a second monitor and I want to make a snaphot of the screen of that monitor, however it keeps taking a snapshot of my main laptop monitor.
Anyway to control this?

I use this line of code

Code: Select all

export snapshot from rect (the screenrect) to file tPathAndFile as jpg
Regards,

Paul Agerbeek

Re: Take Screenshot on other monitor

Posted: Sat Jan 25, 2025 3:52 pm
by richmond62
I am sorry, I am not near my computer at the moment but I vaguely remember something about screenrects (with an 's').

Re: Take Screenshot on other monitor

Posted: Sat Jan 25, 2025 4:24 pm
by Klaus
Dag Paul,

you almost got it! :-)

Code: Select all

export snapshot from rect (LINE 2 OF the screenrectS) to file tPathAndFile as jpg
Groetjes

Klaus

Re: Take Screenshot on other monitor

Posted: Sat Jan 25, 2025 4:40 pm
by mrcoollion
Thank (dankjewel) Klaus,

Almost there, Now I need to know at which of the three lines my stack is at because i have three monitors (including the laptop monitor)

Code: Select all

effective working screenRect
allways gives me the screenrect of the main monitor (laptop) and not he screenrect of the monitor the stack is placed upon.

Any idea's ?

regards,

Paul

Re: Take Screenshot on other monitor

Posted: Sat Jan 25, 2025 4:49 pm
by richmond62
Let's suppose that your 3 monitors are arranged as boringly as my 3 monitors:
-
Screenshot 2025-01-25 at 17.44.53.png
-
I have given my monitors (boring) names to make this conversation easier.

When I do this:
-
Screenshot 2025-01-25 at 17.47.24.jpg
-
You will see that the details about monitor LEFT contain a negative number.

Now when I do this sort of thing with a stack displayed on my LEFT monitor I ALSO get a negative number:
-
Screenshot 2025-01-25 at 17.53.01.png

Re: Take Screenshot on other monitor

Posted: Sat Jan 25, 2025 4:59 pm
by Klaus
Dag Paul,

"the working screenrect" (or "the working screenrectS") will not give you any hint where your stack is located!
It will only give you the dimensions of the "usable" screenrect (minus Mac menubar, Mac Dock/Windows Taskbar)
Check if the LOC of your stack is within the screenrects:

Code: Select all

...
put the loc of this stack into tLoc
repeat for each line tRect in the Screenrects
   if tLoc is within tRect then
       return tRect
  end if
end repeat
...
Then take a snapshot of rect tRect as returned from the avbove mentioned function, you get the picture.


Best

Klaus

Re: Take Screenshot on other monitor

Posted: Sat Jan 25, 2025 5:01 pm
by richmond62
So, now if I do this:
-
MyLeftFoot.jpg
-
I get a larger version (reduced to post here) of the image I have just posted.

Now ALL you have to do is wrap the steps I have shown you up into a single buttonScript. 8)
-
Screenshot 2025-01-25 at 18.18.04.jpg
-
Screenshot 2025-01-25 at 18.24.43.jpg

Re: Take Screenshot on other monitor

Posted: Sat Jan 25, 2025 5:28 pm
by richmond62
Screenshot 2025-01-25 at 18.27.04.png

Re: Take Screenshot on other monitor

Posted: Sat Jan 25, 2025 6:39 pm
by richmond62

Re: Take Screenshot on other monitor

Posted: Sun Jan 26, 2025 2:57 pm
by mrcoollion
Thanks guy's !
Got it working as intended.
The intension was:
1) Enable the user to select a monitor to take a snapshot from and identify that monitor
2) If the app is runninig on that same monitor make it invisible for taking the snapshot and after 1 second make it visible again so the app is not in the snapshot.

Humble Regards :wink: ,

Paul

Re: Take Screenshot on other monitor

Posted: Sun Jan 26, 2025 4:03 pm
by mrcoollion
Ooops,

Cheered to soon.. :o
Even with the same code I get a different line for my main monitor that that I get when I move the app around over different monitors. :shock:
The First line in the pulldownmenu should be the same as the shown monitor information the App is on.
ScreeenshotApp_v1.jpg
ScreeenshotApp_v1.jpg (15.38 KiB) Viewed 8384 times

Code: Select all

on preOpenStack
   moveStack
end preOpenStack

------------------------------
on moveStack finalLeft, finalTop
   put the effective working screenRects into tAllScreens
   put the loc of this stack into tLoc
   repeat for each line tRect in the ScreenRects
      if tLoc is within tRect then
         put tRect into tStackRect
      end if
   end repeat
   put tStackRect into fld "IDMonitorWithApp" of card "Main_Card" of this stack
   set the text of button "SelectedMonitor" of card "Main_Card" of this stack to tAllScreens
end moveStack
------------------------------
An in the select button the code is

Code: Select all

Global gTradeAdvisor
local tSelection
on mousedown
// no code
end mousedown

on menuPick tSelection
   set the label of me to tSelection
end menuPick

Re: Take Screenshot on other monitor

Posted: Sun Jan 26, 2025 4:31 pm
by mrcoollion
Found the issue :D
U should have left out 'effective working' from the following statement

Code: Select all

put the effective working screenRects into tAllScreens
This does work.

Code: Select all

put the screenRects into tAllScreens