Jump to content
Sign in to follow this  
James

Cursor

Recommended Posts

James

Hi all,

I am in need some of help please.

I need to know how to make my script change cursor when the Window Handle (The top of a window is held) to the Move cursor (all four arrows are shown). I found Smoke_N's SetCursor however that permantlety changes it.

Thanks,

James

Share this post


Link to post
Share on other sites
DaRam

Hi all,

I am in need some of help please.

I need to know how to make my script change cursor when the Window Handle (The top of a window is held) to the Move cursor (all four arrows are shown). I found Smoke_N's SetCursor however that permantlety changes it.

Thanks,

James

Not very efficient, but you would check for a $GUI_EVENT_PRIMARYDOWN and call GUISetCursor(9) ; = SIZEALL,

plus on $GUI_EVENT_PRIMARYUP setit back to Normal with GUISetCursor(0).

Edit: Don't bother, this only works when clicking within the GUI not the Titlebar itself :):-( But you get the idea.

Edited by DaRam

Share this post


Link to post
Share on other sites
monoceres

Not very efficient, :) but you would check for a $GUI_EVENT_PRIMARYDOWN and call GUISetCursor(9) ; = SIZEALL,

plus on $GUI_EVENT_PRIMARYUP setit back to Normal with GUISetCursor(0).

That won't work since GUISetCursor only change the cursor inside the window not in the title bar (or something), also $WM_MOVE should be used to check if the window is moving :(

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
MikeP

almost working.. I'm posting it if you wanna dig the idea.. too tired to finish :

#Include <Misc.au3>
#Include <WinAPI.au3>
HotKeySet("{PAUSE}","QuitIt") 
$titlebarheight = 20
$pressed = False
$dll = DllOpen("user32.dll")

While 1
        If _IsPressed("01", $dll) Then 
            $pressed = true
            $mousepos = MouseGetPos()
            $handle = WinGetHandle("")
            $title = WinGetTitle("")
            $size = WinGetClientSize("")
            $pos = WinGetPos("")
            If StringCompare($title,"Program Manager") AND $mousepos[0] > $pos[0] AND $mousepos[0] < $pos[0]+$size[0] AND $mousepos[1] > $pos[1] AND $mousepos[1] < $pos[1]+$titlebarheight Then
                MouseMove($mousepos[0], $mousepos[1], 0)
                $loadcurs = DllCall("user32.dll", "hwnd", "LoadCursor", "hwnd", 0, 'int', 32512)
                $syscurs = DllCall("user32.dll", "int", "SetSystemCursor", "int", $loadcurs[0], "int", 32646)                   
            EndIf
        EndIf
        If $pressed Then
            $loadcurs = DllCall("user32.dll", "hwnd", "LoadCursor", "hwnd", 0, 'int', 32646)
            $syscurs = DllCall("user32.dll", "int", "SetSystemCursor", "int", $loadcurs[0], "int", 32512)
            $pressed = False
        EndIf
        Sleep(10)
WEnd

if your pointer is fucked up.. go to your Mouse config, pointer tab and clic OK to get the standard pointers back.

Share this post


Link to post
Share on other sites
rasim

More solutions:

#include <GuiConstants.au3>
#include <Misc.au3>

;Global Const $HTCAPTION = 0x2

Global Const $OCR_ARROW = 32512
Global Const $OCR_SIZEALL = 32646

Global $flag = False
Global $DllHandle = DllOpen("user32.dll")

$hGui = GUICreate("Test", 300, 200)

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")

GUISetState()

Do
Until GUIGetMsg() = -3

DllClose($DllHandle)

Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
    Local $iProc
    
    $iProc = DllCall($DllHandle, "int", "DefWindowProc", "hwnd", $hWnd, "int", $Msg, "wparam", $wParam, "lparam", $lParam)
    $iProc = $iProc[0]
    
    If ($iProc = $HTCAPTION) And (_IsPressed("01", $DllHandle) = 1) And ($flag = False) Then
        $flag = True
        _SetCursor($OCR_SIZEALL, $OCR_ARROW)
    ElseIf (_IsPressed("01", $DllHandle) = 0) And ($flag = True) Then
        $flag = False
        _SetCursor($OCR_ARROW, $OCR_SIZEALL)
        
        DllCall($DllHandle, "int", "ShowCursor", "int", False)
        DllCall($DllHandle, "int", "ShowCursor", "int", True)
    EndIf
    
    Return $GUI_RUNDEFMSG
EndFunc

Func _SetCursor($sNewCursor, $sReplaceCursor)
    Local $hCursor = DllCall("user32.dll", "hwnd", "LoadCursor", "hwnd", 0, "int", $sNewCursor)
    $hCursor = $hCursor[0]
    DllCall($DllHandle, "int", "SetSystemCursor", "hwnd", $hCursor, "int", $sReplaceCursor)
    DllCall($DllHandle, "int", "DestroyCursor", "hwnd", $hCursor)
EndFunc
:)

Share this post


Link to post
Share on other sites
MikeP

I think the thread creator wanted it to work on any window "I need to know how to make my script change cursor when the Window Handle (The top of a window is held)". Your code works only within a GUI.. any idea to get it to work on any window?

Share this post


Link to post
Share on other sites
BrettF
torels

Suggestion: get the position of each window with winlist and wingetpos functions and then use

Func _SetCursor($sNewCursor, $sReplaceCursor)
    Local $hCursor = DllCall("user32.dll", "hwnd", "LoadCursor", "hwnd", 0, "int", $sNewCursor)
    $hCursor = $hCursor[0]
    DllCall($DllHandle, "int", "SetSystemCursor", "hwnd", $hCursor, "int", $sReplaceCursor)
    DllCall($DllHandle, "int", "DestroyCursor", "hwnd", $hCursor)
EndFunc

when the cursor is on the first 10px of the window and switch back again when it is out of the 10 px


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites
torels

is ti working ?


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites
torels

OK :)


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×