bladem2003 Posted July 13, 2023 Posted July 13, 2023 Hi, how can i set the mouse cursor when i over the input control back to standart? cursorid for input $MCID_IBEAM (5) expandcollapse popup#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
Andreik Posted July 13, 2023 Posted July 13, 2023 I am not sure what do you want to do but instead of GUISetCursor(), which set the cursor for the entire window, use GUICtrlSetCursor() to set a specific cursor to your input control. bladem2003 1
Solution argumentum Posted July 13, 2023 Solution Posted July 13, 2023 2 hours ago, bladem2003 said: how can i set the mouse cursor when i over the input control back to standart? expandcollapse popup#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 bladem2003 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Werty Posted July 13, 2023 Posted July 13, 2023 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... expandcollapse popup#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 bladem2003 1 Some guy's script + some other guy's script = my script!
Werty Posted July 14, 2023 Posted July 14, 2023 (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. Edited July 17, 2023 by Werty bladem2003 1 Some guy's script + some other guy's script = my script!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now