Is there such an event in existence?



  • Hello

    Sorry for the ambigous and silly title.

    Ok I'll ask my question directly, but if you are interested in the long story you may read further below.

    Is there any event for detecting when the mouse pointer has changed? I am guessing such an event may exist in the Win32 API or the DirectX API.
    BTW, I am using .NET (C#).

    [b]Long Story[/b]

    You see, I play this computer game. I want to create a memory-resident application that programmically moves the mouse pointer accross the game screen - and the moment the mouse pointer changes (ie, the graphic of the mouse pointer changes), I want my application to "do something".

    Truth be told, I have no experiance at all with Win32 API or DirectX API. Infact I dont even know how to import an API in my .NET app. However, since the past 10 hours I've been going thru code examples on codeproject.com, experts-exchange.com, MSDN forums, etc so I've learnt a little. I've learnt how to import Win32 DLLs into my C#...

    Now, I know how to programmically move the mouse pointer (Cursor.Position). However, I dont know how to detect when the mouse pointer changes. I spent all day working on the following idea:

    1) capturedBlock1 = Capture screen area around the mouse pointer
    2) if (capturedBlock "is similar to" Image)
       // do something
        else
        Move mouse pointer 20 blocks
        GOTO 1

    As you can imagine, I ran into major problems with the above method. I wont even begin boring you with the details. It was a stupid idea. Then it hit me.... there has to be an event in Windows or DirectX that is fired whenever the game changes the mouse cursor. So here I am...

    Your help is GREATLY appreciated.

     



  • What's the point of a game if you're not the one playing it? If it's not fun any more, don't cheat, just quit.



  • @Goplat said:

    What's the point of a game if you're not the one playing it? If it's not fun any more, don't cheat, just quit.

    Yeah. I don't really see the point in putting so much work into [i]not[/i] playing a game. I mean, it's a game. It doesn't really matter... unless he's trying to cheat at online poker or farm gold in WoW or something. In that case I can understand why but I wouldn't support it.



  • Its not about fun or game or cheating or anything.

    I have an idea. I just want to learn the ins and outs of everything I need to know in order to implement it. Thats all -_-;

     



  • I'd start by looking at how an application would set the cursor shape:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/cursors.asp

     LoadCursor[fromFile] is used to change the graphic, so if you hook that system call you'll know when it's called. This may or may not be trivial. Sysinternals.com or rootkit.com would be a good place to find out how to go about doing that.

    Most likely this will be enough though:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/cursors/cursorreference/cursorstructures/cursorinfo.asp

    Call GetCursorInfo() after every mouse move and check the resource that's loaded. This may or may not work, depending on which cursor info is used (I'm pretty sure that the cursor is dependant on the window that the mouse currently hovers over, so it may only get your own windows cursor state..)

     

     



  • [quote user="Nandurius"]

    I'd start by looking at how an application would set the cursor shape:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/cursors.asp

     LoadCursor[fromFile] is used to change the graphic, so if you hook that system call you'll know when it's called. This may or may not be trivial. Sysinternals.com or rootkit.com would be a good place to find out how to go about doing that.

    [/quote]

    Interesting. For starters, I'll investigate the first solution you suggest
    Now, hmm.. is there any particular reason why you suggested LoadCursor() instead of SetCursor()? It seems LoadCursor is a function that is called only once to load all the cursors into the "memmory". I'd assume it would be better to hook the SetCursor() system call, dont you think?

     

     



  • [quote user="GizmoC"]Interesting. For starters, I'll investigate the first solution you suggest

    Now, hmm.. is there any particular reason why you suggested LoadCursor() instead of SetCursor()? It seems LoadCursor is a function that is called only once to load all the cursors into the "memmory". I'd assume it would be better to hook the SetCursor() system call, dont you think?

     [/quote]

     Oh, duh. I was reading the page too fast, didn't see the SetCursor function. Seems like that's the right one though.

    This comment from the docs intrigues/scares me though:
    [quote user="msdn"]The cursor is not shown on the screen if the internal cursor display
    count is less than zero. This occurs if the application uses the ShowCursor function to hide the cursor more times than to show the cursor.[/quote]

    wtf?
     



  • This article seems to address your requirements: http://msdn.microsoft.com/msdnmag/issues/01/10/Cursor/default.aspx



  • [quote user="monkewing"]

    This article seems to address your requirements: http://msdn.microsoft.com/msdnmag/issues/01/10/Cursor/default.aspx

    [/quote]

     

    Thanks, I was actually aware of the article before I made this post. Unfortunately, I am not able to make the WaitForCursor() function work for User-Defined cursors. Prolly because I have like no C++ experiance.  



  • [quote user="djork"][quote user="Goplat"]What's the point of a game if you're not the one playing it? If it's not fun any more, don't cheat, just quit.
    [/quote]

    Yeah. I don't really see the point in putting so much work into [i]not[/i] playing a game. I mean, it's a game. It doesn't really matter... unless he's trying to cheat at online poker or farm gold in WoW or something. In that case I can understand why but I wouldn't support it.[/quote]

     I've always found developing my own macros, etc. to be far more interesting, challenging, and rewarding than playing the games themselves.  For example, I once decompiled the Runescape applet, and hooked in my own custom macro language.  That was tons of fun.
     



  • [quote user="GizmoC"]You see, I play this computer game. I want to create a memory-resident
    application that programmically moves the mouse pointer accross the
    game screen - and the moment the mouse pointer changes (ie, the graphic
    of the mouse pointer changes), I want my application to "do something".

    Truth be told, I have no experiance at all with Win32 API or DirectX API. Infact I dont even know how to import an API in my .NET app. However, since the past 10 hours I've been going thru code examples on codeproject.com, experts-exchange.com, MSDN forums, etc so I've learnt a little. I've learnt how to import Win32 DLLs into my C#...

    Now, I know how to programmically move the mouse pointer (Cursor.Position). However, I dont know how to detect when the mouse pointer changes. I spent all day working on the following idea:

    1) capturedBlock1 = Capture screen area around the mouse pointer
    2) if (capturedBlock "is similar to" Image)
       // do something
        else
        Move mouse pointer 20 blocks
        GOTO 1

    As you can imagine, I ran into major problems with the above method. I wont even begin boring you with the details. It was a stupid idea. Then it hit me.... there has to be an event in Windows or DirectX that is fired whenever the game changes the mouse cursor. So here I am...

    [/quote]

    It's no good.  Train fishing the same way as the rest of us -- by sitting in Auberdine for hours on end. :) 



  • [quote user="Angstrom"] Train fishing the same way as the rest of us -- by sitting in Auberdine for hours on end. :) [/quote]

    HAHAHA
    Actually, there are auto-fishing bots out there. I havent used them, or even seen them in action. But it IS possible. I am doing this as a personal challenge.



  • Whoa, slow down. The OP mentioned DirectX, that changes things somewhat doesn it?


Log in to reply