Forums


Comfort Software :: Forums :: Development
<< Previous thread | Next thread >>   

How to show/close/fade the On-Screen Keyboard

Go to page       >>  
Author Post
Comfort
Fri Oct 19 2007, 03:20am


Joined: Wed Sep 19 2007, 03:42pm
Posts: 545
You can use Window Messages to manipulate the on-screen keyboard.

http://www.comfort-software.com/keyboard/help/manipulatekeyboard.htm

Like this:

WM_CSKEYBOARD = WM_USER + 192;

PostMessage(FindWindow('TFirstForm', 'CKeyboardFirstForm'), WM_CSKEYBOARD, 1, 0); - to show keyboard
PostMessage(FindWindow('TFirstForm', 'CKeyboardFirstForm'), WM_CSKEYBOARD, 2, 0); - to close keyboard
PostMessage(FindWindow('TFirstForm', 'CKeyboardFirstForm'), WM_CSKEYBOARD, 3, 0); - to fade keyboard

Here is a program that can do this: http://www.comfort-software.com/download/ManipulateKB.zip

Also you can find Sample Code for other language in help file.

If you can't use Windows Messages then download and try these files:
http://www.comfort-software.com/download/ShowKB.exe
http://www.comfort-software.com/download/HideKB.exe
http://www.comfort-software.com/download/ToggleKB.exe


[ Edited Thu Sep 04 2014, 02:47pm ]

Have a nice day
Back to top
Kevin
Tue Jan 08 2008, 12:38pm
Registered Member #42
Joined: Tue Jan 08 2008, 11:41am
Posts: 2
I really like your on-screen keyboard. I am working on a proof of concept for my company. I'm having a difficult time getting the keyboard to show/hide via the Windows Messages. I'm developing a winforms C# kiosk application. An example of how to implement this would be most helpful... Thanks
Back to top
Comfort
Tue Jan 08 2008, 01:11pm


Joined: Wed Sep 19 2007, 03:42pm
Posts: 545
I cannot write example for C#. Maybe somebody else?
Here is 2 main functions from WinAPI:
  • PostMessage
  • FindWindow

You can find description of these functions in help.

-------------------
For example, for Visual Basic it looks like this:

Private Const WM_CSKEYBOARD = WM_USER + 192

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

‘Code to show keyboard
Dim hWnd As Long
hWnd = FindWindow(“TFirstForm”, “CKeyboardFirstForm”)
PostMessage hWnd, WM_CSKEYBOARD, 1, 0

‘Code to close keyboard
Dim hWnd As Long
hWnd = FindWindow(“TFirstForm”, “CKeyboardFirstForm”)
PostMessage hWnd, WM_CSKEYBOARD, 2, 0
-------------------


Have a nice day
Back to top
Kevin
Tue Jan 08 2008, 01:58pm
Registered Member #42
Joined: Tue Jan 08 2008, 11:41am
Posts: 2
Thanks for your quick reply ... you got me headed in the right direction.

Here is the code in C# (almost exactly as you describe in VB)

public const Int32 WM_USER = 1024;
public const Int32 WM_CSKEYBOARD = WM_USER + 192;

[DllImport("user32.dll", EntryPoint = "FindWindow")]
private static extern Int32 FindWindow(string _ClassName, string _WindowName);

[DllImport("User32.DLL")]
public static extern Boolean PostMessage(Int32 hWnd, Int32 Msg, Int32 wParam, Int32 lParam);


Int32 hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm");
PostMessage(hWnd, WM_CSKEYBOARD, 1, 0 ); // Show
PostMessage(hWnd, WM_CSKEYBOARD, 2, 0); // Hide


Now that I have that working... I've got a couple more questions -

1 - Is there a way to position the keyboard without any user intervention? Would i do this through an API call? I kind a new at the API interface - please bare with me.

2- Is there a way to disable/hide/remove the close and autohide icons?

Thank You - you have been most helpful!
Back to top
Comfort
Wed Jan 09 2008, 08:02am


Joined: Wed Sep 19 2007, 03:42pm
Posts: 545
1. Please, download new beta version: http://www.comfort-software.com/beta/kb_setup.exe
In this version you can also use Window Messages to move the on-screen keyboard.

Like this:
-----------------
WM_CSKEYBOARDMOVE = WM_USER + 193;

PostMessage(FindWindow('TFirstForm', 'CKeyboardFirstForm'), WM_CSKEYBOARDMOVE, Left, Top);
----------------------------
Left, Top - new position

2. You can restrict access: http://www.comfort-software.com/forum-t49.html

Have a nice day
Back to top
Miguel
Thu Jan 17 2008, 12:15pm
Registered Member #46
Joined: Thu Jan 17 2008, 10:16am
Posts: 2
Hi,
I was wondering if it is possible to use the code
PostMessage(FindWindow('TFirstForm', 'CKeyboardFirstForm'), WM_CSKEYBOARD, 1, 0);
and get the autohide to work correctly?

I am trying to use the On-Screen Keyboard on a touchscreen without a keyboard.
The computer is used in a tourism office with a web page (IExplorer in full screen) .
I wanted to make the on-screen keyboard visible when the user enters a text field (used to search) but hide it if the users does not "type" anything in a couple of seconds.

