×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Using Touch keyboard

Using Touch keyboard

Using Touch keyboard

(OP)
Hello,

I would like to use the native Touch keyboard on a touch-screen computer running win8.1 whenever I setfocus to a textbox.

i.e. whenever that textbox gets the focus I would like touch keyboard automatically popup and then dissapear
on LostFocus, without pressing the keyb icon.

Any ideas?

Thank you,
Daniel

RE: Using Touch keyboard

I don't have Windows 8, but I hope these demos would give you some hints.

1. Using a thirty party software
Download a free small virtual keyboard from www.FreeVirtualKeyboard.com

CODE --> Foxpro

Declare Integer ShellExecute In shell32 Integer hWindow, String lpOperation, String lpFile, String lpParameters, String lpDirectory, Integer nShowCmd
Declare Integer SetParent In User32 Integer HWnd, Integer ParenthWnd
Declare Integer FindWindow In user32 String lpClassName, String lpWindowName
Declare Integer GetWindowLong In user32 Integer HWnd, Integer nIndex
Declare Integer SetWindowLong In user32 Integer HWnd, Integer nIndex, Integer dwNewLong
Declare Integer SetFocus In user32 Integer
Declare Integer SetWindowPos In user32 INTEGER HWnd, INTEGER hWndInsertAfter, INTEGER x, INTEGER Y, INTEGER cx, INTEGER cy, INTEGER uFlags
Declare Integer GetWindowThreadProcessId in Win32API Integer hWnd, Integer @lpdwProcessId
Declare Integer OpenProcess in Win32API Integer dwDesiredAccess, Integer bInheritHandle, Integer dwProcessID
Declare Integer TerminateProcess in Win32API Integer hProcess, Integer uExitCode

Clear
Public ofrm
ofrm = Createobject("MyForm")
ofrm.Show()

Define Class MyForm As Form
	Width = 900
	Height=430
	hOsk = 0
	nOskHeight = 200
	ShowWindow = 2
	Desktop = .T.
	AutoCenter = .T.
	Add Object txt1 As TextBox
	Add Object cmd1 As CommandButton With Top = 50 , Caption = "\<Click"
	Add Object txt2 As TextBox WITH top = 100
	Add Object cmd2 As CommandButton With Top = 150 , Caption = "\<Click"
	Add Object tmr As Timer With Interval = 300,Enabled = .F.
	
	PROCEDURE Init
		BINDEVENT(This.txt1,'GotFocus',This,'MyGotFocus')
		BINDEVENT(This.txt2,'GotFocus',This,'MyGotFocus')
		BINDEVENT(This.txt1,'LostFocus',This,'MyLostFocus')
		BINDEVENT(This.txt2,'LostFocus',This,'MyLostFocus')
	PROCEDURE Mygotfocus
		IF ThisForm.hosk = 0
			ThisForm.tmr.Enabled = .T.
		ELSE
			SetWindowPos(ThisForm.hOsk, 0, 0, SYSMETRIC(2)-ThisForm.nOskHeight,SYSMETRIC(1), ThisForm.nOskHeight,  0x0010+0x0040) && move to the bottom of the form and show
		ENDIF
	ENDPROC
	PROCEDURE Mylostfocus
		SetWindowPos(ThisForm.hOsk, 0, 0, SYSMETRIC(2)-ThisForm.nOskHeight,SYSMETRIC(1), ThisForm.nOskHeight,  0x0010+0x0080) && move to the bottom of the form and show
	ENDPROC
	Procedure Load
		= ShellExecute(0, "open", "d:\kit\freevk.exe", "", "", 1) &&& the path can be generalised
	ENDPROC
	
	Procedure tmr.Timer
		LOCAL nStyle
		ThisForm.hOsk = FindWindow (.Null., "Free Virtual Keyboard (www.FreeVirtualKeyboard.com)")
		nStyle = GetWindowLong (ThisForm.hOsk, -16)
		**************************************************************************************************************
		* If you want the keyboard to be embeded in your form
		* uncomment the following 4 lines
		* and in all SetWindowPos() change SYSMETRIC(2) with Thisform.height and SYSMETRIC(1) with Thisform.width
		**************************************************************************************************************
*!*			SetWindowLong (ThisForm.hOsk, -16, Bitset(m.nStyle,30)) && set child
*!*			SetWindowLong (ThisForm.hOsk, -16, Bitclear(m.nStyle,31)) && remove popup
*!*			SetParent(ThisForm.hOsk, Thisform.HWnd) && change parent
*!*			SetWindowLong (ThisForm.hOsk, -16, BITAND(m.nStyle,2^32-1-0xCF0000)) && remove the title bar
		SetWindowPos(ThisForm.hOsk, 0, 0, SYSMETRIC(2)-ThisForm.nOskHeight,SYSMETRIC(1), ThisForm.nOskHeight,  0x0010+0x0040) && move to the bottom of the form and show

		This.Enabled = .F.
	ENDPROC
	PROCEDURE destroy
		LOCAL lnProcessID
		UNBINDEVENTS(This)
		lnProcessID = 0
		GetWindowThreadProcessId(ThisForm.hOsk, @lnProcessID)
		TerminateProcess(OpenProcess(1, 1, m.lnProcessID) , 0)
	ENDPROC
Enddefine 

2. Using osk.exe on a 32bit Windows
Windows XP, 7 and 8 are shifted with On-creen keyboard
On a 32 bit system you can use the above code but execute osk.exe instead freevk.exe, i.e :
= ShellExecute(0, "open", "osk.exe", "", "", 1)
and when search the window, type its caption (if the system is in English)
ThisForm.hOsk = FindWindow (.Null., "On-Screen Keyboard")

3. Using osk.exe on a 64bit Windows
On a 64bit Windows, osk.exe can be launched, but cannot be controlled from within VFP, because VFP is 32 bit and osk.exe is 64bit

CODE --> Foxpro

Declare Integer ShellExecute In shell32 Integer hWindow, String lpOperation, String lpFile, String lpParameters, String lpDirectory, Integer nShowCmd
Declare Integer ShowWindow In user32 Integer hWindow, Integer nCmdShow
DECLARE integer Wow64DisableWow64FsRedirection IN kernel32 Long @
DECLARE integer Wow64RevertWow64FsRedirection IN kernel32 Long @

Public ofrm
ofrm = Createobject("MyForm")
ofrm.Show()

Define Class MyForm As Form
	hwndosk = -1
	ADD OBJECT txt1 as textbox
	ADD OBJECT cm1 as commandbutton WITH top = 50
	ADD OBJECT txt2 as textbox WITH top = 100
	ADD OBJECT cm2 as commandbutton WITH top = 150
	PROCEDURE Load
		LOCAL lnVal
		IF LEN(GETENV("ProgramFiles(x86)"))>1
			xxx=Wow64DisableWow64FsRedirection(lnVal)
		ENDIF
		ThisForm.hwndosk = ShellExecute(0, "open", "osk.exe", "", "", 1)
		IF LEN(GETENV("ProgramFiles(x86)"))>1
			xxx=Wow64RevertWow64FsRedirection(lnVal)
		ENDIF
	ENDPROC
ENDDEFINE 

A detailed discussion can be found here http://www.foxite.com/archives/virtual-keyboard-00...

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close