Comments (13)
Thank you for the report. You wrote "in some games" does that mean that in general it works?
Also Windows makes a difference between Key::Shift
, Key::LShift
and Key::RShift
. All these are different keys. The game might expect one of the other keys.
from enigo.
Thank you for the report. You wrote "in some games" does that mean that in general it works? Also Windows makes a difference between
Key::Shift
,Key::LShift
andKey::RShift
. All these are different keys. The game might expect one of the other keys.
When I use the physical keyboard in the game, it all triggers the skills properly. But using enigo doesn't trigger it.
F1-F12 can't be triggered either.
from enigo.
Can you please open Notepad and then run this slightly changed example
use enigo::{Enigo, Key, KeyboardControllable};
use std::thread;
use std::time::Duration;
fn main() {
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new();
// select all
enigo.key_down(Key::LShift);
println!("Press key");
thread::sleep(Duration::from_secs(5));
enigo.key_up(Key::LShift);
}
Please try to press a letter key on your physical keyboard during the 5 seconds the example sleeps. If the letter is capitalized, we know that the Shift key works in general. Then we know that there must be some special case with the game
from enigo.
Can you please open Notepad and then run this slightly changed example
use enigo::{Enigo, Key, KeyboardControllable}; use std::thread; use std::time::Duration; fn main() { thread::sleep(Duration::from_secs(2)); let mut enigo = Enigo::new(); // select all enigo.key_down(Key::LShift); println!("Press key"); thread::sleep(Duration::from_secs(5)); enigo.key_up(Key::LShift); }
Please try to press a letter key on your physical keyboard during the 5 seconds the example sleeps. If the letter is capitalized, we know that the Shift key works in general. Then we know that there must be some special case with the game
It works fine in Notepad and other editors. But not in Guild Wars 2, I don't know why.
from enigo.
Okay, thank you. That helps already to narrow it down. I probably need some time for this to investigate the issue.
from enigo.
And in-game chatting also works, just not when binding skills.
from enigo.
Maybe the old API to simulate input will work. Could you please try this changed example:
use enigo::{Enigo, Key, KeyboardControllable};
use std::thread;
use std::time::Duration;
use windows::Win32::UI::Input::KeyboardAndMouse::{KEYBD_EVENT_FLAGS, KEYEVENTF_KEYUP, VK_LSHIFT};
fn main() {
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new();
// Simulate a key press
unsafe {
windows::Win32::UI::Input::KeyboardAndMouse::keybd_event(
VK_LSHIFT.0 as u8,
0,
KEYBD_EVENT_FLAGS::default(),
0,
)
};
thread::sleep(Duration::from_millis(20));
// Press other key (Change this if you'd like)
enigo.key_click(Key::Layout('a'));
// Simulate a key release
thread::sleep(Duration::from_millis(20));
unsafe {
windows::Win32::UI::Input::KeyboardAndMouse::keybd_event(
VK_LSHIFT.0 as u8,
0,
KEYEVENTF_KEYUP,
0,
)
};
}
I don't know which other keys you want to press in order to see if Key::LShift works. Feel free to change this part of the example:
// Press other key (Change this if you'd like)
enigo.key_click(Key::Layout('a'));
from enigo.
Maybe the old API to simulate input will work. Could you please try this changed example:
use enigo::{Enigo, Key, KeyboardControllable}; use std::thread; use std::time::Duration; use windows::Win32::UI::Input::KeyboardAndMouse::{KEYBD_EVENT_FLAGS, KEYEVENTF_KEYUP, VK_LSHIFT}; fn main() { thread::sleep(Duration::from_secs(2)); let mut enigo = Enigo::new(); // Simulate a key press unsafe { windows::Win32::UI::Input::KeyboardAndMouse::keybd_event( VK_LSHIFT.0 as u8, 0, KEYBD_EVENT_FLAGS::default(), 0, ) }; thread::sleep(Duration::from_millis(20)); // Press other key (Change this if you'd like) enigo.key_click(Key::Layout('a')); // Simulate a key release thread::sleep(Duration::from_millis(20)); unsafe { windows::Win32::UI::Input::KeyboardAndMouse::keybd_event( VK_LSHIFT.0 as u8, 0, KEYEVENTF_KEYUP, 0, ) }; }
I don't know which other keys you want to press in order to see if Key::LShift works. Feel free to change this part of the example:
// Press other key (Change this if you'd like) enigo.key_click(Key::Layout('a'));
This example also does not trigger any skills that are tied to special keys (Shift and F1-F12 etc...)
I tried to simulate it using Python's Keyboard module and it works fine.
from enigo.
Okay, thank you for trying it out. Back to the drawing board :/
from enigo.
The same issue occurs with the game "Star Citizen"
from enigo.
Apparently it is best to send both, the scan code and the virtual key, in order for all programs to register the key input properly (e.g something like this https://github.com/Narsil/rdev/pull/113/files). Maybe that would solve this issue as well
from enigo.
I created #280, which might address this issue. It would be great if you could test it to see if it fixes it.
from enigo.
Same issue with Ctrl
F1
from enigo.
Related Issues (20)
- Win: Is it necessary to set the MessageExtraInfo? HOT 1
- win: Use an array in `SendInput` to get rid of sleep HOT 2
- Reading key presses HOT 4
- win: Check if alt-gr works
- character sequence manual delay HOT 3
- Inconsistent number of newlines produced by `\n` in `key_sequence` HOT 1
- Is EnigoSettings Unavailable on Windows HOT 2
- Volume up / down doesn't work on MacOS HOT 6
- macOS: Use objc2 instead of objc HOT 3
- Invoking multiple keys at the same time does not seem to register HOT 4
- Selecting text isn't working HOT 3
- `text` seems to miss certain characters, consistently HOT 12
- Support BSDs HOT 4
- State of 0.2 releases HOT 6
- Mouse moves to the wrong coordinates HOT 4
- Choose between xdo and wayland at runtime HOT 1
- Doesn't work as expected in simulation “Ctrl+C" HOT 2
- Screenshot under window does not work HOT 1
- Special characters are not working with ShiftKey
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enigo.