AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Changing the mouse cursor
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
skrommel



Joined: 30 Jul 2004
Posts: 190

PostPosted: Mon Apr 10, 2006 1:54 pm    Post subject: Changing the mouse cursor Reply with quote

Smile Here's some code to change the mouse cursor. I've put it into an about box where it canges the cursor to a hand over links.



Skrommel


Code:
ABOUT:
Gui,Destroy
Gui,Add,Text,y-5,`t
Gui,Add,Picture,Icon100,%SystemRoot%\system32\SHELL32.dll
Gui,Font,Bold
Gui,Add,Text,x+10 yp+10,Hand v1.0
Gui,Font
Gui,Add,Text,xm,Changes the cursor to a hand over links.
Gui,Add,Text,y+0,`t
Gui,Add,Picture,Icon47,%SystemRoot%\system32\SHELL32.dll
Gui,Font,Bold
Gui,Add,Text,x+10 yp+10,1 Hour Software by Skrommel
Gui,Font
Gui,Add,Text,xm,For more tools and information, please stop by at
Gui,Font,CBlue Underline
Gui,Add,Text,xm GWWW,http://www.donationcoders.com/skrommel
Gui,Font
Gui,Add,Text,y+0,`t
Gui,Add,Picture,Icon25,%SystemRoot%\system32\SHELL32.dll
Gui,Font,Bold
Gui,Add,Text,x+10 yp+10,AutoHotkey
Gui,Font
Gui,Add,Text,xm,This program is made using AutoHotkey
Gui,Font,CBlue Underline
Gui,Add,Text,xm GAUTOHOTKEY,http://www.autohotkey.com
Gui,Font
Gui,Add,Text,y+0,`t
Gui,Add,Button,GABOUTOK Default w75,&OK
Gui,Show,,%applicationname% About

;Load the cursor and start the "hook"
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
OnMessage(0x200,"WM_MOUSEMOVE")
Return

AUTOHOTKEY:
Run,http://www.autohotkey.com,,UseErrorLevel
Return

WWW:
Run,http://www.donationcoders.com/skrommel,,UseErrorLevel
Return

ABOUTOK:
Gui,Destroy
;Disable the "hook" and destroy the cursor
OnMessage(0x200,"")
DllCall("DestroyCursor","Uint",hCurs)
Return

GuiClose:
ExitApp

;The "hook"
WM_MOUSEMOVE(wParam,lParam)
{
  Global hCurs
  MouseGetPos,,,,ctrl
  ;Only change over certain controls, use Windows Spy to find them.
  If ctrl in Static9,Static14
    DllCall("SetCursor","UInt",hCurs)
  Return
}


Last edited by skrommel on Thu May 25, 2006 6:07 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10667

PostPosted: Mon Apr 10, 2006 1:57 pm    Post subject: Reply with quote

Nice script and presentation; thanks for sharing it.

Control over cursor shape is one of those features that's been planned for a long time. It's still a high priority, so hopefully it will get done soon.
Back to top
View user's profile Send private message Send e-mail
Jub Jub



Joined: 29 Apr 2006
Posts: 1

PostPosted: Sat Apr 29, 2006 2:19 pm    Post subject: I need help Reply with quote

umm, im sorta new to forums. I want to change the mouse cursor for my forum using phpbb2 i think its 2. But anyways, I dont no where to do it and i dont know how. sry for the typing, but im in a hurry
Back to top
View user's profile Send private message
HurryHarry
Guest





PostPosted: Sat Apr 29, 2006 2:30 pm    Post subject: Reply with quote

@ Jub Jub
I guess you request help regarding a phpBB configuration issue. Unfortunately you're at the wrong place, as this is the forum of AHK (Autohotkey) - btw. a nice piece of software. Smile
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 7159

PostPosted: Wed May 24, 2006 6:52 am    Post subject: Re: Changing the mouse cursor Reply with quote

Dear skrommel, Smile

I tried this just now.. and it is NICE!!

Thanks for sharing Very Happy

I am trying to do something similar and need a small clarification:

Should not Line 5 in the following subroutine

Quote:
ABOUTOK:
Gui,Destroy
;Disable the "hook" and destroy the cursor
OnMessage(0x200,"")
DllCall("DestroyCursor","Uint",hCur)
Return


read as

