GetAsyncKeyState
GetAsyncKeyState
I wrote an application in c++ which should return the GetAsyncKeyState(0x01). But I always get 0. If I click on the window of my app,I will get the right answer. GetAsyncKeyState should return systemwide clicks! The same things happens when I write a VB application.
I found an app written in Delphi which uses the GetAsyncKeyState call and returns systemwide clicks. Can someone tell me whats the reason? And how can I fix this.
THX
I tried wine-0.9.59 and wine-0.9.60
I found an app written in Delphi which uses the GetAsyncKeyState call and returns systemwide clicks. Can someone tell me whats the reason? And how can I fix this.
THX
I tried wine-0.9.59 and wine-0.9.60
GetAsyncKeyState
On Thu, May 8, 2008 at 5:51 AM, bdevel <[email protected]> wrote:
I wrote an application in c++ which should return the GetAsyncKeyState(0x01). But I always get 0. If I click on the window of my app,I will get the right answer. GetAsyncKeyState should return systemwide clicks! The same things happens when I write a VB application.
Even when run in Wine?I found an app written in Delphi which uses the GetAsyncKeyState call and returns systemwide clicks.
Yes. In vmware the apps I wrote returning systemwide mouseclicks!
And as I said the Delphi app returns in wine systemwide mouseclicks. I tried hook too with the same results.
I can post an example sourcecode but everyone knows how to call the GetAsyncKeyState function.
printf("Mouse state %08X\n",GetAsyncKeyState(0x01)); // for example
And as I said the Delphi app returns in wine systemwide mouseclicks. I tried hook too with the same results.
I can post an example sourcecode but everyone knows how to call the GetAsyncKeyState function.
printf("Mouse state %08X\n",GetAsyncKeyState(0x01)); // for example
Last edited by bdevel on Thu May 08, 2008 8:10 am, edited 1 time in total.
GetAsyncKeyState
On Thu, May 8, 2008 at 6:01 AM, bdevel <[email protected]> wrote:
WINEDEBUG=+relay
to see what they're doing differently.
Then try running both it and your app withYes.... the Delphi app reeturns in wine systemwide mouseclicks.
WINEDEBUG=+relay
to see what they're doing differently.
Re: GetAsyncKeyState
It's a long known problem. And you can't fix it without modifying Wine and X server. Wine can not know what keys are pressed outside of programs' window.bdevel wrote:I found an app written in Delphi which uses the GetAsyncKeyState call and returns systemwide clicks. Can someone tell me whats the reason? And how can I fix this.
See http://bugs.winehq.org/show_bug.cgi?id=5623 for more info.
GetAsyncKeyState
On Thu, May 8, 2008 at 6:19 AM, bdevel <[email protected]> wrote:
WINEDEBUG=+relay
export WINEDEBUG
wine AsyncKeyTest.exe
unset WINEDEBUG
or, more concisely,
WINEDEBUG=+relay wine AsyncKeyTest.exe
Vitamin's probably right, i.e. we don't believe the delphi app
actually does what you claim.
But what the heck, if it does, +relay will tell you what it's doing.
It's an environment variable. Either you can dowine AsyncKeyTest.exe WINEDEBUG=+relay doesn't return anything. Could you please explain how I should use the WINEDEBUG=+relay command.
WINEDEBUG=+relay
export WINEDEBUG
wine AsyncKeyTest.exe
unset WINEDEBUG
or, more concisely,
WINEDEBUG=+relay wine AsyncKeyTest.exe
Vitamin's probably right, i.e. we don't believe the delphi app
actually does what you claim.
But what the heck, if it does, +relay will tell you what it's doing.
GetAsyncKeyState
vitamin skrev:
ought to be sufficient.
Pff. Why would you need to modify X server? Using existing XQueryKeymapbdevel wrote:It's a long known problem. And you can't fix it without modifying Wine and X server. Wine can not know what keys are pressed outside of programs' window.I found an app written in Delphi which uses the GetAsyncKeyState call and returns systemwide clicks. Can someone tell me whats the reason? And how can I fix this.
ought to be sufficient.
GetAsyncKeyState
On Thu, May 8, 2008 at 6:29 AM, bdevel <[email protected]> wrote:
We don't believe it can. But hey, we could be wrong.But why the Delphi app can do this while it runs in wine?
Re: GetAsyncKeyState
Well I guess one could use this to query the keyboard state, However like with mouse (GetCursorPos -> XQueryPointer) there are might be some issues.Ove Kaaven wrote:vitamin skrev:Pff. Why would you need to modify X server? Using existing XQueryKeymapbdevel wrote:It's a long known problem. And you can't fix it without modifying Wine and X server. Wine can not know what keys are pressed outside of programs' window.I found an app written in Delphi which uses the GetAsyncKeyState call and returns systemwide clicks. Can someone tell me whats the reason? And how can I fix this.
ought to be sufficient.
GetAsyncKeyState
On Thu, May 8, 2008 at 7:34 AM, bdevel <[email protected]> wrote:
Better source is http://bugs.winehq.org/show_bug.cgi?id=7874 which points to
http://www.easyuo.com/cheffe/asynckeytest.zip and also lists a code
fragment showing how it's implemented.
That test program doesn't work for me in Wine unless it has the focus,
which kind of defeats the purpose. So I'm not sure what you're talking about
when you say it works in Wine.
That's a scary url.Here is the Delphi app.
Better source is http://bugs.winehq.org/show_bug.cgi?id=7874 which points to
http://www.easyuo.com/cheffe/asynckeytest.zip and also lists a code
fragment showing how it's implemented.
That test program doesn't work for me in Wine unless it has the focus,
which kind of defeats the purpose. So I'm not sure what you're talking about
when you say it works in Wine.
GetKeyState() is what you should use. Getting "global" key states are bad. If you really have to do that, then you doing something really wrong.bdevel wrote:Ok then show me a better solution to get the keystates. But I think this bug has to be fixed.vitamin wrote: Or better then that don't use GetAsyncKeyState - it's a really bad thing to relay on.
I realy love wine (because i can play allmost every windows game). But this bug drives me crazy!
Also patches are welcome. That bug won't be fixed any time soon. So you better fix your program instead.
DO NOT post that app here, it will be removed
GetAsyncKeyState
Am 08.05.2008 um 15:26 schrieb vitamin:
that bad.
Markus
- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/
Some people would see a feature here. Some gentle sandboxing isn'tWine can not know what keys are pressed outside of programs' window.
that bad.
Markus
- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/
GetAsyncKeyState
On Thursday May 8 2008 17:09:28 vitamin wrote:
example, Mousotron really needs this to be fixed to be fully usable. Today, it
only can "see" mouse motion (globally in the X server) but not mouse/keyboard key presses (outside of its window).
There is some other real-world examples...
Unfortunately this is unlikely to be fixed anytime soon because of some technical difficulties.
Actually sometimes there is valid reasons for getting global key states. ForGetting "global" key states are bad.
If you really have to do that, then you doing something really wrong.
example, Mousotron really needs this to be fixed to be fully usable. Today, it
only can "see" mouse motion (globally in the X server) but not mouse/keyboard key presses (outside of its window).
There is some other real-world examples...
Unfortunately this is unlikely to be fixed anytime soon because of some technical difficulties.
Re: GetAsyncKeyState
The stuff that "needs" global key events called "key logger".L. Rahyen wrote:On Thursday May 8 2008 17:09:28 vitamin wrote:Actually sometimes there is valid reasons for getting global key states. ForGetting "global" key states are bad.
If you really have to do that, then you doing something really wrong.
example, Mousotron really needs this to be fixed to be fully usable.
If something _needs_ those events, they should use LL_HOOKs (keyboard and mouse). Constantly polling GetAsyncKeyState() doesn't guarantee anything and is a really bad practice. It's even bad to use that function to check state of the keys at any given point of time.
GetAsyncKeyState
On Friday May 9 2008 23:30:36 vitamin wrote:
it doesn't log anything (it even lacks statistical logging). In real world
this program is useful to see how much text you wrote today or how actively
you used your mouse.
really care about good design or good practice. BTW, I'm not sure how exactly
Mousotron works (I didn't actually tried to debug it) so therefore I'm not
sure does it uses this function or not; I just think that there is might be a
such possibility.
Not necessary. In my example, - Mousotron, - collects number of keypresses,L. Rahyen wrote:The stuff that "needs" global key events called "key logger".On Thursday May 8 2008 17:09:28 vitamin wrote:Actually sometimes there is valid reasons for getting global key states.Getting "global" key states are bad.
If you really have to do that, then you doing something really wrong.
For example, Mousotron really needs this to be fixed to be fully usable.
it doesn't log anything (it even lacks statistical logging). In real world
this program is useful to see how much text you wrote today or how actively
you used your mouse.
Well, fact is that (unfortunately) not all developers of Windows programsIf something _needs_ those events, they should use LL_HOOKs (keyboard and
mouse). Constantly polling GetAsyncKeyState() doesn't guarantee anything
and is a really bad practice. It's even bad to use that function to check
state of the keys at any given point of time.
really care about good design or good practice. BTW, I'm not sure how exactly
Mousotron works (I didn't actually tried to debug it) so therefore I'm not
sure does it uses this function or not; I just think that there is might be a
such possibility.
This app shouldn't be a key logger and I usually do not program for windows (the worst OS ever
). The app should start/stop pushing a button within a game when I push a button (for example "c"). A friend asked me for such a program!
I also tried hooks but it doesn't work (perhapse I did something wrong, I don't know). A short example would be nice.

I also tried hooks but it doesn't work (perhapse I did something wrong, I don't know). A short example would be nice.
The topic is closed. We don't write trainers/cheats/other bad stuff.bdevel wrote:This app shouldn't be a key logger and I usually do not program for windows (the worst OS ever). The app should start/stop pushing a button within a game when I push a button (for example "c"). A friend asked me for such a program!
I also tried hooks but it doesn't work (perhapse I did something wrong, I don't know). A short example would be nice.