Jump to content

Mouse Wrap


Recommended Posts

well... its simple.. and i find it easyer to use this then to drag the mouse back to center....

well.. again i was bored.. but yeah this if the mouse is going to go off the screen... then it movesthe cursor to to opposit end.. eh..

#NoTrayIcon
HotKeySet ('!^{ESC}', '_Exit_')
MsgBox (48,'Attention!', 'Mouse Wrap will commence.')
While 1
    $Mgp = MouseGetPos()
    If $Mgp[0] >= @DesktopWidth - 1 Then MouseMove (2, $Mgp[1], 0)
    If $Mgp[0] <= 1 Then MouseMove (@DesktopWidth - 2, $Mgp[1], 0)
    Sleep (100)
WEnd
Func _Exit_ ()
    MsgBox (48,'Attention!', 'Mouse Wrap has been terminated.')
    Exit
EndFunc

CTLR&ALT&ESC closes it....

haha ^_^

Edited by CodyBarrett
Link to comment
Share on other sites

haha.. sorry youknowwho4eva ^_^ i don't have a double moniter... ;) i wouldn't know waht to change for that to make it work... if you want.. instead of 5 change it to 1.. because its difficult to click on the taskbar... :\ so yeah actually ima change it to that right now

Link to comment
Share on other sites

That is a good Idea. Just noticed for you up and down you have the mouse move cords swapped.

Edit: A simple quick fix for me is to change all the @desktopwidth's to @desktopwidth*2 ^_^

Edited by youknowwho4eva

Giggity

Link to comment
Share on other sites

A simple quick fix for me is to change all the @desktopwidth's to @desktopwidth*2 tongue.gif

oh lol thats it?
Link to comment
Share on other sites

ah well...i don't own 2 monitors so i can't test it out... if someone would please post how to do that for other people that have 2 monitors.. im sure that would be appreciated..

Link to comment
Share on other sites

The Vertical wrap does not work properly, but it does work... Didn't put enough time in to figure it out, but I did however figure the Horizontal wrap out on Dual-Monitors...

#NoTrayIcon
HotKeySet ('!^{ESC}', '_Exit_')
MsgBox (48,'Attention!', 'Mouse Wrap will commence.')
While 1
    $Mgp = MouseGetPos()
    If $Mgp[0] >= @DesktopWidth*2 - 1 Then MouseMove (5, $Mgp[1], '')
    $Mgp = MouseGetPos()
    If $Mgp[0] <= 1 Then MouseMove (@DesktopWidth*2-5, $Mgp[1], '')
    $Mgp = MouseGetPos()
    If $Mgp[1] >= @DesktopHeight - 1 Then MouseMove (1, $Mgp[0], '')
    $Mgp = MouseGetPos()
    If $Mgp[1] <= 1 Then MouseMove (@DesktopHeight - 1, $Mgp[0], '')
WEnd
Func _Exit_ ()
    MsgBox (48,'Attention!', 'Mouse Wrap has been terminated.')
    Exit
EndFunc

Oh, and just for the record... @DesktopHeight and @DesktopWidth take on the attributes on the focused monitor I believe... Because at one point my mouse was stuck on my Secondary, using nothing but those macros... I might be wrong, need a comment from a Dev here... ^_^

Or if I weren't busy ATM, I would do some more testing... Stopped by during a break and seen this... Hope it helped. ;)

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

#NoTrayIcon
HotKeySet("{Esc}","_Exit")
$Desktop_Area = WinGetPos("Program Manager")
If $Desktop_Area[0] < 0 Then
    $Desktop_Area[2] -= Abs($Desktop_Area[0])
EndIf
If $Desktop_Area[1] < 0 Then
    $Desktop_Area[3] -= Abs($Desktop_Area[1])
EndIf

While 1
    Sleep(10)
    $Mgp = MouseGetPos()
    If $Mgp[0] > $Desktop_Area[2] - 2 Then 
        MouseMove ($Desktop_Area[0] + 2, $Mgp[1], '')
    ElseIf $Mgp[0] < $Desktop_Area[0] + 2 Then 
        MouseMove ($Desktop_Area[2] - 2, $Mgp[1], '')
    EndIf
    
    If $Mgp[1] > $Desktop_Area[3] - 2 Then 
        MouseMove ($Mgp[0], $Desktop_Area[1] + 2, '')
    ElseIf $Mgp[1] < $Desktop_Area[1] + 2 Then 
        MouseMove ($Mgp[0], $Desktop_Area[3] - 2, '')
    EndIf
