Invoke Virtual Keyboard?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

cmhjon
Posts: 190
Joined: Tue Aug 04, 2015 11:55 am

Invoke Virtual Keyboard?

Post by cmhjon » Wed Oct 20, 2021 3:26 pm

HI all,

I have built a tiny app that runs on some all-in-one Windows 10 touch screen PC's (no physical keyboard or mouse). The app contains a text field and when I tap it to enter some text, I would like to have the PC/Windows virtual keyboard automatically appear (I can invoke it manually by tapping on the keyboard icon in the Windows task tray but I would like eliminate that step if possible). Is there a way to do this?

Thank you,
Jon :)

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Invoke Virtual Keyboard?

Post by Klaus » Wed Oct 20, 2021 3:37 pm

Maybe a simple SHELL command ->

Code: Select all

...
set the hideconsolewindows to TRUE
get shell("osk")
...

cmhjon
Posts: 190
Joined: Tue Aug 04, 2015 11:55 am

Re: Invoke Virtual Keyboard?

Post by cmhjon » Wed Oct 20, 2021 3:50 pm

Hi Klaus,

I tried this and so far, no luck. I put the code into the script of the text field trying both mouseUp and mouseDown. What am I missing?

Thank you so much!
Jon :)

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Invoke Virtual Keyboard?

Post by Klaus » Wed Oct 20, 2021 3:53 pm

Try:

Code: Select all

on openfield
   set the hideconsolewindows to TRUE
   get shell("osk")
end openfield

cmhjon
Posts: 190
Joined: Tue Aug 04, 2015 11:55 am

Re: Invoke Virtual Keyboard?

Post by cmhjon » Wed Oct 20, 2021 4:45 pm

Hi Klaus,

That kind of works. The keyboard automatically appears but nothing happens when I tap any of the keys. Only after I close the keyboard does the text I tapped appear in the text field in my app. The other thing I noticed is that the keyboard that is called by my app is not the same keyboard as the one that appears when I tap the keyboard icon in the Windows task tray. The one called by my app has a black background while the one that appears when tapping the icon in the task tray has a light gray background.

Any other ideas?

Thank you so much!
Jon :)
Last edited by cmhjon on Wed Oct 20, 2021 5:00 pm, edited 1 time in total.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Invoke Virtual Keyboard?

Post by Klaus » Wed Oct 20, 2021 4:54 pm

Hi Jon,

sorry no more brtilliant ideas...


Best

Klaus

cmhjon
Posts: 190
Joined: Tue Aug 04, 2015 11:55 am

Re: Invoke Virtual Keyboard?

Post by cmhjon » Wed Oct 20, 2021 4:59 pm

I think I will add a numeric keypad to it.

Thank you so much for your help!
Jon :)

crokyweb
Posts: 16
Joined: Fri Apr 15, 2022 1:55 pm

Re: Invoke Virtual Keyboard?

Post by crokyweb » Fri Aug 30, 2024 4:13 pm

Klaus wrote:
Wed Oct 20, 2021 3:53 pm
Try:

Code: Select all

on openfield
   set the hideconsolewindows to TRUE
   get shell("osk")
end openfield
I think I have the same problem. I see the cursor flashing in the text field, the virtual keyboard appears with the command get shell("osk") but strangely it does not write in the text field. If I close the virtual keyboard in the text field the characters I had typed before are written in succession. This does not always happen and I can not understand what it could depend on. It seems that it loses focus but I am not sure it is a strange behavior because if I restart everything for a while it works after that it comes back. Any suggestions, ideas? Thanks

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Invoke Virtual Keyboard?

Post by Klaus » Fri Aug 30, 2024 5:21 pm

Sorry, still no brilliant idea after three years...

crokyweb
Posts: 16
Joined: Fri Apr 15, 2022 1:55 pm

Re: Invoke Virtual Keyboard?

Post by crokyweb » Wed Sep 04, 2024 2:30 pm

I have some big problems with adapting a virtual keyboard stack that I found on your forum.

