Forum Archive

About the keyboard function keyboard.get_input_context()

sanmaoban

When I used the keyboard.get_input_context() function, I found that if I input a lot of Chinese characters (more than 5 Chinese characters) in the Google search page box, I found that the keyboard.get_input_context() function can only get the part of the input box I tried to move the cursor and continue to get the characters, but I can’t get any remaining characters. Is there any wise man who can get all the characters in the input box, can you help me answer?

JonB

Do you mean the characters don't show up on the screen? Or that pulling the text doesn't give you everything you can see?

sanmaoban

@JonB said:

Do you mean the characters don't show up on the screen? Or that pulling the text doesn't give you everything you can see?

Sorry, maybe I didn’t express it clearly. I want to write a script to capture the characters I just typed in the Google search box. When I type English characters, the script runs normally, but when I type more than five Chinese characters When writing characters, this script cannot get all the characters. Can you help me find out what went wrong? The script is relatively simple, I put the captured input characters in the variable input_str
import keyboard input_str='' a=keyboard.get_input_context()[0] while (isinstance(a,str)): input_str=a+input_str keyboard.move_cursor(-len(a)) a=keyboard.get_input_context()[0] keyboard.move_cursor(len(input_str))

sanmaoban

@JonB
I am very sorry because my English is not very good,In order to better describe this problem,I want to show this problem with pictures, but I don’t know how to send it to,I posted a photo on Twitter. In the photo, you can see that not all the characters are intercepted. I want to get all the Chinese characters. If it is convenient for you, I hope you can take a look.I used examples\keyboard\ KB Info.py in pythonista,thank youlink twitter url

JeanFreeman

I have an HP laptop that has the same issue. It is a bios thing. I don't have that computer in front of my right now, but let me see if I can get this down from memory.

When you reboot the computer, press F10 (I believe) to get into the bios/startup menu. It looks like an old DOS screen. Scroll horizontally to functions. There will be an option to enable the function keys. If it says 'ON', turn it off. Or vise versa.

Then exit out of that menu and save your changes. Next time you go in to SP things should be back to normal. Unfortunately every time Windows has a major update you will have to do this.

I'll double check these steps tomorrow once I get into the office.

Apart from that I always take help from the sites like wpmtest to test my keyboard commands !