WEnd

Func _Exit()
    Exit
EndFunc

should work with multiple monitors.

Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

#NoTrayIcon
 HotKeySet("{Esc}","_Exit")
 $Desktop_Area = WinGetPos("Program Manager")
 If $Desktop_Area[0] < 0 Then
     $Desktop_Area[2] -= Abs($Desktop_Area[0])
 EndIf
 If $Desktop_Area[1] < 0 Then
     $Desktop_Area[3] -= Abs($Desktop_Area[1])
 EndIf
 
 While 1
     Sleep(10)
     $Mgp = MouseGetPos()
     If $Mgp[0] > $Desktop_Area[2] - 2 Then 
         MouseMove ($Desktop_Area[0] + 2, $Mgp[1], '')
     ElseIf $Mgp[0] < $Desktop_Area[0] + 2 Then 
         MouseMove ($Desktop_Area[2] - 2, $Mgp[1], '')
     EndIf
     
     If $Mgp[1] > $Desktop_Area[3] - 2 Then 
         MouseMove ($Mgp[0], $Desktop_Area[1] + 2, '')
     ElseIf $Mgp[1] < $Desktop_Area[1] + 2 Then 
         MouseMove ($Mgp[0], $Desktop_Area[3] - 2, '')
     EndIf
 WEnd
 
 Func _Exit()
     Exit
 EndFunc

should work with multiple monitors.

Yes, it seems to working properly!

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

Very cool! Made me realize how much I depend on the borders of my screen, as I'm constantly using the taskbar and various widgets that pop out of the sides.

Link to comment
Share on other sites

Yes, it seems to working properly!

UEZ

Sorry, it is not working properly!

X border of my 2nd monitor is not working properly! Because I have different screen resolutions.

1st monitor: 1920x1200

2nd monitor: 1280x1024

2nd monitor is above 1st monitor centered.

I will have a look on it and maybe I can fix it!

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

I think I've got my logic right but, as usual, I'm prepared to be wrong. I've used MonitorFromPoint and GetMonitorInfo to determine when and where to wrap especially with multiple monitors. Let me know what you think.

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

Global $hDLL = DllOpen("user32.dll")
Global $rDesktop = WinGetPos("Program Manager")
Global $gMonitorInfo = DllStructCreate("int;int[4];int[4];int;char[32]")
DllStructSetData($gMonitorInfo, 1, DllStructGetSize($gMonitorInfo))

_Main()

Exit

Func _Main()
    Local $aMP, $hMonitor, $rMonitor, $sText
    While 1
        Sleep(10)
        $aMP = MouseGetPos()
        $hMonitor = _GetMonitorFromPoint($aMP[0], $aMP[1])
        If $hMonitor <> 0 Then
            $rMonitor = _GetMonitorRect($hMonitor)
            ; Left
            If ($aMP[0] - $rMonitor[0]) = 0 Then
                If _GetMonitorFromPoint($aMP[0] - 1, $aMP[1]) = 0 Then
                    If _GetMonitorFromPoint($aMP[0] + $rDesktop[2] - 2, $aMP[1]) = 0 Then
                        MouseMove($aMP[0] + $rMonitor[2] - 2, $aMP[1], 0)
                    Else
                        MouseMove($aMP[0] + $rDesktop[2] - 2, $aMP[1], 0)
                    EndIf
                EndIf
            EndIf
            ; Top
            If ($aMP[1] - $rMonitor[1]) = 0 Then
                If _GetMonitorFromPoint($aMP[0], $aMP[1] - 1) = 0 Then
                    If _GetMonitorFromPoint($aMP[0], $aMP[1] + $rDesktop[3] - 2) = 0 Then
                        MouseMove($aMP[0], $aMP[1] + $rMonitor[3] - 2, 0)
                    Else
                        MouseMove($aMP[0], $aMP[1] + $rDesktop[3] - 2, 0)
                    EndIf
                EndIf
            EndIf
            ; Right
            If ($aMP[0] - $rMonitor[0]) = $rMonitor[2] - 1 Then
                If _GetMonitorFromPoint($aMP[0] + 1, $aMP[1]) = 0 Then
                    If _GetMonitorFromPoint($aMP[0] - $rDesktop[2] + 2, $aMP[1]) = 0 Then
                        MouseMove($aMP[0] - $rMonitor[2] + 2, $aMP[1], 0)
                    Else
                        MouseMove($aMP[0] - $rDesktop[2] + 2, $aMP[1], 0)
                    EndIf
                EndIf
            EndIf
            ; Bottom
            If ($aMP[1] - $rMonitor[1]) = $rMonitor[3] - 1 Then
                If _GetMonitorFromPoint($aMP[0], $aMP[1] + 1) = 0 Then
                    If _GetMonitorFromPoint($aMP[0], $aMP[1] - $rDesktop[3] + 2) = 0 Then
                        MouseMove($aMP[0], $aMP[1] - $rMonitor[3] + 2, 0)
                    Else
                        MouseMove($aMP[0], $aMP[1] - $rDesktop[3] + 2, 0)
                    EndIf
                EndIf
            EndIf
        EndIf
    WEnd
