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
On Thu, May 8, 2008 at 5:51 AM, bdevel <wineforum-user at winehq.org> 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.> I found an app written in Delphi which uses the GetAsyncKeyState call and returns systemwide clicks.Even when run in Wine?
Yes. In vmware the apps I wrote returning systemwide mouseclicks! And as I said the Delphi app reeturns in wine systemwide mouseclicks. I tried hook too with the same results.
But why the Delphi app can do this while it runs in wine?
Ove Kaaven wrote:> vitamin skrev: > > > 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. > > > > > > > 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. > > > > Pff. Why would you need to modify X server? Using existing XQueryKeymap > ought to be sufficient.Well I guess one could use this to query the keyboard state, However like with mouse (GetCursorPos -> XQueryPointer) there are might be some issues.
Here is the Delphi app. http://blacktoolz.com/AsyncKeyTest.exe
Hey thats my own domain. I only use this to share sourcecodes with my friends.
On Thu, May 8, 2008 at 9:34 AM, bdevel <wineforum-user at winehq.org> wrote:> Here is the Delphi app. > http://blacktoolz.com/AsyncKeyTest.exethis app does not work for me using the latest wine in FreeBSD 7.0 Sam Fourman Jr.
L. Rahyen wrote:> On Thursday May 8 2008 17:09:28 vitamin wrote: > > > Getting "global" key states are bad. > > If you really have to do that, then you doing something really wrong. > > > > > Actually sometimes there is valid reasons for getting global key states. For > example, Mousotron really needs this to be fixed to be fully usable.The stuff that "needs" global key events called "key logger". 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.
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.