ScreenShot
Posted: Saturday 16th May 2020 3:33pm
Hi guys, here is another of my efforts. Comments welcome.
Code: Select all
DrawingArea1.Clear
Paint.Begin(DrawingArea1)
Paint.LineWidth = 5
Paint.Rectangle(iStartX, iStartY, Mouse..ScreenX - iStartX, Mouse.ScreenY - iStartY)
Paint.Stroke
Paint.End
Code: Select all
Paint.Rectangle(iStartX, iStartY, Mouse..ScreenX - iStartX, Mouse.ScreenY - iStartY)
It is in the Gambas help as I spent some time updating the help on this topic. Have a look here, I wrote a small program to explain its workings which is also available on the Gambas Farm and here.As I wasn't able to find the Mode command (in the Gambas documentation), could you tell me what it (& its argument does)?
Code: Select all
Paint.Rectangle(iStartX, iStartY, Mouse..ScreenX - iStartX, Mouse.ScreenY - iStartY)
Paint.Rectangle(iStartX, iStartY, Mouse..ScreenX - iStartX, Mouse.ScreenY - iStartY)
I looked at my code and there was only one dot, not sure what happened there I created a new Form (Capture) with the Form's Opacity set to 35, Maximized with no Border. This allows the user to draw the rectangle on any part of the screen. When finished (MouseUp) the values are passed back to the FMain Form and the Capture window closed. Then Hide the FMain Form and take the Desktop.Snapshot. Does that help?I last looked at this app 2+ years ago and never got it working. So it's giving me problems! It's quite difficult to work out how to move from the SelectArea form (equivalent of your Capture form) at the form's opening to displaying of the original desktop which has a video (equivalent of your photos display) as part of the available desktop: typically the app's user would have their internet browser open with its window maximised (i.e. covering the available desktop, which doesn't include the launch panel etc), the user would then see a popup requesting press mouse button down when the cursor is at the top left of the video's display, release mouse button when the cursor is at the bottom right of the video's display. So the user would click on the internet browser icon in the launch panel and then do the mouse down, mouse move & mouse up (with the app's code ensuring has the resultant rectangle has its outline redrawn as the mouse moves (but ignoring any mouse position where the right would be to the left of the mouse's down left position or the bottom would be above the mouse's down bottom position).
Could you attach the changed app's tar.gz as I didn't see it in your reply?new Form (Capture) with the Form's Opacity set to 35, Maximized with no Border. This allows the user to draw the rectangle on any part of the screen. When finished (MouseUp) the values are passed back to the FMain Form and the Capture window closed. Then Hide the FMain Form and take the Desktop.Snapshot. ]
Sorry I was not trying to confuse anybody!I didn't notice that the Mode command (first line of Capture Sub) was actually a Public Sub written by you!
Have a look at the attached example.I'm unclear about the meaning of Mouse_Drag. Could you clarify?
I only explained the code provided I have not changed it. Does it not work on your system?Could you attach the changed app's tar.gz as I didn't see it in your reply?
I am looking into this.....I looked at Mouse.X & Mouse.ScreenX and didn't understand the difference between the two: Relative is relative to what? Presumably Absolute is looking at the screen as a whole (i.e. including docks etc)
Have a look at the attached program, hopefully that will help.I looked at Mouse.X & Mouse.ScreenX and didn't understand the difference between the two: Relative is relative to what? Presumably Absolute is looking at the screen as a whole (i.e. including docks etc)
Code: Select all
Private hPicture As Picture
Public Sub Form_Open()
Print "SB"
Inc Application.Busy
hPicture = Desktop.Screenshot(Screen.AvailableX, Screen.AvailableY, Screen.AvailableWidth, Screen.AvailableHeight)
Print "SB1"
Print "Screen X=" & Screen.X & ", Screen Y = " & Screen.Y
Print "Screen AvailableX = " & Screen.AvailableX & ", AvailableY = " & Screen.AvailableY
Print "Screen Width = " & Screen.Width & ", Screen Height = " & Screen.Height
Print "Screen AvailableWidth = " & Screen.AvailableWidth & ", Screen AvailableHeight = " & Screen.AvailableHeight
Print "hPicture Width = " & hPicture.Width & ", hPicture Height = " & hPicture.Height
Last.X = Screen.AvailableX
Last.Y = Screen.AvailableY
Last.Resize(Screen.AvailableWidth, Screen.AvailableHeight)
Print "FSelectArea X = " & FSelectArea.X & ", FSelectArea Y = " & FSelectArea.Y
Print "FSelectArea Left = " & FSelectArea.Left & ", FSelectArea Top = " & FSelectArea.Top
Print "FSelectArea Width = " & FSelectArea.Width & ", FSelectArea Height = " & FSelectArea.Height
DrawingAreaDesktop.Left = Screen.AvailableX
DrawingAreaDesktop.Top = Screen.AvailableY
DrawingAreaDesktop.Width = Screen.AvailableWidth
DrawingAreaDesktop.Height = Screen.AvailableHeight
Print "DrawingAreaDesktop X = " & DrawingAreaDesktop.X & ", DrawingAreaDesktop Y = " & DrawingAreaDesktop.Y
Print "DrawingAreaDesktop Left = " & DrawingAreaDesktop.Left & ", DrawingAreaDesktop Top = " & DrawingAreaDesktop.Top
Print "DrawingAreaDesktop Width = " & DrawingAreaDesktop.Width & ", DrawingAreaDesktop Height = " & DrawingAreaDesktop.Height
Print "SB2"
Paint.Begin(DrawingAreaDesktop)
Print "SB3"
Paint.DrawPicture(hPicture, DrawingAreaDesktop.Left, DrawingAreaDesktop.Top, DrawingAreaDesktop.Width, DrawingAreaDesktop.Height)
Print "SB4"
Paint.End
Code: Select all
SB
SB1
Screen X=0, Screen Y = 0
Screen AvailableX = 67, AvailableY = 27
Screen Width = 1920, Screen Height = 1080
Screen AvailableWidth = 1853, Screen AvailableHeight = 1053
hPicture Width = 1853, hPicture Height = 1053
FSelectArea X = 67, FSelectArea Y = 27
FSelectArea Left = 67, FSelectArea Top = 27
FSelectArea Width = 1853, FSelectArea Height = 1053
DrawingAreaDesktop X = 67, DrawingAreaDesktop Y = 27
DrawingAreaDesktop Left = 67, DrawingAreaDesktop Top = 27
DrawingAreaDesktop Width = 1853, DrawingAreaDesktop Height = 1053
SB2
This is and has been an issue. When you understand something you can create an account and then edit the help pages yourself.still think that the help within Gambas3 when coding a class could be explained better
You need to be careful here as I use the Cinnamon Desktop and my toolbar and System Tray is on the bottom of the screen.The idea is take a screenshot of the available desktop (i.e. the whole of my monitor's screen excluding the top panel (containing the Systray etc,...
This is a nasty one and I don't pretend to fully understand it but if you change the DrawingArea Cached property to True I think you will find that it is OK.When I run the app (using Debug) I get a popup stating 'Cannot Paint outside of Draw event handler'.
I don't know how to create an account: how do I do it? I'm also a little worried that I might get an explanation wrong! How did you find out about Opacity=35?This is and has been an issue. When you understand something you can create an account and then edit the help pages yourself.
I had vaguely thought about that before. I use standard Ubuntu Xenial, with systray panel & launcher panel left in standard positions. Your methods obviously cope with any Ubuntu flavour & I guess even standard Debian etc. ( I might check that out on my Raspberry Pi 3 using Raspbian, which I use for controlling cameras using Motion (much better for me than ZoneMinder), File Server (for all computers on home network), VPN (when I get it working!)).You need to be careful here as I use the Cinnamon Desktop and my toolbar and System Tray is on the bottom of the screen.
I changed the DrawingArea Cached property to True on my app (before incorporating your ideas) and it was OK (i.e. the popup stating 'Cannot Paint outside of Draw event handler' didn't happen).This is a nasty one and I don't pretend to fully understand it but if you change the DrawingArea Cached property to True I think you will find that it is OK.
Why is the 'Arrangement = Vertical' property setting necessary? It's interesting that the Expand property set to True results in filling the (available) desktop rather than the whole screen (i.e. excluding the Systray panel & the Launcher panel): the help is ambiguous about this.For the Form that the user is going to 'draw' the rectangle, set the Form properties:-
Arrangement = Vertical
Border = False
Maximized = True
Opacity = 35
Put your DrawingArea on the Form and set the Expand property to True
With these settings the form and DrawingArea will expand to fill the whole screen (whatever the size). The opacity at 35 allows you to see the Desktop behind.
Have a look at the FMain form settings and layout in the attached then resize the form and you will see that you don't need to write any code to get these results.
Nor me!!I'm not a professional developer:
I have taken this from the Gambas Mailing List 20/05/20 by vuott: -..is it possible to identify Windows in the desktop screenshot?
Public Sub Form_Open()
Dim i As Integer
Dim dw As DesktopWindow
' Gets the ID of all the "windows" open on the desktop:
For Each i In Desktop.FindWindow(Null, Null, Null)
With dw = New DesktopWindow(i)
' Shows the visible name and ID of the Window:
Print .VisibleName, Hex(i)
End With
Next
End
Note I used the 'gb' button to get the formatted code above not the '</>' button.
Experimentation....How did you find out about Opacity=35?
I could have used Horizonal or Fill in this case. Vertical will force all the objects to the top of the form and lay the next item underneath and the next..Why is the 'Arrangement = Vertical' property setting necessary?
Have you seen this book here and here?Gambas really needs a reference manual