Jump to content

set the mouse cursor over the input control back to standart


Go to solution Solved by argumentum,

Recommended Posts

Posted

Hi,

how can i set the mouse cursor when i over the input control back to standart?

cursorid for input $MCID_IBEAM (5)
 

 

 

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>


HotKeySet("{ESC}", "On_Exit")


$hGUI = GUICreate("Y", 400, 150, -1, -1, $WS_POPUP)
GUISetBkColor(0x414141)
GUICtrlCreateInput("", 10, 10, 50, 25)
GUISetState()

GUIRegisterMsg(0x0084, "_WM_NCHITTEST")

While 1
    Sleep(10)
WEnd


Func _WM_NCHITTEST($hWnd, $uMsg, $wParam, $lParam)
    Local $iSide = 0, $iTopBot = 0, $CurSorInfo, $i_marginResize = 6
    Local $aWinPos = WinGetPos($hWnd)
    Local $aCurInfo = GUIGetCursorInfo($hWnd)
    If Not @error Then
        If ($aCurInfo[4] > 0) Then Return
        ;Check if Mouse is over Border, Margin = 6
        If $aCurInfo[0] < $i_marginResize Then $iSide = 1
        If $aCurInfo[0] > $aWinPos[2] - $i_marginResize Then $iSide = 2
        If $aCurInfo[1] < $i_marginResize Then $iTopBot = 3
        If $aCurInfo[1] > $aWinPos[3] - $i_marginResize Then $iTopBot = 6
        $CurSorInfo = $iSide + $iTopBot
    Else
        $CurSorInfo = 0
    EndIf

    If Not (WinGetState($hWnd) = 47) Then
        If ($aCurInfo[4] = 0) Then
            Local $Return_HT = 2, $Set_Cursor = 2
            Switch $CurSorInfo
                Case 1
                    $Set_Cursor = 13
                    $Return_HT = 10
                Case 2
                    $Set_Cursor = 13
                    $Return_HT = 11
                Case 3
                    $Set_Cursor = 11
                    $Return_HT = 12
                Case 4
                    $Set_Cursor = 12
                    $Return_HT = 13
                Case 5
                    $Set_Cursor = 10
                    $Return_HT = 14
                Case 6
                    $Set_Cursor = 11
                    $Return_HT = 15
                Case 7
                    $Set_Cursor = 10
                    $Return_HT = 16
                Case 8
                    $Set_Cursor = 12
                    $Return_HT = 17
            EndSwitch
            GUISetCursor($Set_Cursor, 1)
            If Not ($Return_HT = 2) Then Return $Return_HT
        EndIf
    EndIf
    Return 'GUI_RUNDEFMSG'
EndFunc   ;==>INTERNAL_WM_NCHITTEST

Func On_Exit()
    Exit
EndFunc   ;==>On_Exit

 

  • Solution
Posted
2 hours ago, bladem2003 said:

how can i set the mouse cursor when i over the input control back to standart?

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>


HotKeySet("{ESC}", "On_Exit")


$hGUI = GUICreate("Y", 400, 150, -1, -1, $WS_POPUP)
GUISetBkColor(0x414141)
GUICtrlCreateInput("", 10, 10, 50, 25)
GUICtrlSetCursor(-1, 5) ; <------------ here  =)
GUISetState()

GUIRegisterMsg(0x0084, "_WM_NCHITTEST")

While 1
    Sleep(10)
WEnd


Func _WM_NCHITTEST($hWnd, $uMsg, $wParam, $lParam)
    Local $iSide = 0, $iTopBot = 0, $CurSorInfo, $i_marginResize = 6
    Local $aWinPos = WinGetPos($hWnd)
    Local $aCurInfo = GUIGetCursorInfo($hWnd)
    If Not @error Then
        If ($aCurInfo[4] > 0) Then Return
        ;Check if Mouse is over Border, Margin = 6
        If $aCurInfo[0] < $i_marginResize Then $iSide = 1
        If $aCurInfo[0] > $aWinPos[2] - $i_marginResize Then $iSide = 2
        If $aCurInfo[1] < $i_marginResize Then $iTopBot = 3
        If $aCurInfo[1] > $aWinPos[3] - $i_marginResize Then $iTopBot = 6
        $CurSorInfo = $iSide + $iTopBot
    Else
        $CurSorInfo = 0
    EndIf

    If Not (WinGetState($hWnd) = 47) Then
        If ($aCurInfo[4] = 0) Then
            Local $Return_HT = 2, $Set_Cursor = 2
            Switch $CurSorInfo
                Case 1
                    $Set_Cursor = 13
                    $Return_HT = 10
                Case 2
                    $Set_Cursor = 13
                    $Return_HT = 11
                Case 3
                    $Set_Cursor = 11
                    $Return_HT = 12
                Case 4
                    $Set_Cursor = 12
                    $Return_HT = 13
                Case 5
                    $Set_Cursor = 10
                    $Return_HT = 14
                Case 6
                    $Set_Cursor = 11
                    $Return_HT = 15
                Case 7
                    $Set_Cursor = 10
                    $Return_HT = 16
                Case 8
                    $Set_Cursor = 12
                    $Return_HT = 17
            EndSwitch
            GUISetCursor($Set_Cursor, 1)
            If Not ($Return_HT = 2) Then Return $Return_HT
        EndIf
    EndIf
    Return 'GUI_RUNDEFMSG'
