Jump to content

GUI more than TOPMOST?


algiuxas
 Share

Recommended Posts

Hello,

I'm trying to make cursor for my program, and I need to make it on top but not active when pressed on start menu, taskbar or etc. (cursor appears behind taskbar/start menu).
Somebody could help me with this problem?

; A bit of my script

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <GuiListBox.au3>

Global $Bitmap_Mouse_Pic_Dir = @ScriptDir&"\Cursor.png"
Global $Bitmap_Mouse_Pic = _GetWHI($Bitmap_Mouse_Pic_Dir)
Global $Bitmap_Mouse_PicSel_Dir = @ScriptDir&"\Selection.png"
Global $Bitmap_Mouse_PicSel = _GetWHI($Bitmap_Mouse_PicSel_Dir)
Global $Bitmap_Mouse_Opt = 255

; ...
For $i = 0 to 0
    $GP_guicur[$i] = GUICreate("GP Cursor", 64, 64, $POS[$i][0], $POS[$i][1], $WS_POPUP, $WS_EX_LAYERED, $GUI)
    WinSetOnTop($GP_curgui[$i],"",1)
    SetBitmap($GP_curgui[$i], $Bitmap_Mouse_Pic, $Bitmap_Mouse_Opt)
    GUISetState(@SW_SHOW)
Next
; ...
For ; ...
    Sleep(1000)
    MouseClick("left",5,@DesktopHeight-5)
    ; ...
Next
Exit

;______________________________________________________________________;
;       Original program by Ejoc                                       ;
;       Improved by Adam1213 (autoit 3.2 compatiblity + improved labels;
;______________________________________________________________________;
; $sImage = Path to your image
; Returns = Array[3]
;         $Array[0] = Width
;         $Array[1] = Height
;         $Array[2] = handle to a HBITMAP
; when the image is no longer needed use _WinAPI_DeleteObject($Array[2])
Func _GetWHI($sImage)
    Local $hImage, $aBitmap[3]
    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile($sImage)
    $aBitmap[0] = _GDIPlus_ImageGetWidth($hImage)
    $aBitmap[1] = _GDIPlus_ImageGetHeight($hImage)
    $aBitmap[2] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()
    Return $aBitmap
EndFunc   ;==>_GetWHI

; I changed this so I could shutdown gdiplus once an image has been loaded by _GetWHI()
; just pass it the array returned by _GetWHI()
Func SetBitmap($hGUI, $aBitmap, $iOpacity)
    Local Const $AC_SRC_ALPHA = 1
    Local $hScrDC, $hMemDC, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hOld = _WinAPI_SelectObject($hMemDC, $aBitmap[2])
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $aBitmap[0])
    DllStructSetData($tSize, "Y", $aBitmap[1])
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetBitmap


Thanks :)

Edited by algiuxas

After switching years ago to Linux, sadly I don't use AutoIt anymore.

Link to comment
Share on other sites

I fixed it: 

$WinActive = WinActive( "[ACTIVE]" )
        If $WinActive <> $WinActiveN then
            For $i = 0 to $GP_all
                ConsoleWrite("!")
                WinSetOnTop( $GP_gui[$i][0], "", 1 )
            Next
        EndIf
        $WinActiveN = $WinActive

After switching years ago to Linux, sadly I don't use AutoIt anymore.

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

×
×
  • Create New...