Page 1 of 2

Invoke Virtual Keyboard?

Posted: Wed Oct 20, 2021 3:26 pm
by cmhjon
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 :)

Re: Invoke Virtual Keyboard?

Posted: Wed Oct 20, 2021 3:37 pm
by Klaus
Maybe a simple SHELL command ->

Code: Select all

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

Re: Invoke Virtual Keyboard?

Posted: Wed Oct 20, 2021 3:50 pm
by cmhjon
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 :)

Re: Invoke Virtual Keyboard?

Posted: Wed Oct 20, 2021 3:53 pm
by Klaus
Try:

Code: Select all

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

Re: Invoke Virtual Keyboard?

Posted: Wed Oct 20, 2021 4:45 pm
by cmhjon
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 :)

Re: Invoke Virtual Keyboard?

Posted: Wed Oct 20, 2021 4:54 pm
by Klaus
Hi Jon,

sorry no more brtilliant ideas...


Best

Klaus

Re: Invoke Virtual Keyboard?

Posted: Wed Oct 20, 2021 4:59 pm
by cmhjon
I think I will add a numeric keypad to it.

Thank you so much for your help!
Jon :)

Re: Invoke Virtual Keyboard?

Posted: Fri Aug 30, 2024 4:13 pm
by crokyweb
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

Re: Invoke Virtual Keyboard?

Posted: Fri Aug 30, 2024 5:21 pm
by Klaus
Sorry, still no brilliant idea after three years...

Re: Invoke Virtual Keyboard?

Posted: Wed Sep 04, 2024 2:30 pm
by crokyweb
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

Re: Invoke Virtual Keyboard?

Posted: Thu Sep 05, 2024 12:48 pm
by richmond62
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?

Re: Invoke Virtual Keyboard?

Posted: Thu Sep 05, 2024 1:59 pm
by dunbarx
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

Re: Invoke Virtual Keyboard?

Posted: Thu Sep 05, 2024 3:26 pm
by richmond62
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

Re: Invoke Virtual Keyboard?

Posted: Fri Sep 06, 2024 8:32 pm
by PeirceEd
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

Re: Invoke Virtual Keyboard?

Posted: Fri Sep 06, 2024 8:58 pm
by PeirceEd
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