EndFunc   ;==>INTERNAL_WM_NCHITTEST

Func On_Exit()
    Exit
EndFunc   ;==>On_Exit

 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

All this...

If Not (WinGetState($hWnd) = 47) Then
        If ($aCurInfo[4] = 0) Then
            Local $Return_HT = 2, $Set_Cursor = 2
            Switch $CurSorInfo
                Case 1
                    $Set_Cursor = 13
                    $Return_HT = 10
                Case 2
                    $Set_Cursor = 13
                    $Return_HT = 11
                Case 3
                    $Set_Cursor = 11
                    $Return_HT = 12
                Case 4
                    $Set_Cursor = 12
                    $Return_HT = 13
                Case 5
                    $Set_Cursor = 10
                    $Return_HT = 14
                Case 6
                    $Set_Cursor = 11
                    $Return_HT = 15
                Case 7
                    $Set_Cursor = 10
                    $Return_HT = 16
                Case 8
                    $Set_Cursor = 12
                    $Return_HT = 17
            EndSwitch
            GUISetCursor($Set_Cursor, 1)
            If Not ($Return_HT = 2) Then Return $Return_HT
        EndIf
    EndIf

can be written as...

If Not (WinGetState($hWnd) = 47) And ($aCurInfo[4] = 0) Then
   Local $Set_Cursor[9] = [2, 13, 13, 11, 12, 10, 11, 10, 12]
   GUISetCursor($Set_Cursor[$CursorInfo], 1)
   Return $CursorInfo + 9
EndIf

So all in all...

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

HotKeySet("{ESC}", "On_Exit")

$hGUI = GUICreate("Y", 400, 150, -1, -1, $WS_POPUP)
GUISetBkColor(0x414141)
GUICtrlCreateInput("", 10, 10, 50, 25)
GUICtrlSetCursor(-1, 5) ; <------------ here  =)
GUISetState()

GUIRegisterMsg(0x0084, "_WM_NCHITTEST")

While 1
    Sleep(10)
WEnd

Func _WM_NCHITTEST($hWnd, $uMsg, $wParam, $lParam)
    Local $iSide = 0, $iTopBot = 0, $CurSorInfo, $i_marginResize = 6
    Local $aWinPos = WinGetPos($hWnd)
    Local $aCurInfo = GUIGetCursorInfo($hWnd)
    If Not @error Then
        If ($aCurInfo[4] > 0) Then Return
        ;Check if Mouse is over Border, Margin = 6
        If $aCurInfo[0] < $i_marginResize Then $iSide = 1
        If $aCurInfo[0] > $aWinPos[2] - $i_marginResize Then $iSide = 2
        If $aCurInfo[1] < $i_marginResize Then $iTopBot = 3
        If $aCurInfo[1] > $aWinPos[3] - $i_marginResize Then $iTopBot = 6
        $CurSorInfo = $iSide + $iTopBot
    Else
        $CurSorInfo = 0
    EndIf

    If Not (WinGetState($hWnd) = 47) And ($aCurInfo[4] = 0) Then
            Local $Set_Cursor[9] = [2, 13, 13, 11, 12, 10, 11, 10, 12]
            GUISetCursor($Set_Cursor[$CursorInfo], 1)
            Return $CursorInfo + 9
    EndIf
    Return 'GUI_RUNDEFMSG'
EndFunc   ;==>INTERNAL_WM_NCHITTEST

Func On_Exit()
    Exit
 EndFunc   ;==>On_Exit

 

Some guy's script + some other guy's script = my script!

Posted (edited)

Hmm, using Ternary it can get even smaller...

Func _WM_NCHITTEST($hWnd, $uMsg, $wParam, $lParam)
   Local $Cur = GUIGetCursorInfo($hWnd)
   If ($aCurInfo[4] > 0) Then Return
   If Not (WinGetState($hWnd) = 47) And ($Cur[4] = 0) Then
      Local $Cursor[9] = [2,13,13,11,12,10,11,10,12], $CurInf, $Pos = WinGetPos($hWnd)
      $CurInf=($Cur[0]>$Pos[2]-6?2:$Cur[0]<6?1:0)+($Cur[1]>$Pos[3]-6?6:$Cur[1]<6?3:0)
      GUISetCursor($Cursor[$CurInf], 1)
      Return $CurInf + 9
   EndIf
Return 'GUI_RUNDEFMSG'
EndFunc   ;==>INTERNAL_WM_NCHITTEST

From 49 lines to 11 lines, Ternary Rocks!

Sorry for OT, but the thread was already answered by Andreik and argumentum. :P

Edited by Werty

Some guy's script + some other guy's script = my script!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...