adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
530 stars 127 forks source link

Improving the pressKey() method #258

Closed MuriloMir closed 3 years ago

MuriloMir commented 4 years ago

If you want to press a key repeatedly with a time interval then you need to flush the GUI every time you do it. For instance, supposing you want to create a program that keeps pressing F5 to reload a web page every 5 seconds. I tried using the code below and it didn't work until I added the flush function: SyntheticInput fake = SyntheticInput(0); bool forever = true; while (forever) { fake.pressKey(Key.F5, true); fake.pressKey(Key.F5, false); Thread.sleep(5.seconds); }

adamdruppe commented 4 years ago

Just call the flushGui(); function in your own loop, sdpy exposes that for exactly this kind of thing.

Flushing on every call is inefficient in general.

adamdruppe commented 3 years ago

I added a note to the documentation telling about how it needs to be flushed since doing it automatically is often the wrong thing to do. The doc note though should clear it up so gonna close this.