EndFunc   ;==>_Main

Func _GetMonitorFromPoint($iX, $iY)
    Local $aRet = DllCall($hDLL, "hwnd", "MonitorFromPoint", "int", $iX, "int", $iY, "int", 0)
    Return $aRet[0]
EndFunc   ;==>_GetMonitorFromPoint

Func _GetMonitorRect($hMonitor)
    Local $aRet = DllCall($hDLL, "int", "GetMonitorInfo", "hwnd", $hMonitor, "ptr", DllStructGetPtr($gMonitorInfo))
    Local $aRect[4]
    For $i = 1 To 4
        $aRect[$i - 1] = DllStructGetData($gMonitorInfo, 2, $i)
    Next
    $aRect[2] -= $aRect[0]
    $aRect[3] -= $aRect[1]
    Return $aRect
EndFunc   ;==>_GetMonitorRect

Func _Quit()
    DllClose($hDLL)
    Exit
EndFunc   ;==>_Quit

EDIT: Some script tidying and removed wrapping line

WBD

Edited by WideBoyDixon
Link to comment
Share on other sites

I think I've got my logic right but, as usual, I'm prepared to be wrong. I've used MonitorFromPoint and GetMonitorInfo to determine when and where to wrap especially with multiple monitors. Let me know what you think.

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

Global $hDLL = DllOpen("user32.dll")
Global $rDesktop = WinGetPos("Program Manager")
Global $gMonitorInfo = DllStructCreate("int;int[4];int[4];int;char[32]")
DllStructSetData($gMonitorInfo, 1, DllStructGetSize($gMonitorInfo))

_Main()

Exit

