ScreenShot

johnaaronrose
Posts: 22
Joined: Saturday 21st July 2018 12:13pm
Location: Wolverhampton

Re: ScreenShot

Post by johnaaronrose » Tuesday 02nd June 2020 6:24pm

Charlie,

If you run my app, you will see that after the Message Box is clicked the Mouse_Up event is entered again: this is shown by the console output (i.e. it comes up with the Message Box when I click in a point not in a Desktop Window, excluding all of Desktop) when I comment out the Lock & Unlock lines. That's why I put in the Lock & Unlock lines.:
If bWindowSelected Then
    Print "Window Selected"
  Else
    ' Last.Lock
    Application.Busy = 0
    Message.Title = "Try again:"
    Message.Info("Did not click on window.")
    ' Last.Unlock
    Return
  End If
Regarding the 'Lock' situation I think you have the wrong idea about this. Have a look here.
I've already looked at the Help for Lock & Unlock, but they didn't help me! I don't get why I shouldn't use Lock in order to prevent entry to the Mouse_Up coding when the user clicks the Message Box Ok button. Please explain.
After some experimentation we found that the 'Last' is not changed by the 'Message Box' so you don't need the 'Lock' anyway, try the code below. If you did need to store the 'Last' just create a variable to store it in.
(As mentioned before the window below is created with the 'gb' button not the '</>' code button)
Public Sub Button1_Click()
Message.Info("Did not click on window.")
Print Last.name
End
The 'DrawingArea1_MouseUp' routine will not get called again as the MessageBox is not the 'DrawingArea'.
If you run my app, you will see that after the Message Box is clicked the Mouse_Up event (for the DrawingArea object's DrawingAreaDesktop instance) is entered again: this is shown by the console output below (using the </> button as it's not Gambas coding but, questionably, Coding) to prevent entry to the Mouse_Up coding when the user clicks the Message Box Ok button. The only reason that I can think of this happening is re-entry to the Mouse_Up coding when the user clicks the Message Box Ok button.
I've finally remembered to use the 'gb' button when quoting Gambas Coding: reason I forgot to click the gb button on previous posts is that I'm so used to clicking the '</>' button when quoting code (on other forums).

Code: Select all

 _NET_CLIENT_LIST_STACKING(WINDOW): window id # 0x1e0000a, 0x3c00006, 0x3200007, 0x32743bb, 0x32703e2, 0x3600010, 0x2c00001, 0x400000e

0x1e0000a, 0x3c00006, 0x3200007, 0x32743bb, 0x32703e2, 0x3600010, 0x2c00001, 0x400000e

Split
1e0000a
3c00006
3200007
32743bb
32703e2
3600010
2c00001
400000e
Reverse
400000e
2c00001
3600010
32703e2
32743bb
3200007
3c00006
1e0000a
DesktopWindow:  Name=Downloads  VisibleName=Downloads
i=52888546      Hex(i)=32703E2
Id=52888546     Hex(Id)=32703E2
Left=905        Top=151 Width=881       Height=594
DesktopWindow:  Name=Dropbox    VisibleName=Dropbox
i=52904891      Hex(i)=32743BB
Id=52904891     Hex(Id)=32743BB
Left=98 Top=176 Width=1231      Height=874
DesktopWindow:  Name=john@JohnPC: ~     VisibleName=john@JohnPC: ~
i=62914566      Hex(i)=3C00006
Id=62914566     Hex(Id)=3C00006
Left=665        Top=431 Width=734       Height=458
DesktopWindow:  Name=FSelectWindow.class - SelectWindow 0.0.50 - Gambas 3       VisibleName=FSelectWindow.class - SelectWindow 0.0.50 - Gambas
 3
i=67108878      Hex(i)=400000E
Id=67108878     Hex(Id)=400000E
Left=662        Top=86  Width=1204      Height=952
Mouse Position = 505, 1007
Mouse Position = 1130, 609
The first Mouse Position of 505,1007 is actually the place where I clicked (a point where there is no DesktopWindow except the available desktop & full screen ones, which are ignored by my coding). The second Mouse Position of 1130, 609 is actually in the Ok button of the Message Box. When I click the Ok button, I get a popup saying that the a window is already created (in fact it refers to the Message Box) and is generated by this coding in the Mouse_Up event's coding for the SelectWindow class.
Catch
  Message.Warning(ERROR.Text & " at " & ERROR.Where)
