Jump to content
Sign in to follow this  
chachew

Duplicate cursors with transparent image

Recommended Posts

chachew

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
jguinch

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
chachew

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  

  • Similar Content

    • badcoder123
      By badcoder123
      Hey, all.  
      I've been looking for a way to change cursor colour but not the cursor itself. I've been looking for a couple hours now and can't find anything.  I also don't even know where to start, if anyone has any tips or examples please comment them.
      Thanks
    • Emmhor1
      By Emmhor1
      Hi All,

      MAIN QUESTION:
      Is it possible to Call specific function within a GUI

      So I have a script with multiple functions although I don't want to use every function every time.
      My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.
      I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
      This script is on my work laptops and cannot access it right now.
       
      Who can help me with this?
      GUIcreate
      Func1 
      Func2
      Func3
      Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
      Then a button which executes/calls the selected functions
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
×