; 将鼠标移动到文字上可查看
#SingleInstance Force
hcursorArrow       := LoadCursor(,32512)
hcursorIBeam       := LoadCursor(,32513)
hcursorWait        := LoadCursor(,32514)
hcursorCross       := LoadCursor(,32515)
hcursorHandwriting := LoadCursor(,32631)
hcursorHand        := LoadCursor(,32649)

; About Cursors:https://learn.microsoft.com/en-us/windows/win32/menurc/about-cursors

Gui Add, Text, hwndhwndArrowText, IDC_ARROW
Gui Add, Text, hwndhwndIBeamText, IDC_IBEAM
Gui Add, Text, hwndhwndWaitText, IDC_WAIT
Gui Add, Text, hwndhwndCrossText, IDC_CROSS
Gui Add, Text, hwndhwndHandwritingText, _
Gui Add, Text, hwndhwndHandext, IDC_HAND
Gui +AlwaysOnTop +Resize
Gui Show, w350, WM_SETCURSOR
onMessage(0x0020,"WM_SETCURSOR",-1)
Return

GuiClose(GuiHwnd) {
  ExitApp
}

WM_SETCURSOR(wParam, lParam, msg, hwnd)  {
  global
  local hcursorNew, hcursor, hwndCntl
  static hcursorPrior:=0

  critical On
  hcursorNew:=0, hcursor:=0
  switch (A_Gui)
  {
    case 1:
      /*
      varSetCapacity(POINT, 8, 0)
      dllCall("GetCursorPos", "Ptr",&POINT)
      hwndCnt2:=dllCall("WindowFromPoint", "Int64",NumGet(POINT,0,"Int64"), "Ptr"))
      */
      MouseGetPos,,,,hwndCntl,2
      switch (hwndCntl)
      {
        case hwndArrowText:       hcursorNew:=hcursorArrow
        case hwndIBeamText:       hcursorNew:=hcursorIBeam
        case hwndWaitText:        hcursorNew:=hcursorWait
        case hwndCrossText:       hcursorNew:=hcursorCross
        case hwndHandwritingText:     hcursorNew:=hcursorHandwriting
        case hwndHandext:         hcursorNew:=hcursorHand
      }
      if (hcursorNew)  {
        hcursor:=dllCall("SetCursor", "Ptr",hcursorNew, "Ptr")
        if (!hcursorPrior)
          hcursorPrior:=hcursor
      }  else if (hcursorPrior)  {
        hcursor:=dllCall("SetCursor", "Ptr",hcursorPrior, "Ptr"), hcursorPrior:=0
      }      
  }
  return (hcursor?true:"")
}

LoadCursor(hInst:=0, name:="")  { ;  v1.1  v2.0  hcursorHand:=LoadCursor(,IDC_HAND:=32649)
  static IMAGE_CURSOR:=2
      ,LR_DEFAULTSIZE:=0x00000040
      ,LR_SHARED:=0x00008000
  return (name==""?false:dllCall("User32.dll\LoadImage", "Ptr",hInst, "Ptr",name, "UInt",IMAGE_CURSOR, "Int",0, "Int",0, "UInt",LR_DEFAULTSIZE|LR_SHARED, "Ptr"))
  ;  dllCall("User32.dll\LoadCursor", "Ptr",hInst, "Ptr",name, "Ptr")
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。