There is a 'Break' in your code that is not inside a loop. This generates an error.
You're correct about the Break in the above code: it shouldn't have been there. I actually removed it in the above code.
I noticed this 'aWindow = []' code. You don't need this, if you set up your Array with Dim aWindow as New Window it will be set up as a Dynamic array.
I've never really understood the New keyword usage in Dim or actual code such as 'hDesktopWindow = New DesktopWindow(i)' in this coding (in Form_Open event of SelectWindow class). I used the New keyword in that class's coding because there was a runtime error without it.
Dim hDesktopWindow as DesktopWindow
  For Each i In Desktop.FindWindow(Null, Null, Null)
    hDesktopWindow = New DesktopWindow(i)
I've attached the current state of the app in compressed source. Please decompress it and run the app.
Attachments
SelectWindow.tar.gz
(18.68 KiB) Downloaded 24 times
John

User avatar
cogier
Site Admin
Posts: 487
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: ScreenShot

Post by cogier » Thursday 04th June 2020 4:55pm

Hi John,

Well you are correct and I am not sure what is causing this but I tried out a few ideas and came up with the attached. Note that the MouseUp has been changed to MouseDown and I have created a new 'MessageBox'. I hope it works for you as it took ages to get it to work. I think the problem is that the opaque DrawingArea is over the MessageBox, for some reason, so when you click on the MessageBox button you are clicking on the DrawingArea hence the error. Let me know how you get on.
SelectWindow-0.0.52.tar.gz
(18.91 KiB) Downloaded 24 times

johnaaronrose
Posts: 22
Joined: Saturday 21st July 2018 12:13pm
Location: Wolverhampton

Re: ScreenShot

Post by johnaaronrose » Saturday 06th June 2020 8:20am

Charlie,
Well you are correct and I am not sure what is causing this but I tried out a few ideas and came up with the attached. Note that the MouseUp has been changed to MouseDown and I have created a new 'MessageBox'. I hope it works for you as it took ages to get it to work. I think the problem is that the opaque DrawingArea is over the MessageBox, for some reason, so when you click on the MessageBox button you are clicking on the DrawingArea hence the error. Let me know how you get on.
Your method works fine. However, it's rather complex for what should be solvable by a simpler idea (i.e. using the Lock method). I've emailed Gambas Lists about the Lock method. It will be interesting to see the results. When Benoît looks at these things, he soon spots whether I've got it wrong or whether I have a valid point (e.g. he corrected the coding for the Database object not working after I clarified the problem).

I've just thought of another way round the problem: using the Observe object (as detailed in ). The example on that webpage uses the following coding:
Private $hButton As Button
Private $hObserver As Observer

Public Sub Form_Open()

  $hButton = New Button(Me) As "Button"
  $hButton.Text = "&Click"
  $hButton.Height = 28
  $hButton.Width = 80
  $hObserver = New Observer($hButton) As "Observer"

End

Public Sub Observer_Click()

  Debug "The button has been clicked. I have cancelled the event!"
  Stop Event

End
 
Public Sub Button_Click()

  Debug "If you see me this is a bug!"

