AutoHotkey Community

It is currently May 27th, 2012, 8:39 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: April 10th, 2006, 2:54 pm 
Offline

Joined: July 30th, 2004, 8:50 pm
Posts: 192
:) 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.

Image

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 May 25th, 2006, 7:07 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2006, 2:57 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: I need help
PostPosted: April 29th, 2006, 3:19 pm 
Offline

Joined: April 29th, 2006, 3:17 pm
Posts: 1
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2006, 3:30 pm 
@ 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. :)


Report this post
Top
  
Reply with quote  
PostPosted: May 24th, 2006, 7:52 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear skrommel, :)

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

Thanks for sharing :D

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, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Bug
PostPosted: May 25th, 2006, 7:06 pm 
Offline

Joined: July 30th, 2004, 8:50 pm
Posts: 192
:o Oh no, now I have to correct all of my programs!

Thanks for noticing!

Skrommel


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2006, 4:02 am 
Offline

Joined: February 9th, 2006, 10:39 am
Posts: 33
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2006, 4:38 am 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
Try changing the following function as follows:
(NOT TESTED) Works in my head though :roll:

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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2006, 4:54 am 
Offline

Joined: February 9th, 2006, 10:39 am
Posts: 33
Yep, works perfectly... tnx a lot!

_________________
In a world without walls and fences, who needs Windows and Gates?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 24th, 2006, 5:17 am 
Offline

Joined: November 1st, 2005, 4:44 am
Posts: 135
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2007, 9:08 pm 
Offline

Joined: July 29th, 2005, 5:32 pm
Posts: 179
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2007, 10:19 pm 
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.......)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2007, 3:29 am 
Offline

Joined: February 14th, 2007, 8:01 pm
Posts: 308
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2007, 4:40 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
It would be much simpler if you save the mouse position, and move it to the lower right corner of the screen, for hiding.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2007, 6:31 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
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 ;) .


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: hyper_, xXDarknessXx and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group