ASCII code of CTRL button

Discorez

Member
Licensed User
Longtime User
Somebody can to tell, what ASCII code of CTRL key for emulate pressing with Hardware lib?

I need to select all contents the TextBox -
B4X:
   tbValue.Focus
   tbValue.SelectionStart = 0
   tbValue.SelectionStart = StrLength(tbValue.Text)
It dont work

If to emulate to press a Ctrl+A with Hardware lib, that needs to be made so:
B4X:
        tbValue.Focus 'TextBox
   HW.KeyDown(17)
   HW.KeyPress(Asc("A")) 
   HW.KeyUp(17)
17 - is decimal value from hex value 0x11
VK_CONTROL (0x11)
CTRL key
URL from help - click
but it dont work too...
:sign0085: please
 

Discorez

Member
Licensed User
Longtime User
klaus, it dont work - only moves the cursor to last position of a textbox
 

klaus

Expert
Licensed User
Longtime User
I ask my question once again: What do you want to do ?
Can you post your sbp file ?

B4X:
tbValue.SelectionStart = 0
tbValue.SelectionLength = StrLength(tbValue.Text)
Selects the whole text, but unfortunately the text is not highlighted.

In the attached example you can see that with above code the text is selected.

Best regards.
 

Attachments

  • TextBoxGotFocus.sbp
    1.4 KB · Views: 239

Discorez

Member
Licensed User
Longtime User
In the attached example
It work.
Sorry, I find error in my code... It is very shame to me... :signOops:

But there is other question - how to emulate to press a Ctrl-button on keyboard, with Hardware lib?
HardWare.KeyDown(???)
 
Last edited:

klaus

Expert
Licensed User
Longtime User
You use two times tbValue.SelectionStart = in your code!
With your code you set in the first line the start at 0
and in the 2nd line you set the start at the end, the length remains 0.

I use
tbValue.SelectionStart = in the first line
tbValue.SelectionLenght = in the 2nd line

Best regards.
 

Discorez

Member
Licensed User
Longtime User
Klaus, thanks, but I above wrote that code
B4X:
    tbValue.Focus
    HW.KeyDown(17)
    HW.KeyPress(Asc("A")) 
    HW.KeyUp(17)
not work on my device. Why? I somewhere again was mistaken?
 

klaus

Expert
Licensed User
Longtime User
On my device, htc Touch HD, it doesn't work too.
This means that the TextBox Control doesn't support Ctrl A.
If you try to write Ctrl A into a TextBox with the standard keybord on the desktop or with the virtual keyboard on the device nothing happens.
Ctrl X, Ctrl Y, Ctrl V work.

Best regards.
 
Last edited:

Discorez

Member
Licensed User
Longtime User
If you try to write Ctrl A into a TextBox with the standard keybord ..... nothing happens.
Ctrl X, Ctrl Y, Ctrl V work.
Hmm... The very strange restriction...

Klaus, thank for help!

:sign0074:
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…