It is possible to have a virtual keyboard in PB such as
'Free Virtual Keyboard on
https://freevirtualkeyboard.com, among others?
My main question is how to send the pressed key to the active field of any application.
My thanks in advance to anyone who devotes some time to this matter.
Virtual Keyboard
Re: Virtual Keyboard
Have a look at my post signature:
PB-CodeArchiv-Rebirth/Keyboard_Mouse/SimulateKeyboardMouseInputs.pbi
PB-CodeArchiv-Rebirth/Keyboard_Mouse/SimulateKeyboardMouseInputs.pbi
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Re: Virtual Keyboard
Thank you very much Sicro.
But I think that I can't solve the problem with that software.
The clicked key must go to the application that has the focus at the moment of the click.
Thanks.
But I think that I can't solve the problem with that software.
The clicked key must go to the application that has the focus at the moment of the click.
Thanks.
Re: Virtual Keyboard
The trick now is to create a virtual keyboard window that doesn't steal focus from other windows.
Here is a code that creates a virtual keyboard with the letter keys "a" and "b":
Code: Select all
IncludeFile "Path to PB-CodeArchiv-Rebirth/Keyboard_Mouse/SimulateKeyboardMouseInputs.pbi"
Enumeration Window
#Window_Main
EndEnumeration
Enumeration Gadget
#Button_a
#Button_b
EndEnumeration
If Not OpenWindow(#Window_Main, 0, 0, 160, 100, "Virtual Keyboard")
Debug "Error: OpenWindow"
End
EndIf
; Prevent the window from being activated (getting the focus)
exStyle = GetWindowLong_(WindowID(#Window_Main), #GWL_EXSTYLE)
SetWindowLong_(WindowID(#Window_Main), #GWL_EXSTYLE, exStyle | #WS_EX_NOACTIVATE)
; Set window always on top of all other open windows
StickyWindow(#Window_Main, #True)
ButtonGadget(#Button_a, 15, 20, 50, 50, "a")
ButtonGadget(#Button_b, 95, 20, 50, 50, "b")
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Gadget
Select EventGadget()
Case #Button_a
Simulate::ComputerKey('A', #True)
Simulate::ComputerKey('A', #False)
Case #Button_b
Simulate::ComputerKey('B', #True)
Simulate::ComputerKey('B', #False)
EndSelect
EndIf
Until event = #PB_Event_CloseWindow
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Re: Virtual Keyboard
You're right Sicro.
The solution was in your module.
This was the big problem "The trick now is to create a virtual keyboard window that doesn't steal focus from other windows"
My big thanks to you.
The solution was in your module.
This was the big problem "The trick now is to create a virtual keyboard window that doesn't steal focus from other windows"
My big thanks to you.
Re: Virtual Keyboard
(PureBasic 5.73,Win 10, Portuguese keyboard)
With the code below I get Ã.
But the Chr(191)="¿" and Chr(126)="~".
Is it possible to match the character that the key displays and the Sendinput function?
Thank you
With the code below I get Ã.
But the Chr(191)="¿" and Chr(126)="~".
Is it possible to match the character that the key displays and the Sendinput function?
Thank you
Code: Select all
OpenWindow(0, 0, 0, 300,200, "Virtual Keyboard")
ButtonGadget(10, 15, 55, 50, 30,"Test")
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_NOACTIVATE)
; Set window always on top of all other open windows
StickyWindow(0, #True)
Debug "Tilde= "+Asc("~"); =126
Debug "Chr(191)= "+Chr(191); = ¿
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case 10
TipTap.INPUT
TipTap\Type = #INPUT_KEYBOARD
TipTap\ki\wVk =191
TipTap\ki\dwFlags = 0
SendInput_(1, @TipTap, SizeOf(INPUT))
; TipTap\ki\wVk = 191
TipTap\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @TipTap, SizeOf(INPUT))
TipTap\ki\wVk = #VK_LSHIFT
TipTap\ki\dwFlags = 0
SendInput_(1, @TipTap, SizeOf(INPUT))
TipTap\ki\wVk ='A'
TipTap\ki\dwFlags = 0
SendInput_(1, @TipTap, SizeOf(INPUT))
; TipTap\ki\wVk = 'A'
TipTap\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @TipTap, SizeOf(INPUT))
TipTap\ki\wVk = #VK_LSHIFT
TipTap\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @TipTap, SizeOf(INPUT))
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow
Re: Virtual Keyboard
Try this code:
Code: Select all
IncludeFile "Path to PB-CodeArchiv-Rebirth/Keyboard_Mouse/SendKeys[Win].pbi"
OpenWindow(0, 0, 0, 300,200, "Virtual Keyboard")
ButtonGadget(10, 15, 55, 50, 30,"Test")
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_NOACTIVATE)
; Set window always on top of all other open windows
StickyWindow(0, #True)
Debug "Tilde= "+Asc("~"); =126
Debug "Chr(191)= "+Chr(191); = ¿
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case 10
SendKeys(Chr(191) + "A")
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Re: Virtual Keyboard
Hello Sicro.
It works. Now I can send the ascii code of the key that the result matches.
Thank you for the help.
It works. Now I can send the ascii code of the key that the result matches.
Thank you for the help.
Re: Virtual Keyboard
Glad to hear it. Then I know why it didn't work with the other module and can fix it.
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version