SFML community forums

Help => Window => Topic started by: Crash47 on November 10, 2010, 10:08:58 pm

Title: [Solved] Mouse and keyboard using.
Post by: Crash47 on November 10, 2010, 10:08:58 pm
Hello.
Can anyone tell me the easiest way to use:

1. Mouse motion simulation.

For example:

Quote
newX = 300
newY = 500

MouseMoveTo(newX,newY)


2. Keyboard presses simulation.

For example:
Quote

newKey = "F3"

Keypress(newKey)
Title: [Solved] Mouse and keyboard using.
Post by: Hiura on November 10, 2010, 11:26:03 pm
You mean creating a virtual event and send it to the OS ? Like emulating the user pressing keys of his keyboard but actually he doesn't ?

Well, you can't do that with SFML only. You have to use OS-specific API.
Title: [Solved] Mouse and keyboard using.
Post by: Groogy on November 10, 2010, 11:38:40 pm
If you do your own system for handling events you can just create a sf::Event instance yourself and pass it trough that. And for really emulating that the cursor has moved, use: http://www.sfml-dev.org/documentation/1.6/classsf_1_1Window.htm#369d1764893c6fde8979fcf04142dc55

NOTE: This will only work internally within your application. No fancy OS things here :P
Title: [Solved] Mouse and keyboard using.
Post by: Crash47 on November 11, 2010, 11:27:06 am
Thanks for help! :)