-The first problem is writing the pressed key in a text field located in a different stack than the virtual keyboard.
-The second problem is inserting a pressed RETURN from the virtual keyboard stack always in the text field of another stack
-Third problem inserts the pressed character in the virtual keyboard stack when the blinking cursor is in the text field of another stack about halfway through a word.

If anyone can help me I would be grateful. I attach what I have done so far. I do not understand why the type command does not write to me in the text field in the other stack but writes to me only if the field is present in the same stack of the virtual keyboard. Thanks to all
Attachments
Archivio.zip
(6.11 KiB) Downloaded 261 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10077
Joined: Fri Feb 19, 2010 10:17 am

Re: Invoke Virtual Keyboard?

Post by richmond62 » Thu Sep 05, 2024 12:48 pm

An interesting thought is:

1. Do the desktop operating systems on which LC works have virtual keyboards buried somewhere?

2. If so, can LC somehow invoke them?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Invoke Virtual Keyboard?

Post by dunbarx » Thu Sep 05, 2024 1:59 pm

crokyWeb

I downloaded your stacks. In testieraVirtuale, I noticed that clicking on any of the buttons in the main group throws an error at the line:

Code: Select all

focus on  activeFieldCat
But that variable is empty.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10077
Joined: Fri Feb 19, 2010 10:17 am

Re: Invoke Virtual Keyboard?

Post by richmond62 » Thu Sep 05, 2024 3:26 pm

https://support.apple.com/guide/mac-hel ... 0/mac/11.0

My question is whether LiveCode can invoke this without the machine-user having already turned this on via system settings.
Tip: The Accessibility Keyboard is used for the macOS Keyboard Viewer, which lets you type in different languages when you change input sources. See Use the Keyboard Viewer.
https://forums.developer.apple.com/forums/thread/744835

PeirceEd
Posts: 4
Joined: Fri Mar 15, 2013 7:09 pm

Re: Invoke Virtual Keyboard?

Post by PeirceEd » Fri Sep 06, 2024 8:32 pm

I have found that the following Applescript code can bring the MacOS's Keyboard Viewer into view (tried on MacOS Monterey, Apple M1):

tell application "System Events"
tell process "TextInputMenuAgent"
-- Click the first menu bar item
click menu bar item 1 of menu bar 2
-- Click "Show Keyboard Viewer" in the dropdown menu
click menu item "Show Keyboard Viewer" of menu 1 of menu bar item 1 of menu bar 2
end tell
end tell

put that code into variable tScript and then: do tScript as "AppleScript"
There is a 3-second or so delay between the two clicks for some reason.

To show the Character Palette instead, use the same code but change "Show Keyboard Viewer" into "Show Emoji & Symbols"

You can also call the Character Palette with this other AppleScript code:

tell application "System Events"
if exists (process "CharacterPalette") then
tell application "CharacterPalette" to quit
else
key code 49 using {control down, command down}
end if
end tell

PeirceEd
Posts: 4
Joined: Fri Mar 15, 2013 7:09 pm

Re: Invoke Virtual Keyboard?

Post by PeirceEd » Fri Sep 06, 2024 8:58 pm

Here is the AppleScript code that lists all the menu items pertaining to the Text Input menu on the Mac OS (the menu that shows up on the top right side of the screen when the Keyboard viewer is turned on in the system's preferences):

Code: Select all

tell application "System Events"
	tell process "TextInputMenuAgent"
		try
			set menuItems to every menu item of menu 1 of menu bar item 1 of menu bar 2
			set itemDescriptions to {}
			repeat with menuItem in menuItems
				try
					set end of itemDescriptions to name of menuItem
				on error
					set end of itemDescriptions to "No name"
				end try
			end repeat
			
			-- Display the list of menu items
			set descriptionsText to ""
			repeat with desc in itemDescriptions
				set descriptionsText to descriptionsText & desc & return
			end repeat
			display dialog "Menu Items:" & return & descriptionsText buttons {"OK"} default button "OK"
		on error errMsg
			display dialog "Error listing menu items: " & errMsg buttons {"OK"} default button "OK"
		end try
	end tell
end tell

Post Reply