[Gambas-user] Problem with EXEC and GB.Desktop

Jussi Lahtinen jussi.lahtinen at ...626...
Thu Nov 27 01:01:15 CET 2014


Str(ww) should return memory address of the object ww, not window ID!


Jussi

On Thu, Nov 27, 2014 at 1:24 AM, Lewis Balentine <lewis at ...3412...> wrote:

> Oh, I waited long enough. Here is the work around ...
> -----------------
>    WW = Desktop.FindWindow(WindowTitle)
>    ' WW[?] ALWAYS returns an 'out of bounds' error regardless of what
> value "?" is.
>    ' However WW does hold a valid Window ID
>    WorkStr = Str$(WW)
>    ' this gives us a string of the form "(Integer[] 0xc25688)"
>    ' now we need to extract HEX digits and convert them to an integer
>    p = InStr(WorkStr, "0x")
>    WorkStr = Mid(WorkStr, InStr(WorkStr, "0x") + 2)
>    WorkStr = Left(WorkStr, Len(WorkStr) - 1)
>    n = Val("&H" & WorkStr)
> --------------------------------
>
> Regards,
>
> Lewis
>
> P.S.
>
> "Artificial Intelligence is no match for natural stupidity."
>
> I like that :>)
>
> Send Gambas-user mailing list submissions to
>         gambas-user at lists.sourceforge.net
> ------------------------------
>
> Message: 3
> Date: Wed, 26 Nov 2014 13:55:48 -0500
> From: T Lee Davidson <t.lee.davidson at ...626...>
> Subject: Re: [Gambas-user] Problem with EXEC and GB.Desktop
> To: gambas-user at lists.sourceforge.net
> Message-ID: <54762234.4010207 at ...626...>
> Content-Type: text/plain; charset=utf-8; format=flowed
>
> On 11/26/2014 07:45 AM, Lewis Balentine wrote:
> > /' Gambas module file
> > ' uses:
> > '  gb
> > '  gb.desktop
> > '  gb.desktop.x11(automatically selected by gb.desktop)
> > '  gb.image(automatically selected by gb.desktop)
> > '  gb.qt4 (alternates are: gb.gtk, gb.gtk3, gb.gui)
> >
> > Public Sub Main()
> >     Dim S0, S1, S2 As String
> >     Dim ww As Integer[]
> >     Dim n, WinId As Integer
> >
> >     S0 = "/usr/bin/mate-terminal"
> >     S1 = "--title=" & Chr(34) & "Exec Terminal" & Chr(34)
> >     S2 = "DISPLAY=:0.0"
> >     Exec [S0, S1] With [S2]
> >     ' at list 0.25 second delay required between exec and
> Desktop.FindWindow
> >     ' may vary according to hardware
> >     Wait 2
> >     ww = Desktop.FindWindow("Shell Terminal")
> >     n = ww.Count - 1
> >     'WinId is the same as xwininfo id
> >     WinId = ww[n]
> >     WinId = ww[0]
> >     Desktop.ActiveWindow = WinId
> >     Desktop.SendKeys("ls -l \n")
> >     Quit
> > End
> >
> /----------------------------------------------------------------------------------------------------------/
> > /
> >
> > /With ALL component options ww.Count returns 0 although ww[0] holds a
> > valid ID.
> > With ALL component options *ww[0] *generates *?out of bounds? error*..
> > With gb.gui.opengl (select GTK+3) the program crashes at the first line
> > of code.
>
> I think maybe you are not waiting long enough. I have to "Wait 5" (on my
> admittedly slow system) to keep from getting the "out of bounds error".
> When I do that, all works just fine.
>
>
> --
> Lee
> __________
>
> "Artificial Intelligence is no match for natural stupidity."
>
>
>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list