Detecting system event without a window
BlitzMax Forums/BlitzMax Programming/Detecting system event without a window
| ||
Hi, I don't want to detect a specific event or for the event to be named but just detect if any event happens and I can't use a window. Even if I did use a window it might go out of focus and then I am in the same situation. Is there a simple fast way to detect if an event happens not naming the specific event when the window is out of focus or there is no window? I cant find very good documentation on how to use the pollsystem command but it looks like what I am looking for. |
| ||
I dont' understand what do you really want, sorry! What do you mean with 'system event'? |
| ||
sorry, It was late when i asked this question and I guess I wasnt fully awake haha. I am asking how I can detect if the user presses a key, moves the mouse or clicks the mouse with no window without creating an event hook for every single possibility. and how events work. Its not very well documented. |
| ||
. |
| ||
Are you talking about getting the information from the operating system? I think that is how key loggers work and I think you would run in to a lot of problems if you know what I mean. polled input works only with the graphics active and when the window is on focus also it can only be activated by the graphis object according to this(from the polled input module): Rem Currently only called by Graphics/bglCreateContext. Private for now, as it really needs a source:object parameter. End Rem Function EnablePolledInput( source:Object=Null ) If enabled Return inputSource=source FlushKeys FlushMouse AddHook EmitEventHook,Hook,Null,0 enabled=True End Function Event hooks are also application driven only. I believe windows passes that information to the application only when the window is in focus for the reason mention earlier but that is just my guess. |
| ||
SuperStrict Extern "win32" Function GetCursorPos:Int(point:Byte Ptr) Function GetAsyncKeyState:Int(vKey:Int) End Extern Const VK_LEFTMOUSE:Int = $01 ' Left physical mouse button Const VK_RIGHTMOUSE:Int = $02 ' Right physical mouse button Const VK_MIDDLEMOUSE:Int = $04 ' Middle physical mouse button Global pos:Int[2] Global oldpos:Int[2] Repeat GetCursorPos(pos) 'Read mouse position If pos[0]<>oldpos[0] Or pos[1]<>oldpos[1] then Print "Mouse position=" + pos[0] + "," + pos[1] EndIf oldpos[0] = pos[0] oldpos[1] = pos[1] Local mhit:Int=getasynckeystate(VK_LEFTMOUSE) If mhit Shr 31 Then Print "Left mouse button clicked " + Bin(mhit) If mhit Shr 15 Then Print "Left Mouse down "+Bin(mhit) Delay 10 forever |
| ||
thanks zeke, I was actually looking for something the would just show if a key is pressed not which one but this will work too. @jesse sorry I am a bit confused by all of this terminology. What problems might I run into simply running this on my own computer? I dont intend to make a keylogger if that is what you are wondering. |
| ||
@Nate the Great: See the GHotkey stuff here. Keep in mind that it's really old code. You should be able to gather what you need from it, though. |
| ||
Nate, obviously I was wrong about the mouse sense you can get them globally. I have never even tried to get into making a key logger but just the fact that you are accessing a key while another program is in focus seems to me invasion of privacy. for example entering a password or personal information into a program while another program is intercepting, I would consider it to be an offending program. but sense I never really looked at a key logger, I guess I would not know. the problems I was referring was that a virus detector could potentially detect it as an offending virus but again that is just my guess. If that is not a virus, I don't see how it can not be used or seen as one. I personally don't think that's what you are doing but it was just logical for me to make that conclusions. |