Take Screenshot on other monitor (Solved)

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Take Screenshot on other monitor (Solved)

Post by mrcoollion » Sat Jan 25, 2025 3:28 pm

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
Last edited by mrcoollion on Sun Jan 26, 2025 4:32 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10076
Joined: Fri Feb 19, 2010 10:17 am

Re: Take Screenshot on other monitor

Post by richmond62 » Sat Jan 25, 2025 3:52 pm

I am sorry, I am not near my computer at the moment but I vaguely remember something about screenrects (with an 's').

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Take Screenshot on other monitor

Post by Klaus » Sat Jan 25, 2025 4:24 pm

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

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Take Screenshot on other monitor

Post by mrcoollion » Sat Jan 25, 2025 4:40 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10076
Joined: Fri Feb 19, 2010 10:17 am

Re: Take Screenshot on other monitor

Post by richmond62 » Sat Jan 25, 2025 4:49 pm

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

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Take Screenshot on other monitor

Post by Klaus » Sat Jan 25, 2025 4:59 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10076
Joined: Fri Feb 19, 2010 10:17 am

Re: Take Screenshot on other monitor

Post by richmond62 » Sat Jan 25, 2025 5:01 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10076
Joined: Fri Feb 19, 2010 10:17 am

Re: Take Screenshot on other monitor

Post by richmond62 » Sat Jan 25, 2025 5:28 pm

Screenshot 2025-01-25 at 18.27.04.png
Attachments
VDUs.livecode.zip
Stack.
(1.27 KiB) Downloaded 355 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10076
Joined: Fri Feb 19, 2010 10:17 am

Re: Take Screenshot on other monitor

Post by richmond62 » Sat Jan 25, 2025 6:39 pm


mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Take Screenshot on other monitor

Post by mrcoollion » Sun Jan 26, 2025 2:57 pm

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

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Take Screenshot on other monitor

Post by mrcoollion » Sun Jan 26, 2025 4:03 pm

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 8363 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

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Take Screenshot on other monitor

Post by mrcoollion » Sun Jan 26, 2025 4:31 pm

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

Post Reply