Func _Main()
    Local $aMP, $hMonitor, $rMonitor, $sText
    While 1
        Sleep(10)
        $aMP = MouseGetPos()
        $hMonitor = _GetMonitorFromPoint($aMP[0], $aMP[1])
        If $hMonitor <> 0 Then
            $rMonitor = _GetMonitorRect($hMonitor)
            ; Left
            If ($aMP[0] - $rMonitor[0]) = 0 Then
                If _GetMonitorFromPoint($aMP[0] - 1, $aMP[1]) = 0 Then
                    If _GetMonitorFromPoint($aMP[0] + $rDesktop[2] - 2, $aMP[1]) = 0 Then
                        MouseMove($aMP[0] + $rMonitor[2] - 2, $aMP[1], 0)
                    Else
                        MouseMove($aMP[0] + $rDesktop[2] - 2, $aMP[1], 0)
                    EndIf
                EndIf
            EndIf
            ; Top
            If ($aMP[1] - $rMonitor[1]) = 0 Then
                If _GetMonitorFromPoint($aMP[0], $aMP[1] - 1) = 0 Then
                    If _GetMonitorFromPoint($aMP[0], $aMP[1] + $rDesktop[3] - 2) = 0 Then
                        MouseMove($aMP[0], $aMP[1] + $rMonitor[3] - 2, 0)
                    Else
                        MouseMove($aMP[0], $aMP[1] + $rDesktop[3] - 2, 0)
                    EndIf
                EndIf
            EndIf
            ; Right
            If ($aMP[0] - $rMonitor[0]) = $rMonitor[2] - 1 Then
                If _GetMonitorFromPoint($aMP[0] + 1, $aMP[1]) = 0 Then
                    If _GetMonitorFromPoint($aMP[0] - $rDesktop[2] + 2, $aMP[1]) = 0 Then
                        MouseMove($aMP[0] - $rMonitor[2] + 2, $aMP[1], 0)
                    Else
                        MouseMove($aMP[0] - $rDesktop[2] + 2, $aMP[1], 0)
                    EndIf
                EndIf
            EndIf
            ; Bottom
            If ($aMP[1] - $rMonitor[1]) = $rMonitor[3] - 1 Then
                If _GetMonitorFromPoint($aMP[0], $aMP[1] + 1) = 0 Then
                    If _GetMonitorFromPoint($aMP[0], $aMP[1] - $rDesktop[3] + 2) = 0 Then
                        MouseMove($aMP[0], $aMP[1] - $rMonitor[3] + 2, 0)
                    Else
                        MouseMove($aMP[0], $aMP[1] - $rDesktop[3] + 2, 0)
                    EndIf
                EndIf
            EndIf
        EndIf
    WEnd
EndFunc   ;==>_Main

Func _GetMonitorFromPoint($iX, $iY)
    Local $aRet = DllCall($hDLL, "hwnd", "MonitorFromPoint", "int", $iX, "int", $iY, "int", 0)
    Return $aRet[0]
EndFunc   ;==>_GetMonitorFromPoint

Func _GetMonitorRect($hMonitor)
    Local $aRet = DllCall($hDLL, "int", "GetMonitorInfo", "hwnd", $hMonitor, "ptr", DllStructGetPtr($gMonitorInfo))
    Local $aRect[4]
    For $i = 1 To 4
        $aRect[$i - 1] = DllStructGetData($gMonitorInfo, 2, $i)
    Next
    $aRect[2] -= $aRect[0]
    $aRect[3] -= $aRect[1]
    Return $aRect
EndFunc   ;==>_GetMonitorRect

Func _Quit()
    DllClose($hDLL)
    Exit
EndFunc   ;==>_Quit

EDIT: Some script tidying and removed wrapping line

WBD

Seems to be working properly!

Well done WBD ^_^

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

Mine are of the same resolution so *2 works for me. Here is what I use and looks great.

#NoTrayIcon
HotKeySet ('!^{ESC}', '_Exit_')
MsgBox (48,'Attention!', 'Mouse Wrap will commence.')
While 1
    $Mgp = MouseGetPos()
    If $Mgp[0] >= @DesktopWidth*2 - 1 Then MouseMove (1, $Mgp[1], '')
    $Mgp = MouseGetPos()
    If $Mgp[0] <= 0 Then MouseMove (@DesktopWidth*2 - 2, $Mgp[1], '')
    $Mgp = MouseGetPos()
    If $Mgp[1] >= @DesktopHeight - 1 Then MouseMove ($Mgp[0],1, '')
    $Mgp = MouseGetPos()
    If $Mgp[1] <= 0 Then MouseMove ($Mgp[0],@DesktopHeight - 2,  '')
WEnd
Func _Exit_ ()
    MsgBox (48,'Attention!', 'Mouse Wrap has been terminated.')
    Exit
EndFunc

Giggity

Link to comment
Share on other sites

The Vertical wrap does not work properly, but it does work.

i found this out... sometimes it sends the cursor to the @desktopwidth ....not sure WHY it does this instead of what its supposed to do

Link to comment
Share on other sites

Like I said, I think in post 4, you have your x and y switched on your vertical move.

Edit: I've been running my short version all day. I'm loving it. It's actually making me think of another project, when I have a lul in work again.

Edited by youknowwho4eva

Giggity

Link to comment
Share on other sites

nahh... it does it no matter what the values are set at.. if its 5 it still does it.. and 1 it does it :\

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...