[Gambas-user] New to Gambas - coding question how to find the active window on an Ubuntu 7.10 desktop
Khos
kim.hoskin at ...1073...
Sun Jan 20 17:34:46 CET 2008
Hi Jose,
I emailed you direct but if there is anyone else who can provide input that
would be great. Am I correct in thinking that your 2 lines of code:
SHELL "xwininfo -name \"" & title & "\"| grep \"Window id\" " to result1
'result1=xwininfo: Window id: 0x3201eca "title"
Will give me the active window's title on the Ubuntu desktop (any
app/window)?
Does xwininfo program give all the info(ID/Title etc) that the mouse is
hovering over?
Thanks
Kim
José Luis Redrejo wrote:
>
> I'm using this code to do something similar to what you asked, but not
> over
> a text box, but on over a Embedder control. You'll have to use such
> control,
> and maybe use it inserted in a container component with your textbox if
> you
> need the textbox. It works perfectly with qt or gtk components. The only
> pre-requisite is that you have to know the exact window Title of the app
> you
> want to embed:
>
>
> At my Form I have:
>
> PUBLIC SUB Presence_Embed(windowTitle AS String)
> DIM key AS Integer
> key = Utils.getWindowID(windowTitle)
> WAIT 1
> IF key > 0 THEN
> emb.Embed(key)
> WAIT
> emb.SetFocus
> ENDIF
> emb.Visible = TRUE
>
> END
>
>
> And at a Static Class Utils, I use for many other, things I have:
>
> STATIC PUBLIC FUNCTION getWindowID(title AS String) AS Integer
> DIM result1 AS String
> DIM result2 AS String
> DIM beginning AS Integer
>
> SHELL "xwininfo -name \"" & title & "\"| grep \"Window id\" " to result1
> 'result1=xwininfo: Window id: 0x3201eca "title"
> IF result1 = "" THEN
> WAIT 2
> SHELL "xwininfo -name \"" & title & "\"| grep \"Window id\" " to
> result1
>
> ENDIF
> beginning = InStr(result1, "0x")
>
> result2 = Mid$(result1, beginning + 2, 7)
> 'result2 = Mid$(result1, Len("xwininfo: Window id: 0x"),
> Len("3a00003"))
> IF NOT IsNull(result2) THEN
> RETURN CInteger(Val("&H" & result2))
> ELSE
> RETURN 0
> ENDIF
>
> END
>
>
>
> I think the code is pretty self-explained. If not don't hesitate in asking
> any question.
> Regards.
> José L.
>
>
>
>
>
>
>
> 2008/1/20, Khos <kim.hoskin at ...1073...>:
>>
>>
>>
>>
>> Khos wrote:
>> >
>> > Hi,
>> >
>> > I am quite new to Ubuntu and Gambas worlds but wanted to ask you a
>> > Gambas (which seems to be a such a brilliant piece of software by the
>> > way) coding related question. Hope you won't mind helping me out. How
>> > would I be able to find an active window's caption of any window on the
>> > Ubuntu desktop to show it in a text box on my Gambas created
>> > application?
>> >
>> > I apologize if I sent this in error to the wrong group but hope you
>> could
>> > point me in
>> > the right direction or provide some sample code.
>> >
>> > Many thanks,
>> > Kim
>> >
>>
>> Hi, Anyone have any advise for me? please help :)
>> --
>> View this message in context:
>> http://www.nabble.com/New-to-Gambas---coding-question-how-to-find-the-active-window-on-an-Ubuntu-7.10-desktop-tp14931902p14981935.html
>> Sent from the gambas-user mailing list archive at Nabble.com.
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Microsoft
>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
--
View this message in context: http://www.nabble.com/New-to-Gambas---coding-question-how-to-find-the-active-window-on-an-Ubuntu-7.10-desktop-tp14931902p14983556.html
Sent from the gambas-user mailing list archive at Nabble.com.
More information about the User
mailing list