Sendkey () function

Hi…
In VB or VBA function exists sendKey (). Is there something in Xojo? Or how can simulate keyboard?

Thanks

A direct equivalent does not exist.
What is it you’re trying to accomplish with this ?

Via the serial port to control the application. I need about 6 keys to control the functions of the program.

Don’t have all the code IN the events of the various controls

Write methods that the events in the controls call - then you can control your application by having a serial control simply call the same methods

try: http://www.mbsplugins.eu/RemoteControlPressKey.shtml

The application has shortcuts that are controlled by buttons on the keyboard, such as S-> save, O-> Ok …

I need to write a program that will receive a string from the serial port into a virtual key press S or O, and the application will respond to these strings passed … I hope it is easy to understand.

Sure
I just wouldn’t do that by “pressing keys”

Write a method “SaveToFile”
Then the menu handler for the short cut for Save just called that method
And if you have a serial object listening & it receives the command to save then it calls the same SaveToFile method as well instead of pressing the button to cause the save to happen

It would be easy if the application was written in Xojo. Since it is an older application, there is no other option. The manufacturer offers a similar solution, but it is expensive as it was made ??of gold :slight_smile:

On Mac try AppleScript:

tell application "System Events" tell application "TextEdit" to activate keystroke "S" using command down end tell

Ah so you’re not manipulating a program you wrote but another one.
That wasn’t clear.

Find the Windows Functionality Suite as it has a method that is similar to the VB Sendkeys one
You can incorporate that into your program & do what you’re trying to do

This should work in windows

[code]Class Window1
Inherits Window
wsh As OleObject

Window1 Control PushButton1:
Sub Action()
wsh = new OLEObject(“WScript.Shell”)
Dim np as OLEObject
np = wsh.Run(“notepad”,1)
Timer1.Mode = Timer.ModeSingle
End Sub

Window1 Control Timer1:
Sub Action()
wsh.AppActivate(“Untitled - Notepad”)
wsh.SendKeys(“Hello from Xojo”)
End Sub
End Class[/code]

[quote=43185:@John Hansen]This should work in windows

[code]Class Window1
Inherits Window
wsh As OleObject

Window1 Control PushButton1:
Sub Action()
wsh = new OLEObject(“WScript.Shell”)
Dim np as OLEObject
np = wsh.Run(“notepad”,1)
Timer1.Mode = Timer.ModeSingle
End Sub

Window1 Control Timer1:
Sub Action()
wsh.AppActivate(“Untitled - Notepad”)
wsh.SendKeys(“Hello from Xojo”)
End Sub
End Class[/code][/quote]

Make sure the default settings for Time1:
Timer1.mode = 0 // Off
Timer1.period = 100