Thanks
Back to top
Comfort
Fri Jan 18 2008, 06:57am


Joined: Wed Sep 19 2007, 03:42pm
Posts: 545
Please, use two messages together:

PostMessage(FindWindow('TFirstForm', 'CKeyboardFirstForm'), WM_CSKEYBOARD, 1, 0);
PostMessage(FindWindow('TFirstForm', 'CKeyboardFirstForm'), WM_CSKEYBOARD, 3, 0);

Have a nice day
Back to top
Miguel
Tue Jan 22 2008, 07:14pm
Registered Member #46
Joined: Thu Jan 17 2008, 10:16am
Posts: 2
Thanks, that worked!
The problem was that I thought that "Fade" was "start to fade and dissapear NOW"
Back to top
Mads Pedersen
Mon Jan 28 2008, 05:14am
Registered Member #50
Joined: Mon Jan 28 2008, 05:00am
Posts: 2
Hi,
We are using the On-Screen Keyboard and WM_CSKEYBOARD to show and hide the keyboard from our application. It works great.

Is there a way to toggle the keyboard (not shown to shown and vice versa)? Or to find out if the keyboard is shown via a .NET or WIN32 call?
The case is that the user can push the "X" on the keyboard to hide it, as well as a button in our application can toggle the keyboard. This means that if the user pushes "X", our application comes out of sync, as it thinks the keyboard is shown and consequently hides it (again).

Thank you in advance,
Mads Pedersen
Back to top
Comfort
Mon Jan 28 2008, 07:03am


Joined: Wed Sep 19 2007, 03:42pm
Posts: 545
Mads Pedersen wrote ...

Is there a way to toggle the keyboard (not shown to shown and vice versa)? Or to find out if the keyboard is shown via a .NET or WIN32 call?
The case is that the user can push the "X" on the keyboard to hide it, as well as a button in our application can toggle the keyboard. This means that if the user pushes "X", our application comes out of sync, as it thinks the keyboard is shown and consequently hides it (again).


Please, download new beta version and use this command:
PostMessage(FindWindow('TFirstForm', 'CKeyboardFirstForm'), WM_CSKEYBOARD, 4, 0);

But I recommend you restrict access: http://www.comfort-software.com/forum-t49.html

Also, in new beta you can use new option Hide the icon in the system tray. It may be useful for you.

Have a nice day
Back to top
Mads Pedersen
Mon Jan 28 2008, 09:59am
Registered Member #50
Joined: Mon Jan 28 2008, 05:00am
Posts: 2
Thanks for the quick response!

The toggle functionality (WM_CSKEYBOARD, 4) works perfectly .
In our application, it is still fine if the user could move the keyboard around the screen (could be nice if only the "X" could be restricted).

Otherwise the toggle function is great. You mention that it is a beta version. Should we wait to ship that version until it is stable? Have you got an idea of when it is released?

Also great that the systray icon can be hidden.

Thank you!
Back to top
Comfort
Tue Jan 29 2008, 03:36am


Joined: Wed Sep 19 2007, 03:42pm
Posts: 545
Last beta version is stable enough. You can use it.

Have a nice day
Back to top
bhaumikgadani
Sat Mar 08 2008, 03:55am
Registered Member #76
Joined: Sat Mar 08 2008, 03:12am
Posts: 1
hi i have download the keyboard.
and i want to use it in kiosk application in vb6(winxp). i have made the programme for that
by reading online docs.. i m not expert in vb6,
i want to show the keyboard when form active,,,

for that i have add module and paste following code in that

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const WM_CSKEYBOARD = 1280

and i have add form and paste following code in it in form load event

Dim hWnd As Long

hWnd = FindWindow(“TFirstForm”, “CKeyboardFirstForm”)
PostMessage hWnd, WM_CSKEYBOARD, 1, 0

its show the error of PostMessage - sub or function not defined....

i searched a lot online but didnt get so please can anyone tell the solution for the same.
and after solving it , is it show the keyboard? if not show than please can u tell me where we
have to put code so it will run perfectly...

thanks in advance.

Regards
bhaumik
Back to top
Comfort
Sat Mar 08 2008, 09:30am


Joined: Wed Sep 19 2007, 03:42pm
Posts: 545
I think this code may help you: here

[ Edited Wed Mar 12 2008, 01:29am ]

Have a nice day
Back to top
lhearin
Wed Mar 18 2009, 12:36pm
Registered Member #272
Joined: Wed Mar 18 2009, 12:24pm
Posts: 1
A suggestion for your implementation:

You should use really use WM_APP as your base message number instead of WM_USER. Microsoft makes use of WM_USER + n for many internal messages so it can cause operational issues if there is a conflict. Originally anything above WM_USER was for developers to use but Microsoft ran out of messages below that for their own use. That's why they created WM_APP. They won't use any internal message above that. Even using WM_APP as your base is not foolproof. It would be better still to use a registered Windows message. See the article at http://www.flounder.com/messages.htm.
Back to top
Go to page       >>  
Moderators: Comfort

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System