Quote:
DllCall("DestroyCursor","Uint",hCurs)


Or Am I missing something?

Regards, Smile
_________________
Suresh Kumar A N
Back to top
View user's profile Send private message
skrommel



Joined: 30 Jul 2004
Posts: 190

PostPosted: Thu May 25, 2006 6:06 pm    Post subject: Bug Reply with quote

Surprised Oh no, now I have to correct all of my programs!

Thanks for noticing!

Skrommel
Back to top
View user's profile Send private message Visit poster's website
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Fri Oct 27, 2006 3:02 am    Post subject: Reply with quote

Is it possible to have it work in certain GUI's?

I have a 'About' GUI where a gLabel activates a target (is +owner -SysMenu).
When the 'Update' GUI is open the hand appears also although there is no gLabel (there both static1).

Is there a way to let the hand cursor only work in the About GUI?

Tnx
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1317
Location: USA

PostPosted: Fri Oct 27, 2006 3:38 am    Post subject: Reply with quote

Try changing the following function as follows:
(NOT TESTED) Works in my head though Rolling Eyes

Code:
WM_MOUSEMOVE(wParam,lParam)
{
  Global hCurs
  MouseGetPos,,,,ctrl
  ;Only change over certain controls, use Windows Spy to find them.
  If ctrl in Static9,Static14
    DllCall("SetCursor","UInt",hCurs)
  Return
}


Code:
WM_MOUSEMOVE(wParam,lParam)
{
  GuiTitleToChangeCursorIn:="The exact title shown in the TitleBar" ; edit the text in quotes
  IfWinActive, %GuiTitleToChangeCursorIn% ; only do the following if the correct window is active
    {
  Global hCurs
  MouseGetPos,,,,ctrl
  ;Only change over certain controls, use Windows Spy to find them.
 If ctrl in Static9,Static14 ; you will have to change this to your control id's
    DllCall("SetCursor","UInt",hCurs)
   }
  Return
}
Back to top
View user's profile Send private message
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Fri Oct 27, 2006 3:54 am    Post subject: Reply with quote

Yep, works perfectly... tnx a lot!
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
iason



Joined: 01 Nov 2005
Posts: 128

PostPosted: Sun Dec 24, 2006 4:17 am    Post subject: Re: Changing the mouse cursor Reply with quote

Quote:
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND


Can someone suggest some sort of tutorial about the icons inside that file?
_________________
help to be helped
Back to top
View user's profile Send private message
freakkk



Joined: 29 Jul 2005
Posts: 179

PostPosted: Sat Jan 13, 2007 8:08 pm    Post subject: Reply with quote

I took the 'Display context-senstive help' example in help file.. & mixed it with your example above. It makes it easier for setting the tooltip & custom mouse cursor for specific controls. It also allows you to use a .cur or .ani file not included in user32.dll.
Code:

Gui, Add, ListBox, x16 y17 w420 h120  vGui1MyListBox, MyListBox
Gui1MyListBox_Tooltip = Gui1MyListBox hover tip..
Gui1MyListBox_MouseCursor = 32649

Gui, Add, Edit, x16 y137 w420 h90  vGui1MyEdit, MyEdit
Gui1MyEdit_Tooltip = Gui1MyEdit hover tip..
Gui1MyEdit_MouseCursor = 32648

Gui, Add, Button, x286 y237 w90 h20  vGui1MyButton, MyButton
Gui1MyButton_Tooltip = Gui1MyButton hover tip..
Gui1MyButton_MouseCursor = %A_ScriptDir%\grab.cur   ; if not found.. it doesn't do anything..

Gui, Show, w453 h281, Example..
OnMessage(0x200, "GuiHoverControl") ; Start tooltip/mouse cursor routine..
Return
;-----------------
GuiEscape:
GuiClose:
ExitApp