End
It does have the merit of not having to create another form to emulate MessageBox! Obviously, the Observe control created has to be 'removed' (yet something else I don't yet know how to do)!
John

johnaaronrose
Posts: 22
Joined: Saturday 21st July 2018 12:13pm
Location: Wolverhampton

Re: ScreenShot

Post by johnaaronrose » Sunday 14th June 2020 7:10am

Charlie,

I tried the Observe object method I alluded to previously. It didn't work due to a quirk (I've forgotten the details: a conglomeration of senior moments),
I've had no reply from anyone (on the Gambas Lists) re the problem with Lock & Unlock.. I don't know if Benoît has looked at that posting of mine. The big thing at the moment on Gambas Lists seems to be running Gambas on Windows using the "Windows Sub-system for Linux" software from Microsoft. If WSL 1 / WSL 2 work properly (though as with all things Microsoft, I don't have full confidence in that), this could dramatically expand the user base for Gambas.
I've uploaded my iRecorder app to the Gambas Farm. It's really slow using the search facility on Gambas Farm. Does Benoît 'control' its server? If so, would you like to ask him to improve its server? I'm assuming that you have direct contact with him.
I'll use your no-form method to do the MessageBox method equivalent in my SelectWindow app. After finishing that, I'll return to finishing my StreamRecorder app, which will incorporate stuff from the SelectWindow app.
John

User avatar
cogier
Site Admin
Posts: 487
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: ScreenShot

Post by cogier » Sunday 14th June 2020 3:19pm

Hi John,
..a conglomeration of senior moments
I know the feeling :?
I've uploaded my iRecorder app to the Gambas Farm. It's really slow using the search facility on Gambas Farm. Does Benoît 'control' its server? If so, would you like to ask him to improve its server? I'm assuming that you have direct contact with him.
Sorry but I have no more contact with Benoît than you do, but I can't find anything wrong with the Farm's speed. Did you look at the link I put up showing what it's like on my computer? Here it is again here

I tried your program. It did not explain that I needed to install 'get-iplayer'. All I got was a message that the directory did not exist. I installed it but I couldn't get a program to play. The program said it had finished playing after a couple of seconds. I tried it on TV and Radio but got the same result. I am in the correct region to get the BBC. The log file says 'Unknown option: player'.

johnaaronrose
Posts: 22
Joined: Saturday 21st July 2018 12:13pm
Location: Wolverhampton

Re: ScreenShot

Post by johnaaronrose » Sunday 14th June 2020 5:42pm

Charlie,
I tried your program. It did not explain that I needed to install 'get-iplayer'. All I got was a message that the directory did not exist. I installed it but I couldn't get a program to play. The program said it had finished playing after a couple of seconds. I tried it on TV and Radio but got the same result. I am in the correct region to get the BBC. The log file says 'Unknown option: player'.
I need to put words about how to install latest get_iplayer in the description of iRecorder on Gambas Farm. I use Ubuntu 18.04 currently (as I'm loath to use anything but LTS of Ubuntu and I wait till the .1 version of LTS Ubuntu is released). The latest version of get_iplayer is at:
https://launchpad.net/~jon-hedgerows/+a ... et-iplayer.
It's now changed to use snap to install it rather than adding a repository. Hopefully the snap version will automatically update get_iplayer, as the BBC occasionally change their server usage and get_iplayer thus has to be updated.
I looked at get_iplayer's coding once and it's horrendous to understand. I would incorporate get_iplayer's usage of the BBC iPlayer's servers if I knew (or could find out) their details.

Here is iRecorder deb again, though I've now found out that it hangs on entry to the form. I'll take a look at the Gambas coding and get back to you:
https://app.box.com/s/3sum82ruwau71bzrejyyc7etqqhcugsq

I think also that there may be a problem with the sound codecs (AAC) on Ubuntu Bionic.

BTW I couldn't work out how to update an on Gambas Farm. Does it do it automatically when you Publish an app again?
John

User avatar
cogier
Site Admin
Posts: 487
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: ScreenShot

Post by cogier » Tuesday 16th June 2020 4:15pm

BTW I couldn't work out how to update an on Gambas Farm. Does it do it automatically when you Publish an app again?
Just publish again. If you use the same version number it will overwrite the original. If you use a later version number both copies will be published as below: -

Image

johnaaronrose
Posts: 22
Joined: Saturday 21st July 2018 12:13pm
Location: Wolverhampton

Re: ScreenShot

Post by johnaaronrose » Thursday 18th June 2020 9:53am

I've emailed Jon Davies (shown below in a text format as not able to attach as eml or txt extension) about problems with get-iplayer (name when installed using snap) / get_iplayer (name when using using Ubuntu repos or launchpad ppa). I've used snap, so iRecorder invokes get-iplayer.
I've uploaded latest version of iRecorder to Gambas Farm.
But until get-iplayer problems resolved, may or may not work at any time.
Jon,

Thanks for your reply. However, I think that there's a fundamental problem with get-iplayer / get_iplayer v3.25 (on snap, which also happens with get_iplayer from your Launchpad ppa).

This console output (with the first 2 ERRORs taking over a minute to appear) demonstrates this:
john@JohnPC:~$ get-iplayer . --refresh --type=TV
get_iplayer v3.25, Copyright (C) 2008-2010 Phil Lewis
This program comes with ABSOLUTELY NO WARRANTY; for details use --warranty.
This is free software, and you are welcome to redistribute it under certain
conditions; use --conditions for details.
INFO: Indexing tv programmes (concurrent)
ERROR: Failed to download BBC Four schedule page (3/3): https://www.bbc.co.uk/schedules/p00fzl6b/2020/w25
ERROR: Connection error: SSL connect attempt failed

If I go to the BBC iPlayer web site (https://www.bbc.co.uk/iplayer using Chromium) it comes up instantly and it's quick to access & play any programme from that web page in a few seconds (e.g. Racism in the Ranks https://www.bbc.co.uk/iplayer/episode/p ... -the-ranks
or Art of Persia Series 1 Episode 1 on BBC4 https://www.bbc.co.uk/iplayer/episode/m ... -episode-1).
I've never had a problem like the above ERRORs until recently.

I'm running Ubuntu Bionic on an 8GB Celeron Barebones NUC and I don't have speed problems with any other apps and Systems Monitor showed 2GB of memory free.

John
07476 041418
01902 331266


On 15/06/2020 15:17, Jon Davies wrote:
> I don't maintain the snap, so even if I could work out what was wrong I wouldn't be able to fix it.
>
> But I tried installing the snap on a fresh install of Ubuntu Focal, and it works perfectly here. Sometimes the BBC website does funny things, sometimes other things go wrong. Suggest you just try again?
>
> Incidentally, gip hasn't been updated since the last build I uploaded to launchpad, so you don't /need/ to switch to the snap just yet.
>
> Jon
>
>
>
>
>
>
> On Mon, 15 Jun 2020 at 11:06, John Rose <john.aaron.rose@gmail.com> wrote:
>
> Jon,
>
> I noticed that get_iplayer is no longer maintained on the Launchpad URL
> of https://launchpad.net/~jon-hedgerows/+a ... et-iplayer
>
> So I uninstalled get_iplayer and installed get-iplayer by using "snap
> install get-iplayer".
>
> However, running "get-iplayer . --force --type=TV" gave errors and it
> kept repeating the errors. I've attached a list of errors generated
> after running get-iplayer for a few minutes. Here's the Terminal output
> showing the first one.
>
> john@JohnPC:~$ get-iplayer . --force --type=TV
> get_iplayer v3.25, Copyright (C) 2008-2010 Phil Lewis
> This program comes with ABSOLUTELY NO WARRANTY; for details use
> --warranty.
> This is free software, and you are welcome to redistribute it under
> certain
> conditions; use --conditions for details.
>
>
>
> INFO: Indexing tv programmes (concurrent)
>
> ERROR: Failed to download BBC Alba schedule page (3/3):
> https://www.bbc.co.uk/schedules/p00fzl67/2020/w20
> ERROR: Connection error: SSL connect attempt failed
>
>
> --
> John
> 07476 041418
> 01902 331266
>
John

johnaaronrose
Posts: 22
Joined: Saturday 21st July 2018 12:13pm
Location: Wolverhampton

Re: ScreenShot

Post by johnaaronrose » Tuesday 23rd June 2020 9:58am

Charlie,
I had a reply, on Gambas User Lists, from Benoît this morning. He said:
It means that you have to do:
Object.Lock(MyDrawingArea)
instead of:
MyDrawingArea.Lock()
So using this method (after removing coding to have a form emulating a MsgBox), that app is now working properly. I'll now be able to move onto my StreamRecorder app: it does recording of a video stream whether desktop screen, window or an area). What a marathon!

I'm corresponding still with Jon Davies (maintainer of get-iplayer) about why my iRecorder app gives connection errors to BBC servers. He's scratching his head at the moment! Could you try downloading the app from the Gambas Farm and see if it runs OK for you?
Attachments
SelectWindow.tar.gz
(18.7 KiB) Downloaded 23 times
John

User avatar
cogier
Site Admin
Posts: 487
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: ScreenShot

Post by cogier » Tuesday 23rd June 2020 2:38pm

Hi John,

I have also been working on this. I think your life would be a lot easier if you used the gb.Desktop component. The details of the open windows, their location and size details are all there for the taking. Just find the open window you want and PictureBoxMain.Picture = hWindow.GetScreenshot(). Have alook at the attached.

I'll look at the other program and report back later...

UPDATE
All I got was "Please Try Again Later as BBC iPlayer Servers Not Responding"
and
Image
Attachments
GrabIt-0.0.1.tar.gz
(11.6 KiB) Downloaded 25 times

Post Reply