Sorry fo late reply,

> You can't if you don't have the focus. What you need is a global shortcut, 
> which is managed by your desktop environment, or a special program. 
>
> For example, in KDE, there is a control panel entry for configuring them.
>   

Yes, you are right.
But I'm looking for a window manager (or desktop environment) 
independent way.

So I start to write a test program using Xlib with EXTERN declaration 
like this.

' Gambas module file
EXTERN XOpenDisplay(DpyName AS String) AS Pointer IN "libX11"
EXTERN XDefaultScreen(Display AS Pointer) AS Integer IN "libX11"
EXTERN XDefaultRootWindow(Display AS Pointer) AS Integer IN "libX11"
EXTERN XSelectInput(Display AS Pointer, Window AS Integer, KeyMask AS 
Long) IN "libX11"
EXTERN XNextEvent(Display AS Pointer, XEvent AS Pointer) IN "libX11"
EXTERN XGrabKey(Display AS Pointer, KeyCode AS Integer, Modifiers AS 
Integer, Window AS Pointer, OwnEvent AS Boolean, PointerMode AS Integer, 
KeyboardMode AS Integer) IN "libX11"

PUBLIC SUB Main()

    DIM pDisplay AS Pointer
    DIM pRootWindow AS Pointer
    DIM pEvent AS Pointer

    pDisplay = XOpenDisplay("")
    pRootWindow = XDefaultRootWindow(pDisplay)
    XSelectInput(pDisplay, pRootWindow, 1)              '1 = KeyPressMask
    XGrabKey(pDisplay, 95, 0, pRootWindow, FALSE, 1, 1) '95 = F11 key, 
1=GrabModeAsync
    DO
        XNextEvent(pDisplay, pEvent)
        PRINT ("Key F11 Pressed")
    LOOP
END

When F11 Key, keycode is 95 on my japanese keyboard, is pressed,
It should print the message. But actually program exit with signal 11.

Any comments or suggestions are wlecome.

Regards,

-- 
--------------------------------------
Kazutaka HARADA
  e-mail:[email protected]
--------------------------------------


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gambas-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to