AetherMaster Posted September 14, 2009 Share Posted September 14, 2009 I've been searching around, and I found this way to change the cursor: Global Const $OCR_APPSTARTING = 32650 Global Const $OCR_NORMAL = 32512 Global Const $OCR_CROSS = 32515 Global Const $OCR_HAND = 32649 Global Const $OCR_IBEAM = 32513 Global Const $OCR_NO = 32648 Global Const $OCR_SIZEALL = 32646 Global Const $OCR_SIZENESW = 32643 Global Const $OCR_SIZENS = 32645 Global Const $OCR_SIZENWSE = 32642 Global Const $OCR_SIZEWE = 32644 Global Const $OCR_UP = 32516 Global Const $OCR_WAIT = 32514 ;~ _SetCursor(@WindowsDir & "\cursors\3dgarro.cur", $OCR_NORMAL) ;~ _SetCursor(@WindowsDir & "\cursors\3dwarro.cur", $OCR_NORMAL) _SetCursor(@DesktopDir & "\wii-pointer-ccw.cur", $OCR_NORMAL) ;================================================================== ; $s_file - file to load cursor from ; $i_cursor - system cursor to change ;================================================================== Func _SetCursor($s_file, $i_cursor) Local $newhcurs, $lResult $newhcurs = DllCall("user32.dll", "int", "LoadCursorFromFile", "str", $s_file) If Not @error Then $lResult = DllCall("user32.dll", "int", "SetSystemCursor", "int", $newhcurs[0], "int", $i_cursor) If Not @error Then $lResult = DllCall("user32.dll", "int", "DestroyCursor", "int", $newhcurs[0]) Else MsgBox(0, "Error", "Failed SetSystemCursor") EndIf Else MsgBox(0, "Error", "Failed LoadCursorFromFile") EndIf EndFunc ;==>_SetCursor This is the only one that I could get working that kept the custom cursor over icons and such in my GUI, but it turns out this is because it changes your default cursor. My question to you all is this: Is there a way to use the above, but have your old cursor return when the script is closed? Thanks! Link to comment Share on other sites More sharing options...
picaxe Posted September 14, 2009 Share Posted September 14, 2009 A slightly tidied example from AutoIt forums#include <GuiConstants.au3> #include <WindowsConstants.au3> $sCurFile = @WindowsDir & "\cursors\hourglas.ani" Global $aCur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str", $sCurFile) If $aCur[0] = "" Then MsgBox(262144 + 16, "", "Cursor file " & $sCurFile & " not found") Exit EndIf $iGuiCenter = @DesktopWidth / 2 $hGui1 = GUICreate("Default Cursor", 300, 200, $iGuiCenter + 10) GUISetState() Global $hGui2 = GUICreate("Chosen Cursor", 300, 200, $iGuiCenter - 310) GUISetState() GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') Do Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam) If $hWnd = $hGui2 Then DllCall("user32.dll", "int", "SetCursor", "int", $aCur[0]) Return 0 EndIf EndFunc ;==>WM_SETCURSOR Link to comment Share on other sites More sharing options...
AetherMaster Posted September 14, 2009 Author Share Posted September 14, 2009 (edited) Thanks, that kind of works, but still shows up as a normal cursor over icons in the ControlGUI. Would someone please take a look at the scrip and see what could fix that? Thanks! expandcollapse popup#NoTrayIcon #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <TabConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <File.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <File.au3> #include <Array.au3> #include <Icons.au3> #include "extra1.au3" #include "extra2.au3" Global Const $winstate = @SW_HIDE ;Func main() $xSpacing = 5 $ySpacing = 50 $xWidth = 445 SplashImageOn("Updating...",@ScriptDir & "\Show\App\update.bmp", 464,223,-1,-1,3) Local $currentver = "212" InetGet ("http://website.com/folder/Downloads/Portapack/version.ini",@ScriptDir & "\version.ini") $latestver = IniRead(@ScriptDir & "\version.ini","Version","vnum","0") SplashOff() If $latestver > $currentver Then _downloadnewver() ElseIf $latestver == "0" Then oopsnonet() EndIf Func _downloadnewver() MsgBox(64,IniRead(@ScriptDir & "\version.ini","Version","title","Newer Version Available!"),IniRead(@ScriptDir & "\version.ini","Version","txt","There is a new version available. Please visit http://WADder.net/forums/ to download the latest version.")) EndFunc Func oopsnonet() MsgBox(64,"Unable to connect","The Portapack was unable to check for a new version. Your current version will now open without checking for updates. Another check will be performed the next time you launch the pack.") EndFunc AutoItSetOption ("TrayIconHide", 1) _SoundLoop(@ScriptDir & "\Show\App\BGM.wav") ;SoundPlay(@ScriptDir & "\Show\App\BGM.wav") ;SoundSetWaveVolume(75) Func WM_NCHITTEST2($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $mainGUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc Func _SoundLoop($sSoundFile, $bLoop = True) Local Const $SND_ALIAS = 0x10000 Local Const $SND_ALIAS_ID = 0x110000 Local Const $SND_APPLICATION = 0x80 Local Const $SND_ASYNC = 0x1 Local Const $SND_FILENAME = 0x20000 Local Const $SND_LOOP = 0x8 Local Const $SND_MEMORY = 0x4 Local Const $SND_NODEFAULT = 0x2 Local Const $SND_NOSTOP = 0x10 Local Const $SND_NOWAIT = 0x2000 Local Const $SND_PURGE = 0x40 Local Const $SND_RESOURCE = 0x40004 Local Const $SND_SYNC = 0x0 If $bLoop Then DllCall('winmm.dll', 'int', 'PlaySoundA', 'str', $sSoundFile, 'int', 0, 'int', BitOR($SND_ASYNC, $SND_FILENAME, $SND_LOOP)) Else DllCall('winmm.dll', 'int', 'PlaySoundA', 'str', $sSoundFile, 'int', 0, 'int', $SND_FILENAME) EndIf EndFunc _GDIPlus_Startup() $pngSrc = @ScriptDir & "\App\BG.png" $mImage = _GDIPlus_ImageLoadFromFile($pngSrc) $width = _GDIPlus_ImageGetWidth($mImage) $height = _GDIPlus_ImageGetHeight($mImage) $mainGUI = GUICreate("WADder Portapack", $width, $height, -1, -1, $WS_POPUP , $WS_EX_LAYERED) SetBitmap($mainGUI, $mImage, 0) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST2") GUISetState() For $i = 0 To 255 Step 5 SetBitmap($mainGUI, $mImage, $i) Next $controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $mainGUI) GUICtrlCreatePic(@ScriptDir & "\Show\App\grey.gif", 0, 0, $width, $height) GUICtrlSetState(-1, $GUI_DISABLE) $WADder = GUICtrlCreateIcon('', 0, 33, 61, 100, 100) GUICtrlSetTip($WADder, 'WADder 2.7.3 by Xuzz') $MyMenu = GUICtrlCreateIcon('',0,133,61,100,100) GUICtrlSetTip($MyMenu, 'MyMenu 1.3.1 by Xuzz and Jacol') $ExIMG = GUICtrlCreateIcon('',0,220,61,100,100) GUICtrlSetTip($ExIMG, 'Extract Everything 1.2 by Jacol') $Ewes = GUICtrlCreateIcon('',0,315,61,100,100) GUICtrlSetTip($Ewes, 'EWES v8 by pbsds') $Exitico = GUICtrlCreateIcon('', 0, 397.5, 30, 10, 10) GUICtrlSetTip($Exitico, 'Exit') $Easter = GUICtrlCreateIcon('', 0, 35, 30, 10, 10) GUICtrlSetTip($Easter, 'Pssssst... Click me!') $Easter2 = GuiCtrlCreateIcon('',0,338,33,13,13) GUICtrlSetTip($Easter2, "I'm just a plain old letter! ...right?") $Show = GUICtrlCreateIcon('',0,330,165,79,19) GUICtrlSetTip($Show, 'Show the More Programs menu') $About = GUICtrlCreateIcon('',0,397.5,46) GUICtrlSetTip($About, 'About the Portapack') $Play = GuiCtrlCreateIcon('',0,203,164,19,19) GUICtrlSetTip($Play, 'Play or restart the background music') $Pause = GUICtrlCreateIcon('',0,222,164,19,19) GUICtrlSetTip($Pause, 'Stop the background music') _SetIcon($WADder, @Scriptdir & "\Show\App\WADder.ico", 0, 100, 100) _SetIcon($MyMenu, @Scriptdir & "\Show\App\MyMenu.ico", 0, 100, 100) _SetIcon($ExIMG, @ScriptDir & "\Show\App\ExIMG.ico", 0, 100, 100) _SetIcon($Ewes, @ScriptDir & "\Show\App\EWES.ico", 0, 100, 100) _SetIcon($Exitico, @ScriptDir & "\Show\App\CloseBtn.ico", 0, 16, 16) _SetIcon($Easter, @ScriptDir & "\Show\App\EasterEgg.ico", 0, 10, 10) _SetIcon($Easter2, @ScriptDir & "\Show\App\Egg2.ico",0,13,13) _SetIcon($Show, @Scriptdir & "\App\Program.ico", 0, 79, 19) _SetIcon($About, @ScriptDir & "\Show\App\About.ico",0,16,16) _SetIcon($Play, @ScriptDir & "\Show\App\Play.ico",0,19,19) _SetIcon($Pause,@ScriptDir & "\Show\App\Pause.ico",0,19,19) $sCurFile = @ScriptDir & "\Show\App\Wii.cur" Global $aCur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str", $sCurFile) If $aCur[0] = "" Then MsgBox(262144 + 16, "", "Cursor file " & $sCurFile & " not found") Exit EndIf $iGuiCenter = @DesktopWidth / 2 GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam) If $hWnd = $mainGUI Then DllCall("user32.dll", "int", "SetCursor", "int", $aCur[0]) Return 0 EndIf EndFunc ;==>WM_SETCURSOR GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete($controlGUI) ;fade out png background For $i = 255 To 0 Step -10 SetBitmap($mainGUI, $mImage, $i) Next ; Release resources _WinAPI_DeleteObject($mImage) _GDIPlus_Shutdown() ExitLoop Case $msg = $WADder Run("C:\Program Files\WADder\wadder.exe") Sleep(1500) Exit Case $msg = $MyMenu Run("C:\MyMenu\mymenu.exe") Sleep(1500) doexit() Case $msg = $ExIMG Run("C:\Program Files\Extract Images\Extract Everything.exe") doexit() Case $msg = $Ewes Run("C:\Ewes v8\GUI.exe") Sleep(1500) doexit() Case $msg = $Exitico doexit() Case $msg = $Easter _SoundLoop(@ScriptDir & "\Show\App\Silent.wav") SoundPlay(@Scriptdir & "\Show\App\KKSong.wav",0) SoundSetWaveVolume(100) Case $msg = $Easter2 Run(@ScriptDir & "\Show\App\CB.exe") Case $msg = $Show GUIDelete($controlGUI) ;fade out png background For $i = 255 To 0 Step -100 SetBitmap($mainGUI, $mImage, $i) Next ; Release resources _WinAPI_DeleteObject($mImage) _GDIPlus_Shutdown() Run(@ScriptDir & "\Show\Portapack.exe") Exit Case $msg = $About _SoundLoop(@ScriptDir & "\Show\App\Silent.wav") ;SoundPlay(@ScriptDir & "\Show\App\Silent.wav") Run(@ScriptDir & "\Show\App\About.exe") Case $msg = $Play _SoundLoop(@ScriptDir & "\Show\App\BGM.wav") ;SoundPlay(@ScriptDir & "\Show\App\BGM.wav") ;SoundSetWaveVolume(75) Case $msg = $Pause _SoundLoop(@ScriptDir & "\Show\App\Silent.wav") ;SoundPlay(@ScriptDir & "\Show\App\Silent.wav") ;SoundSetWaveVolume(75) EndSelect WEnd ;EndFunc Func doexit() GUIDelete($controlGUI) ;fade out png background For $i = 255 To 0 Step -10 SetBitmap($mainGUI, $mImage, $i) Next ; Release resources _WinAPI_DeleteObject($mImage) _GDIPlus_Shutdown() quit() EndFunc Func quit() Exit EndFunc Sorry for being a noob Edited September 14, 2009 by AetherMaster Link to comment Share on other sites More sharing options...
wraithdu Posted September 14, 2009 Share Posted September 14, 2009 Change the return value of the WM_SETCURSOR function to 1 to stop default processing (read MSDN). Link to comment Share on other sites More sharing options...
AetherMaster Posted September 14, 2009 Author Share Posted September 14, 2009 It worked, thanks Link to comment Share on other sites More sharing options...
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