Thread: How to find the cursor on the screen ?

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    7

    How to find the cursor on the screen ?

    For example, on my screen there is a string "abcd"
    how can I find the cursor of a and record it ?

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    If you're in the Windows environment, maybe the following snippet could be of some help to you.


    Code:
    #include <windows.h>
    
    int main(void)
    {
        DWORD dwX, dwY;
        HANDLE hOut;
        CONSOLE_SCREEN_BUFFER_INFO sbSize;
        COORD Where;
        DWORD NumRead;
        char cCharacter;
        char cCheckCharacter = 'X';
    
        hOut = GetStdHandle(STD_OUTPUT_HANDLE);
        GetConsoleScreenBufferInfo(hOut, &sbSize);
        for (dwY = 0; dwY < sbSize.srWindow.Bottom; dwY++)
            for(dwX = 0; dwX < sbSize.srWindow.Right; dwX++)
            {
                Where.X = dwX;
                Where.Y = dwY;
                ReadConsoleOutputCharacter(hOut,
                    &cCharacter,
                    1,
                    Where,
                    &NumRead);
                if(cCharacter == cCheckCharacter)
                    // dwX, dwY coordinate
                    Beep(400, 1000);
            }
        return 0;
    }

  3. #3
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    ::FROM THE HIP::

    If you are in Linux, you may be able to get the current buffer from /dev/mem or /dev/kmem. The location is around 0xb000 (I think). Since Linux runs in protected mode, there should be some residual chars left in the buffer. . . you'd just have to do some research on it.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Kennedy
    ::FROM THE HIP::
    I ususally just use my eyes when I'm looking for the cursor. I'm not sure I like or understand the whole "from the hip" thing. Maybe your have a touch screen monitor and if so, I'm not so sure I like where you're going with this conversation...


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    I'll overlook that and assume you aren't from the US thus haven't seen enough westerns in your time and tell you the whole phrase is "shooting from the hip" and refers to not having a good bead on the target. . . in other words I was only "taking a stab at it" or "flying by the seat of my pants" perhaps even, "not looking before I leap".

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Kennedy
    I'll overlook that and assume you aren't from the US thus...
    I'll overlook that and assume you have absolutely no sense of humour.


    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Hmmm, smell, touch, taste, hearing, and sight. . . all checks out. . . "Funny" I cannot locate my humour sense.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How does this user get screen to run under root?
    By Overworked_PhD in forum Tech Board
    Replies: 2
    Last Post: 06-28-2009, 09:31 AM
  2. Linux Problem Screen Resoultion
    By Matus in forum Tech Board
    Replies: 1
    Last Post: 01-29-2009, 04:39 PM
  3. [C] GDI: how to erase material drawn at an entire screen DC
    By pc2-brazil in forum Windows Programming
    Replies: 3
    Last Post: 01-24-2009, 07:24 PM
  4. Feedback: Functional Specification Wording
    By Ragsdale85 in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2006, 04:56 PM
  5. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 10:18 PM