Sign in to follow this  
Followers 0
chachew

Duplicate cursors with transparent image

3 posts in this topic

So i borrowed this code and made some adjustments to fit my needs. Basically i am wanting to mimic the main windows cursor and create a duplicate cursor at a different location of the monitor. So on code line 18, "ToolTip("^", $mouse[0] + GUICtrlRead($xDistanceInput) - 100, $mouse[1] + GUICtrlRead($yDistanceInput))" i want that to be a transparent PNG image. That image will be a cursor image

#include <Misc.au3>

HotKeySet("{ESC}", "_exit")
$mouse = MouseGetPos()

$xDistanceInput = GUICtrlCreateInput("", 128, 0, 49, 21)
$yDistanceInput = GUICtrlCreateInput("", 128, 24, 49, 21)
_secondMouse()

While 1
    Sleep(10)
WEnd

Func _secondMouse()
    While 1
        Sleep(5)
        $mouse = MouseGetPos()
        ToolTip("^", $mouse[0] + GUICtrlRead($xDistanceInput) - 100, $mouse[1] + GUICtrlRead($yDistanceInput))
        If _IsPressed("01") Then _mouseClick()
        If _IsPressed("78") Then ;HotKeySet{F9}
            ToolTip("")
            ExitLoop
        EndIf
    WEnd
EndFunc   ;==>_secondMouse

Func _mouseClick()
    ToolTip("")
    MouseUp("left")
    MouseMove($mouse[0] + GUICtrlRead($xDistanceInput), $mouse[1] + GUICtrlRead($yDistanceInput), 0)
    MouseDown("left")
    Sleep(50)
    MouseUp("left")
    MouseMove($mouse[0], $mouse[1], 0)
    ToolTip("^", $mouse[0] + GUICtrlRead($xDistanceInput), $mouse[1] + GUICtrlRead($yDistanceInput))
EndFunc   ;==>_mouseClick

Func _exit()
    Exit
EndFunc   ;==>_exit

Share this post


Link to post
Share on other sites



Here is an idea, using a transparent GUI and an icon control with a Windows cursor :

#include <WindowsConstants.au3>
#include <WinAPI.au3>

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

Local $sCursorPic = @WindowsDir & "\Cursors\aero_arrow.cur"
Local $distanceX = 100
Local $distanceY = -10
Local $aPos, $aOldPos


Local $hCursorGUI = GUICreate("DUPLICATE CURSOR", 48, 48, Default, Default, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST) )
Local $picture = GUICtrlCreateIcon($sCursorPic, -1,  0, 0, 48, 48)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hCursorGUI, 0xABCDEF, 255)

GUISetState()

While 1
    $aPos = MouseGetPos()
    If IsArray($aPos) Then
        If $aPos <> $aOldPos Then
            $aOldPos = $aPos
            WinMove($hCursorGUI, "", $aPos[0] + $distanceX, $aPos[1] + $distanceY)
        EndIf
    EndIf

    Sleep(10)
WEnd

Func _Quit()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

