Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] Mouse and keyboard using.  (Read 2356 times)

0 Members and 1 Guest are viewing this topic.

Crash47

  • Newbie
  • *
  • Posts: 6
    • View Profile
[Solved] Mouse and keyboard using.
« 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)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
[Solved] Mouse and keyboard using.
« Reply #1 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.
SFML / OS X developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
[Solved] Mouse and keyboard using.
« Reply #2 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
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Crash47

  • Newbie
  • *
  • Posts: 6
    • View Profile
[Solved] Mouse and keyboard using.
« Reply #3 on: November 11, 2010, 11:27:06 am »
Thanks for help! :)