Login   /   Register

Getting the current mouse cursor

Rate this article
     1 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 5
Loading ... Loading ...
April 10th, 2008 by Yaron Assa

Sometimes, you can only tell when an AUT operation has ended by checking the windows mouse cursor - is it an hourglass, or a simple arrow.

 

The following code allows your to get the integer code of the mouse icon:

'These come once, in the top of the script
extern.Declare micLong,"GetForegroundWindow","user32.dll","GetForegroundWindow"
extern.Declare micLong,"AttachThreadInput","user32.dll","AttachThreadInput", micLong, micLong,micLong
extern.Declare micLong,"GetWindowThreadProcessId","user32.dll","GetWindowThreadProcessId", micLong, micLong
extern.Declare micLong,"GetCurrentThreadId","kernel32.dll","GetCurrentThreadId"
extern.Declare micLong,"GetCursor","user32.dll","GetCursor"
 
'Function definition
function get_cursor()
    hwnd = extern.GetForegroundWindow()
    pid = extern.GetWindowThreadProcessId(hWnd, NULL)
    thread_id=extern.GetCurrentThreadId()
    extern.AttachThreadInput pid,thread_id,True
    get_cursor=extern.GetCursor()
    extern.AttachThreadInput pid,thread_id,False
end function
 
'Now we can use the function in our scripts
Print get_cursor() 

Posted in Keyboard and Mouse

5 Responses to “Getting the current mouse cursor”

  1. duttaj123 Says:

    [+]

    i have a doubt... i need to just move the mouse after each say 3 min when a prog is getting run... basically i would like to avo... ...

  2. Mohamed Ali Says:

    [+]

    change your registry values to disable the screen saver. to do so, run this: Const HKEY_CURRENT_USER = &H80000001 strComp... ...

  3. Mohamed Ali Says:

    [-]

    What is the integer for the hour glass?

  4. Sachin Says:

    [+]

    I've a question here... What is the integer value for the different states of the cursor? For eg: I want the state of the cursor... ...

  5. daniva Says:

    [-]

    The integer represent the code id of the cursor

Leave a Reply

You must be logged in to post a comment.

This article was viewed 885 times