Awesome, this works!

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • nlta1992
      By nlta1992
      I want creat GUI, have button 1 to 10, but only use loop for ... to ... step ... next.
      Thanks.
    • ur
      By ur
      We are trying to automate the installation testing before sending to end users, our product.
      For Silent Installation, we have completed this part.
      But for GUI, the default installation is completed by sending the keys based on the window.
      But for GUI custom installation, we are struck.
      How to enable or disable features in the below screen using GUI automation.?

    • AndyS01
      By AndyS01
      When I set the busy cursor on the main gui, it returns to a normal cursor when hovering over any of the controls on the gui window.  This behavior happens regardless of whether I set the 'override' parameter to 1 or to 0.
      Here is my test code:
      #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_UseX64=N Opt("GUICloseOnESC", 1) ; ESC closes GUI? (0 = no, 1 = yes) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt('MustDeclareVars', 1) OnAutoItExitRegister("Event_GUIClose") #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $hMainWin, $statusID, $cnt = 0 _Main() Func _Main() Local $msg $hMainWin = GUICreate("cursor test", 250, 200, -1, -1) GUICtrlCreateListView("ABCdef", 10, 10, 100, 100) GUICtrlCreateButton("override = 1", 130, 10, 100, 25) GUICtrlSetOnEvent(-1, "handle_SetCur_1_btn") GUICtrlCreateButton("override = 0", 130, 50, 100, 25) GUICtrlSetOnEvent(-1, "handle_SetCur_0_btn") $statusID = GUICtrlCreateLabel("", 10, 120, 200, 20) GUICtrlSetBkColor(-1, 0xFFFF00) GUISetOnEvent($GUI_EVENT_CLOSE, 'Event_GUIClose') GUISetState() ; Make everything visible While (1) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect Sleep(125) WEnd EndFunc ;==>_Main Func Event_GUIClose() Exit EndFunc ;==>Event_GUIClose Func handle_SetCur_1_btn() If (Mod($cnt, 2)) Then setIT(15, 1) Else setIT(2, 1) EndIf $cnt += 1 EndFunc ;==>handle_SetCur_1_btn Func handle_SetCur_0_btn() If (Mod($cnt, 2)) Then setIT(15, 0) Else setIT(2, 0) EndIf $cnt += 1 EndFunc ;==>handle_SetCur_0_btn Func setIT($cursorID, $override) Local $str GUISetCursor($cursorID, $override, $hMainWin) $str = "Set " & (($cursorID = 2) ? " normal" : " busy") & " cursor." $str &= " (override = " & $override & ")" ConsoleWrite("+++: " & $str & @CRLF) GUICtrlSetData($statusID, $str) EndFunc ;==>setIT  
    • drapdv
      By drapdv
      I have a GUI with a parent window that has a menu and shortcut buttons at the top, and a child window which displays a list which is scrolled vertically.
      When the list is relatively small, like no more than 100 or so lines then it scrolls fine.  As the list gets larger, scrolling begins to slow, and if you start mixing up the scroll method (mousewheel, left-clicking the scrollbar box, etc) then it begins to hang.  When it hangs, dwm.exe CPU usage maxes out, and I can't even switch to another window.  Each line in the list is 1000px wide X 30px tall, and the lines alternate between a gray background and a white background, in case that matters.
      When a non-Aero theme is active, everything works fine.  So, I could disable DWM every time someone fires it up, but changing a client's color scheme is not ideal.
      I tried to utilize _WinAPI_DwmSetWindowAttribute($oGui_Parent,  $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED), and although it succeeds in disabling DWM for that window, it doesn't seem to make any difference as far as the scrolling lag is concerned.
      The code is several thousand lines long and contains proprietary information, so I'm trying to avoid posting that, but these are the lines which are creating the GUIs.  Is there anything that anyone can think of off the top of their heads, or is there anything jumping out at you from this snippet of code?  Any help is appreciated!
      $oGui_Parent = GUICreate("Data Viewer", 700, 500, Default, Default, BitOR($WS_CAPTION, $WS_MINIMIZEBOX, $WS_POPUPWINDOW)) WinSetTrans($oGui_Parent, "", 255) _WinAPI_DwmSetWindowAttribute($oGui_Parent, $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED) GUISetFont(9, 500, 0, "Calibri") GUISetBkColor(0xFFFFFF) $oGui_Child = GUICreate("", 700, 400, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $oGui_Parent) WinSetTrans($oGui_Child, "", 255) _WinAPI_DwmSetWindowAttribute($oGui_Child, $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED) GUISetFont(9, 500, 0, "Calibri") GUISetBkColor(0xFFFFFF)  
    • siva1612
      By siva1612
      I would like to create a window like the one shown below. The requirements are as below
      1. The title bar should be opaque.
      2. The parent window/Main screen will be below the side menu/child window
      3. The left side of the side menu window should be opaque.
      4. The right side should be semi-transparent. 

       
      Any idea to help?