Results 1 to 10 of 10

Thread: on screen keyboard

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    6

    Question

    Hello.
    I am trying to make an on-screen keyboard.
    The idea is:
    The user has the keyboard on screen.
    When a key on the screen keyboard is pressed - the appropriate key press is sent to the control in focus as if it came from the real keyboard.
    This MUST happen without the focus change that usually happens when another control on the screen is pressed.

    so, the question is: how do I have my on screen virtual keyboard acknoladge a mouse click by not receiving the focus, yet sending the right keypress to the control who had the focus?

    If you have win2000 you can see this sort of application under accessories\accesibility\on-screen keyboard.

    Thanks.
    -----------------


  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Well you could use a timer and make a call to GetActiveWindow to store the active window handle. Then when the user click on one of your buttons call SetActiveWindow to restore the other window. When this is done you could just use SendKeys to send the key stroke.

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Wink sample code 4 keyboard ...

    Use the getactivewindow API call as Joacim mentioned explained here

    Sample code 4 virtual heyboard here

    Hope this helps!
    Alex Read

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    Guest
    The GetActiveWindow function retrieves the window handle to the active window associated with the thread that calls the function.

  5. #5
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    Use getforegoundwindow and setforegroundwindow for all programs
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    6

    Thumbs up Getting there!

    Thanks.
    Your answers were very helpful in getting things working.
    some unfilled wishes:

    A. I wish the focus didn't change back and forth. It causes the form which receives the key input to flash with every virtual keystroke, Plus some controls have lostFocus events that I'd rather didn't happen.

    B. I wish I didn't have to use polling to get the active window. Is there another way to get the previously active window handle (without adding code to ever window in the application)?

    C. The GetActiveWindow function only works for windows in my own appllication. What about using the virtual keyboard on other running applications (this is something I might be able to do without..)

    Again - thanks for pointing in the right direction.
    (Though without some more wish filling, I won't be getting very far with this)

    ------


  7. #7
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    for other applications use the GetForegroundWindow to get it and SetForegroundWindow to set it.

    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  8. #8

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    6

    Lightbulb 1 wish down. 2 to go.

    Thanks gwdash.

    Now I get your point.
    Wish C is filled.

    How about A and B. Anyone?


  9. #9
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    You could use SetWindowPos to always show your window on top of all other windows. Even when it's not having the focus.

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    for B

    You could use GetForegroundWindow as well, just have a property that doesn't accept if the foreground window is your window.
    Code:
    Property Get LastWindow()
    static wnd as long
     if getforegroundwindow<>Yourform.hwnd then wnd=GetForegroundWindow 
     lastwindow=wnd
    end property
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width