Jump to content

is possible to place a cursor below gui


nuevito4
 Share

Recommended Posts

No cursor always has top most attribute.

I didn't find anything in autoit but I did find nomousy from autohotkey so I am sure it can be done. I figured out that while watching a video in windows media player the mouse disapears so it is possible, don't know how in autoit though.

; Method 1: Hides the cursor in client area
; Uncomment following line for example
; GUISetCursor(16, 1)

; Method 2: Hides cursor for entire window (even the titlebar)
; Uncomment following line for example
; DllCall('user32.dll', 'int', 'ShowCursor', 'int', 0)
Edited by rogue5099
Link to comment
Share on other sites

You mean something like this:

;fast hack by UEZ 2011
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>


_GDIPlus_Startup()
$hBMP = _CreateBitmapFromIcon(0xABCDEF)
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
$hGUI = GUICreate("", 12, 20, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF)
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
 _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)

HotKeySet("{ESC}", "_Exit")

$hWnd =  GUICreate("Test", 320, 200, -1, -1, Default,  $WS_EX_TOPMOST)
GUISetState()

GUIRegisterMsg($WM_PAINT, "WM_PAINT")
DllCall('user32.dll', 'int', 'ShowCursor', 'int', 0)

 While GUIGetMsg() <> -3

     $mpos = MouseGetPos()
     WinMove($hGui, "", $mpos[0], $mpos[1])
    Sleep(10)
WEnd

Func _Exit()
    _GDIPlus_BitmapDispose($hBitmap)
    _WinAPI_DeleteObject($hBMP)
    _GDIPlus_Shutdown()
    GUIDelete($hWnd)
    GUIDelete($hGUI)
    DllCall('user32.dll', 'int', 'ShowCursor', 'int', 1)
    Exit
EndFunc

Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
   _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_PAINT

Func _CreateBitmapFromIcon($iBackground = 0x00000, $iIndex = 0, $iWidth = 12, $iHeight = 20)
    Local $hDC, $hBackDC, $hBackSv, $hIcon, $hBitmap
    $hDC = _WinAPI_GetDC(0)
    $hBackDC = _WinAPI_CreateCompatibleDC($hDC)
    $hBitmap = _WinAPI_CreateSolidBitmap(0, $iBackground, $iWidth, $iHeight)
    $hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap)
    $hIcon = _WinAPI_CopyIcon(_WinAPI_LoadCursor(0, 32512))
    If Not @error Then
        _WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, 0, 0, 0, 0, 3)
        _WinAPI_DestroyIcon($hIcon)
    EndIf
    _WinAPI_SelectObject($hBackDC, $hBackSv)
    _WinAPI_ReleaseDC(0, $hDC)
    _WinAPI_DeleteDC($hBackDC)
    Return $hBitmap
EndFunc   ;==>_CreateBitmapFromIcon


Func _WinAPI_LoadCursor($hInstance, $sName)
    Local $TypeOfName = 'int'
    If IsString($sName) Then
        $TypeOfName = 'wstr'
    EndIf
    Local $Ret = DllCall('user32.dll', 'ptr', 'LoadCursorW', 'ptr', $hInstance, $TypeOfName, $sName)
    If (@error) Or (Not $Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
EndFunc   ;==>_WinAPI_LoadCursor

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Hi. is possible to place a cursor below gui

Posted Image

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate("test", 220, 120, -1, -1)
WinSetOnTop("test", "", 1)
GUISetState(@SW_SHOW)
Sleep(2000)

:)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>
HotKeySet("{ESC}", "Terminate")

$Gui = GUICreate("My GUI")
GUISetState(@SW_SHOW)
_WinAPI_SetCapture($Gui)
_WinAPI_SetCursor(0)
GUIRegisterMsg($WM_SETCURSOR, "ON_SETCURSOR")

While 1
$msg = GUIGetMsg()
WEnd

Func ON_SETCURSOR($hWnd, $Msg, $wParam, $lParam)
_WinAPI_SetCursor(0)
Return $GUI_RUNDEFMSG
EndFunc

Func Terminate()
    Exit 0
EndFunc
Edited by wolf9228

صرح السماء كان هنا

 

Link to comment
Share on other sites

thanks for responding. The idea is to put an animation with AutoIt and replace the cursor.

utilis part of the script of "flyufo"

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

HotKeySet("{Esc}", "Quit")

Global $Gif = @ScriptDir & "\homero.gif"
Global $i = 0, $ApX, $ApY, $ApW, $ApH, $eX, $eY
Global $hImage, $hBitmap, $hScrDC, $hMemDC, $tSize, $pSize, $tSource, $pSource, $tBlend, $pBlend
Global $GFC, $GFDC, $pDimensionIDs, $tDL
Global $Pause

$hGUI = GUICreate("FlyUfo", 0, 0, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
GUISetState()

GifInit()

AdlibRegister("mousep", 10)

Func mousep()
    $mpos = MouseGetPos()
    WinMove("FlyUfo", "", $mpos[0] - 60, $mpos[1] - 50)
EndFunc   ;==>mousep


While 1
    If $i = $GFC Then $i = 0
    GifDrawFrame($i)
    Sleep(100)
    $i += 1
WEnd

Func Quit()
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
    _GDIPlus_Shutdown()
    HotKeySet("{Esc}")
    Exit
EndFunc   ;==>Quit

Func GifInit()
    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile($Gif)
    $ApW = _GDIPlus_ImageGetWidth($hImage)
    $ApH = _GDIPlus_ImageGetHeight($hImage)
    $hScrDC = _WinAPI_GetDC($hGUI)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $tSize = DllStructCreate($tagSIZE)
    DllStructSetData($tSize, "X", $ApW)
    DllStructSetData($tSize, "Y", $ApH)
    $pSize = DllStructGetPtr($tSize)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    DllStructSetData($tBlend, "Alpha", 255)
    DllStructSetData($tBlend, "Format", 1)
    $pBlend = DllStructGetPtr($tBlend)
    $tDL = DllStructCreate($tagGUID)
    $pDimensionIDs = DllStructGetPtr($tDL)
    $GFDC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsCount", "ptr", $hImage, "int*", 0)
    DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsList", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $GFDC[2])
    $GFC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameCount", "int", $hImage, "ptr", $pDimensionIDs, "int*", 0)
    $GFC = $GFC[3]
EndFunc   ;==>GifInit

Func GifDrawFrame($i)
    DllCall($ghGDIPDll, "int", "GdipImageSelectActiveFrame", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $i)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
EndFunc   ;==>GifDrawFrame

post-63388-0-92446600-1298960541_thumb.g

Link to comment
Share on other sites

Have a look to _WinAPI_SetSystemCursor() function from WinAPIEx.au3!

You have to convert the animated GIF to an ani format.

I tested it with an existing .ani file and it is working properly.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...