Sign in to follow this  
Followers 0
CodyBarrett

Mouse Wrap

26 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



If you are at 5 it jumps the mouse back and forth. Won't let me go to my second monitor ^_^. Other than that, I like it.


Giggity

Share this post


Link to post
Share on other sites

I used to have a similar program... But it didn't crossover if you went to the edge near the X... How about that then?

MDiesel

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

Thats only if both monitors are the same size though...

look at jarvis' _ComputerGetMonitors

Share this post


Link to post
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..

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

#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]

Share this post


Link to post
Share on other sites

#11 ·  Posted

#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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#12 ·  Posted

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.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

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
1 person likes this

Share this post


Link to post
Share on other sites

#15 ·  Posted

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#16 ·  Posted

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

Share this post


Link to post
Share on other sites

#17 ·  Posted

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

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#19 ·  Posted

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

Share this post


Link to post
Share on other sites

#20 ·  Posted

wow, to much fun! makes me think of the astroid game where the ship would wrap the screen (yes I'm getting old) i takes some getting used to


Gnatwork Networks

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