; ///////////////////// Function ///////////////////////
GuiHoverControl()
{
    static CurrControl, PrevControl, _Tooltip, hCurs
    CurrControl := A_GuiControl
    If (CurrControl <> PrevControl and not InStr(CurrControl, " "))
    {
        ToolTip  ; Turn off any previous tooltip.
        SetTimer, GuiDisplayToolTip, 1000
        PrevControl := CurrControl
        DllCall("DestroyCursor","Uint",hCurs)
        hCurs =
    }
    If (%CurrControl%_MouseCursor)
    {
        If ((SubStr(%CurrControl%_MouseCursor, -3, 4)) = ".cur" or (SubStr(%CurrControl%_MouseCursor, -3, 4)) = ".ani")
        {
          If hCurs =
          {
            IfExist, % %CurrControl%_MouseCursor
              hCurs:=DllCall("LoadCursorFromFile","Str",%CurrControl%_MouseCursor)
          }
        }
        Else
        {
          If hCurs =
            hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",%CurrControl%_MouseCursor,"UInt")
        }
        If hCurs <>
         DllCall("SetCursor","UInt",hCurs)
    }
    return

    GuiDisplayToolTip:
    SetTimer, GuiDisplayToolTip, Off
    ToolTip % %CurrControl%_Tooltip
    SetTimer, GuiRemoveToolTip, 3000
    return

    GuiRemoveToolTip:
    SetTimer, GuiRemoveToolTip, Off
    ToolTip
    return
}
Here's another example that shows a bunch of icons in user32.dll..
(make sure you include GuiHoverControl() somewhere on here..)
Code:
Column1Buttons =
(
32642   NW to SE - Small
32643   NE to SW - Small
32644   WE - Small
32645   NS - Small
32646   NSEW - Small
32648   IDC_NO  (Slashed circle)
32649   IDC_HAND  (Icon Hand)
32650   IDC_APPSTARTING
32651   IDC_HELP
32652   NS - Big
)

Column2Buttons =
(
32653   WE - Big
32654   NSEW - Big
32655   N - Big
32656   S - Big
32657   W - Big
32658   E - Big
32659   NW - Big
32660   NE - Big
32661   SW - Big
32662   SE - Big
)

y=0
Loop, Parse, Column1Buttons, `n
{
  Gui, Add, Button, x5 y%y% w220 h25 vGui1Button%A_Index% gGui1Button, %A_LoopField%
  Gui1Button%A_Index%_MouseCursor := SubStr(A_LoopField, "1", 5)
  y+=25
}
y=0
Loop, Parse, Column2Buttons, `n
{
  BtnNum := A_Index+10
  Gui, Add, Button, x226 y%y% w220 h25 vGui1Button%BtnNum% gGui1Button, %A_LoopField%
  Gui1Button%BtnNum%_MouseCursor := SubStr(A_LoopField, "1", 5)
  y+=25
}

Gui, Show, w450 ,--Mouse Cursors In user32.dll--
OnMessage(0x200, "GuiHoverControl") ; Start tooltip/mouse cursor routine..
Return
;-----------------
Gui1Button:
GuiControlGet, tmp1,, % A_GuiControl
clipboard := SubStr(tmp1, 1, 5)
tmp1 =
MsgBox, ,--Mouse Cursors In user32.dll--,'%clipboard%' has been copied to the clipboard.., 4
return
;-----------------
GuiEscape:
GuiClose:
ExitApp

_________________
.o0[ corey ]0o.
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Apr 09, 2007 9:19 pm    Post subject: Reply with quote

how would i change the function so that i could change the curosor with a simple function call? this would help with setting hotkeys to change cursor (like if i am holding the mouse button in.......)
Back to top
degarb



Joined: 14 Feb 2007
Posts: 225

PostPosted: Fri Aug 03, 2007 2:29 am    Post subject: Reply with quote

I like the hand over links. But, I wish to hide cursor when mouse not moved for 7 seconds, then reappear on move.

I could write my own park on 2x3 spot then resume on move, but why reinvent the wheele.

Any one did this?
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4474
Location: Boulder, CO

PostPosted: Fri Aug 03, 2007 3:40 am    Post subject: Reply with quote

It would be much simpler if you save the mouse position, and move it to the lower right corner of the screen, for hiding.
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2446

PostPosted: Fri Aug 03, 2007 5:31 am    Post subject: Reply with quote

degarb wrote:
I like the hand over links. But, I wish to hide cursor when mouse not moved for 7 seconds, then reappear on move.

I could write my own park on 2x3 spot then resume on move, but why reinvent the wheele.

Any one did this?
This might come in handy (although requires an additional .exe file ATM). There are likely a few other methods posted on the forum as this has been asked many times. Maybe try a search if you haven't already Wink .
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group