|
nudone
|
 |
« on: May 05, 2010, 05:10:22 PM » |
|
i've been using this simple script to slide my cursor around my screen(s) by hitting buttons on my house (these buttons are just assigned to keyboard hotkeys that i'll never normally use). i find the sliding method of moving the cursor very nice - it means i hardly have to move the mouse about on the mat and, i'm not sure why, but it just seems to feel nicer than using an accelerated cursor (i haven't got used to using skwire's MAT app). REQUEST: so, here's the request. although i like this sliding cursor motion - it has to carry out the full autohotkey "MouseMove" function before releasing the cursor - so i can't break the movement part way by moving the cursor with my mouse. does that make sense? in other words: i'd like the buttons on my mouse to start the cursor sliding across the screen BUT as soon as i move the mouse myself - autohotkey releases the cursor and lets me take control. i thought i'd be able to figure this out myself but i soon realised that the "MouseMove" function isn't something i can command to stop. well, not with my basic knowledge. i've included my script if it helps - thanks. Formatted for AutoIt with the GeSHI Syntax Highlighter [ copy or print] ;SlideCursor ;By nudone ;date: 2010-04-26 ScriptVersion=0.2 ;function: Slides mouse cursor across whole screens. For multi-monitor systems. ;CoordMode,Mouse,Screen ;this isn't used ;# = winkey, ! = alt, ^ = control, + = shift Menu,Tray,Icon,%SystemRoot%\system32\SHELL32.dll,101 Menu,Tray,Tip,SlideCursor %ScriptVersion% Hotkey, #k, MoveUp Hotkey, ^!+k, MoveUp ; * to work with programmable mouse buttons (if winkey not accepted) Hotkey, ^!+j, MoveDown Hotkey, #j, MoveDown ; * Hotkey, #+j, MoveLeft Hotkey, ^!+h, MoveLeft ; * Hotkey, #+k, MoveRight Hotkey, ^!+l, MoveRight ; * ;screen sizes TopScreenHeight=1080 MiddleScreenWidth=1920 LeftScreenWidth=1024 RightScreenWidth=1024 ;mouse cursor movement speed VerticalSpeed=5 ; 0 = fastet, 100 = slowest HorizontalSpeed=10 ; Move the mouse upwards: MoveUp: MouseMove, xpos , ypos - (TopScreenHeight *0.95), VerticalSpeed ; Move the mouse downwards: MoveDown: MouseMove, xpos , ypos + (TopScreenHeight *0.95), VerticalSpeed ; Move the mouse to (far) left: MoveLeft: ;MouseMove, xpos - MiddleScreenWidth - LeftScreenWidth , ypos, HorizontalSpeed ; use for 3 screens full travel MouseMove, xpos - LeftScreenWidth , ypos , HorizontalSpeed ; ; Move the mouse to (far) right: MoveRight: ;MouseMove, xpos + MiddleScreenWidth + LeftScreenWidth , ypos, HorizontalSpeed ;use for 3 screens full travel MouseMove, xpos + RightScreenWidth , ypos , HorizontalSpeed
|
|
|
|
Logged
|
|
|
|
|
cranioscopical
|
 |
« Reply #1 on: May 05, 2010, 06:03:35 PM » |
|
i've been using this simple script to slide my cursor around my screen(s) by hitting buttons on my house Clearly you need to modify the home keys.
|
|
|
|
|
Logged
|
Chris
|
|
|
|
Target
|
 |
« Reply #2 on: May 05, 2010, 06:24:22 PM » |
|
i've been using this simple script to slide my cursor around my screen(s) by hitting buttons on my house... for some reason this rang a bell with me too... My initial thoughts on this would be to move the cursor incrementally within a loop (so there is something to break out of) eg [ copy or print] mousegetpos, xpos, ypos loop { mousegetpos, , ypos_ if ypos_ <> ypos break xpos++ mousemove, xpos, ypos, horizontalspeed if xpos = %rightscreenwidth% Break } this is an example only - I haven't tested it, but it should break out of the loop when it reaches the screen width, or if the mouse position varies vertically (this being a horizontal movement)
|
|
|
|
|
Logged
|
"Look wise, say nothing, and grunt. Speech was given to conceal thought" - Sir William Osler
|
|
|
|
|
AndyM
|
 |
« Reply #3 on: May 05, 2010, 09:24:21 PM » |
|
i've been using this simple script to slide my cursor around my screen(s) by hitting buttons on my house Clearly you need to modify the home keys. 
|
|
|
|
|
Logged
|
|
|
|
|
nudone
|
 |
« Reply #4 on: May 06, 2010, 02:38:23 AM » |
|
i've been using this simple script to slide my cursor around my screen(s) by hitting buttons on my house Clearly you need to modify the home keys. heheheh, oh dear. but very good cranioscopical. thanks, Target, i will try your script out when i get chance later. it looks like it will work. i'll let you know. (nice bell pun by the way).
|
|
|
|
« Last Edit: May 06, 2010, 02:40:11 AM by nudone »
|
Logged
|
|
|
|
|
nudone
|
 |
« Reply #5 on: May 06, 2010, 05:13:56 AM » |
|
okay, this is working fine (almost). i just had to change the if statement to use % % and it started working. i've been trying to add a bit of a buffer, or error margin, so that the loop doesn't break instantly when it detects mouse movement - i'm sure it will feel better if the cursor is allowed to move slightly off course as it slides. but, my logic and autohotkey knowledge aren't up to the task (i've not included my OR statements here as they are obviously just completely wrong). could anyone (Target) see how to add a mouse movement buffer or margin to the script below? Formatted for AutoIt with the GeSHI Syntax Highlighter [ copy or print] Hotkey, #k, MoveUp Hotkey, ^!+k, MoveUp ; * to work with programmable mouse buttons (if winkey not accepted) Hotkey, ^!+j, MoveDown Hotkey, #j, MoveDown ; * Hotkey, #+j, MoveLeft Hotkey, ^!+h, MoveLeft ; * Hotkey, #+k, MoveRight Hotkey, ^!+l, MoveRight ; * horizontalspeed=0 ; 0 = fastest, 100 = slowest verticalspeed=0 speedmultiplier=30 ; cursor movement needs speeding up a bit rightscreenwidth=1920 ; width of monitor screenheight=1200 ; height of monitor MoveUp: loop { ypos -= speedmultiplier } MoveDown: loop { ypos += speedmultiplier } MoveLeft: loop { xpos -= speedmultiplier } MoveRight: loop { xpos += speedmultiplier if xpos = %rightscreenwidth% }
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #6 on: May 06, 2010, 05:54:29 AM » |
|
Adjust the FudgeFactor variable to your liking: Formatted for AutoIt with the GeSHI Syntax Highlighter [ copy or print] Hotkey, #k, MoveUp Hotkey, ^!+k, MoveUp ; * to work with programmable mouse buttons (if winkey not accepted) Hotkey, ^!+j, MoveDown Hotkey, #j, MoveDown ; * Hotkey, #+j, MoveLeft Hotkey, ^!+h, MoveLeft ; * Hotkey, #+k, MoveRight Hotkey, ^!+l, MoveRight ; * horizontalspeed=0 ; 0 = fastest, 100 = slowest verticalspeed=0 speedmultiplier=30 ; cursor movement needs speeding up a bit rightscreenwidth=1920 ; width of monitor screenheight=1200 ; height of monitor FudgeFactor=50 MoveUp: loop { If ( xpos_ < ( xpos - FudgeFactor ) OR ( xpos_ > ( xpos + FudgeFactor ) ) ) ypos -= speedmultiplier } MoveDown: loop { If ( xpos_ < ( xpos - FudgeFactor ) OR ( xpos_ > ( xpos + FudgeFactor ) ) ) ypos += speedmultiplier } MoveLeft: loop { If ( ypos_ < ( ypos - FudgeFactor ) OR ( ypos_ > ( ypos + FudgeFactor ) ) ) xpos -= speedmultiplier } MoveRight: loop { If ( ypos_ < ( ypos - FudgeFactor ) OR ( ypos_ > ( ypos + FudgeFactor ) ) ) xpos += speedmultiplier if xpos = %rightscreenwidth% }
|
|
|
|
« Last Edit: May 06, 2010, 05:57:01 AM by skwire »
|
Logged
|
|
|
|
|
nudone
|
 |
« Reply #7 on: May 06, 2010, 06:10:57 AM » |
|
okay, that's great, skwire.
with FudgeFactor=10 and an added FudgeFactorHorizontal=2 (for horizontal cursor slides across the screen), it feels about right.
i'm happy with how things are now - but it would be a near perfect script if the cursor slide could "transition/merge" into the manual cursor movement when user moves the mouse. maybe that is expected way too much though as there could/would be times when the user wants to break the slide immediately - so a set transition would be annoying.
(p.s. i think my OR statement was missing a bracket as it looked about the same - that's reassuring that i wasn't totally out of my depth.)
|
|
|
|
« Last Edit: May 06, 2010, 06:13:18 AM by nudone »
|
Logged
|
|
|
|
|
Perry Mowbray
|
 |
« Reply #8 on: May 06, 2010, 07:34:29 AM » |
|
i'm happy with how things are now - but it would be a near perfect script if the cursor slide could "transition/merge" into the manual cursor movement when user moves the mouse. maybe that is expected way too much though as there could/would be times when the user wants to break the slide immediately - so a set transition would be annoying.
I think you'd need to be careful that you don't end up chasing your cursor all around your monitors? This just reminded me of an Amiga mouse hack the kids loved... a rocket was launched when the programme ran and chased the cursor; the user moved the cursor away from the rocket which then changed course and kept chasing... until it caught up with the cursor and it exploded and the cursor disappeared: just long enough for you to wonder what you were going to do without a cursor (the first time anyway).
|
|
|
|
|
Logged
|
|
|
|
|
nudone
|
 |
« Reply #9 on: May 06, 2010, 07:59:31 AM » |
|
I think you'd need to be careful that you don't end up chasing your cursor all around your monitors?
good point.
|
|
|
|
|
Logged
|
|
|
|
|
nudone
|
 |
« Reply #10 on: May 06, 2010, 11:04:23 AM » |
|
i've updated the script slightly. it now calculates the "virtual" desktop covered by all of the monitors. it doesn't detect monitors being enabled/disabled so the script has to rerun if you are changing that kind of thing. it seems to work correctly, but then, i've based it on my inverted T screen layout (2 on top in the middle, 3 in a row along the bottom): 3 in a row works, 2 vertical works, all 4 works, and 1 main monitor works. i have a request (that i know skwire knows the answer to), for switching the mouse cursor icon to another one - but only whilst the slide cursor function is in operation. i just think it would be nice if a giant cursor appeared whilst the sliding occured. i've had a look on the autohotkey forum but the dllcall function they are talking about for cursor swapping is beyond me. i might try adding something to the script to detect which monitor the cursor is on. it might be handy for the cursor to travel automatically to the side and then up when trying to slide the cursor from the edge screen(s) to the top screen (and down and across when moving from the top screen to the side screens). something like: make cursor slide up if cursor is on middle screen then slide up else if cursor is on left screen then slide to right then up else slide cursor to left and up that sounds simple enough to my basic understanding of autohotkey. i may also attempt to make the cursor slow down as it approaches the edges of the screen (as it did using the original MouseMove function). here's the new script anyway. Formatted for AutoIt with the GeSHI Syntax Highlighter [ copy or print] SysGet, VirtualScreenLeft, 76 ; get the dimensions of the virtual desktop (all screens) SysGet, VirtualScreenWidth, 78 SysGet, VirtualScreenTop, 77 SysGet, VirtualScreenHeight, 79 CoordMode, Mouse, Screen ; make mouse coordinates relative to screen not active window Hotkey, #k, MoveUp Hotkey, ^!+k, MoveUp ; * to work with programmable mouse buttons (if winkey not accepted) Hotkey, ^!+j, MoveDown Hotkey, #j, MoveDown ; * Hotkey, #+j, MoveLeft Hotkey, ^!+h, MoveLeft ; * Hotkey, #+k, MoveRight Hotkey, ^!+l, MoveRight ; * horizontalspeed = 0 ; 0 = fastest, 100 = slowest verticalspeed =0 verticalspeedmultiplier = 50 ; cursor movement needs speeding up a bit horizontalspeedmultiplier = 70 borderstop = 100 ; border around screens to halt cursor slide mainscreenwidth = 1920 ; width of monitor TopEdge := VirtualScreenTop + borderstop ; topmost monitor edge BottomEdge := VirtualScreenHeight + VirtualScreenTop - borderstop ; bottommost monitor edge LeftEdge := VirtualScreenLeft + borderstop ; leftmost monitor RightEdge := VirtualScreenWidth + VirtualScreenLeft - borderstop ; rightmost monitor edge FudgeFactor=10 ; margin of error for vertical slides FudgeFactorHorizontal=2 ; margin of error for horizontal slides MoveUp: ;CoordMode, Mouse, Screen loop { If ( xpos_ < ( xpos - FudgeFactor ) OR ( xpos_ > ( xpos + FudgeFactor ) ) ) ypos -= verticalspeedmultiplier ;if ypos = 0 } MoveDown: ;CoordMode, Mouse, Screen loop { If ( xpos_ < ( xpos - FudgeFactor ) OR ( xpos_ > ( xpos + FudgeFactor ) ) ) ypos += verticalspeedmultiplier ;if ypos = %screenheight% } MoveLeft: loop { If ( ypos_ < ( ypos - FudgeFactorHorizontal ) OR ( ypos_ > ( ypos + FudgeFactorHorizontal ) ) ) xpos -= horizontalspeedmultiplier ;if xpos = 0 } MoveRight: loop { If ( ypos_ < ( ypos - FudgeFactorHorizontal ) OR ( ypos_ > ( ypos + FudgeFactorHorizontal ) ) ) xpos += horizontalspeedmultiplier ;if xpos = %mainscreenwidth% }
|
|
|
|
« Last Edit: May 06, 2010, 11:06:02 AM by nudone »
|
Logged
|
|
|
|
|
Perry Mowbray
|
 |
« Reply #11 on: May 06, 2010, 05:39:23 PM » |
|
i have a request (that i know skwire knows the answer to), for switching the mouse cursor icon to another one - but only whilst the slide cursor function is in operation. i just think it would be nice if a giant cursor appeared whilst the sliding occured. i've had a look on the autohotkey forum but the dllcall function they are talking about for cursor swapping is beyond me.
You mean this one: http://www.autohotkey.com/forum/topic6107.html which actually leads to this one: http://www.autohotkey.com/forum/topic35600.html
|
|
|
|
« Last Edit: May 06, 2010, 05:43:02 PM by Perry Mowbray »
|
Logged
|
|
|
|
|
Perry Mowbray
|
 |
« Reply #12 on: May 06, 2010, 05:40:18 PM » |
|
I think you'd need to be careful that you don't end up chasing your cursor all around your monitors?
good point. In hindsight I think it may be a good idea for a game?  Maybe you need a gameMode??
|
|
|
|
|
Logged
|
|
|
|
|
nudone
|
 |
« Reply #13 on: May 06, 2010, 07:35:11 PM » |
|
yes, they are what i saw - and became no less confused after reading them. i will try to understand it, maybe it's very simple. i have enough fun with this sliding cursor as it is - but you are welcome to modify it into a game, Perry (truth is, it takes me too long to accomplish anything with autohotkey to try "fun" stuff).
|
|
|
|
|
Logged
|
|
|
|
|
Target
|
 |
« Reply #14 on: May 06, 2010, 08:02:34 PM » |
|
i have enough fun with this sliding cursor as it is - but you are welcome to modify it into a game, Perry (truth is, it takes me too long to accomplish anything with autohotkey to try "fun" stuff).
it's all fun (in a hair tearing, teeth grinding kind of way...)
|
|
|
|
|
Logged
|
"Look wise, say nothing, and grunt. Speech was given to conceal thought" - Sir William Osler
|
|
|
|
nudone
|
 |
« Reply #15 on: May 07, 2010, 04:23:44 AM » |
|
i mentioned above that i might try and adapt the script so that it will make the cursor travel around corners - moving from a lower corner screen to the upper middle screen (and vice versa).
but it appears the the script allows for this already, in a buggy kind of way. so that is fortunate.
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #16 on: May 07, 2010, 05:09:13 AM » |
|
yes, they are what i saw - and became no less confused after reading them. i will try to understand it, maybe it's very simple. It is rather simple since Serenity wrapped the functions nicely. Simply add the following function definitions to the BOTTOM of your script: Formatted for AutoIt with the GeSHI Syntax Highlighter [ copy or print] RestoreCursors() { SPI_SETCURSORS := 0x57 DllCall( "SystemParametersInfo", UInt ,SPI_SETCURSORS , UInt ,0, UInt ,0, UInt ,0 ) } SetSystemCursor( Cursor = "", cx = 0, cy = 0 ) { BlankCursor := 0, SystemCursor := 0, FileCursor := 0 ; init SystemCursors = 32512IDC_ARROW,32513IDC_IBEAM,32514IDC_WAIT,32515IDC_CROSS ,32516IDC_UPARROW,32640IDC_SIZE,32641IDC_ICON,32642IDC_SIZENWSE ,32643IDC_SIZENESW,32644IDC_SIZEWE,32645IDC_SIZENS,32646IDC_SIZEALL ,32648IDC_NO,32649IDC_HAND,32650IDC_APPSTARTING,32651IDC_HELP If Cursor = ; empty, so create blank cursor { VarSetCapacity( AndMask, 32*4, 0xFF ), VarSetCapacity( XorMask, 32*4, 0 ) BlankCursor = 1 ; flag for later } Else If SubStr ( Cursor ,1,4 ) = "IDC_" ; load system cursor { Loop, Parse, SystemCursors, `, { CursorName := SubStr( A_Loopfield, 6, 15 ) ; get the cursor name, no trailing space with substr CursorID := SubStr( A_Loopfield, 1, 5 ) ; get the cursor id SystemCursor = 1 If ( CursorName = Cursor ) { CursorHandle : = DllCall( "LoadCursor", Uint ,0, Int,CursorID ) } } If CursorHandle = ; invalid cursor name given { Msgbox,, SetCursor , Error: Invalid cursor name CursorHandle = Error } } { SplitPath, Cursor,,, Ext ; auto-detect type uType := 0x1 uType := 0x2 { Msgbox,, SetCursor , Error: Invalid file type CursorHandle = Error } FileCursor = 1 } { Msgbox,, SetCursor , Error: Invalid file path or cursor name CursorHandle = Error ; raise for later } { Loop, Parse, SystemCursors, `, { { Type = BlankCursor %Type%%A_Index% : = DllCall( "CreateCursor" , Uint ,0, Int,0, Int,0, Int,32, Int,32, Uint ,&AndMask , Uint ,&XorMask ) CursorHandle : = DllCall( "CopyImage", Uint ,%Type%%A_Index% , Uint ,0x2 , Int,0, Int,0, Int,0 ) DllCall( "SetSystemCursor", Uint ,CursorHandle , Int,SubStr ( A_Loopfield , 1, 5 ) ) } { Type = SystemCursor CursorHandle : = DllCall( "LoadCursor", Uint ,0, Int,CursorID ) %Type%%A_Index% : = DllCall( "CopyImage" , Uint ,CursorHandle , Uint ,0x2 , Int,cx , Int,cy , Uint ,0 ) CursorHandle : = DllCall( "CopyImage", Uint ,%Type%%A_Index% , Uint ,0x2 , Int,0, Int,0, Int,0 ) DllCall( "SetSystemCursor", Uint ,CursorHandle , Int,SubStr ( A_Loopfield , 1, 5 ) ) } { Type = FileCursor %Type%%A_Index% : = DllCall( "LoadImageA" , UInt ,0, Str ,Cursor , UInt ,uType , Int,cx , Int,cy , UInt ,0x10 ) DllCall( "SetSystemCursor", Uint ,%Type%%A_Index% , Int,SubStr ( A_Loopfield , 1, 5 ) ) } } } }
Then, to change the cursor, do the following: Formatted for AutoIt with the GeSHI Syntax Highlighter [ copy or print] Cursor := "C:\path\to\my\cursor.cur" SetSystemCursor( Cursor )
Or: Formatted for AutoIt with the GeSHI Syntax Highlighter [ copy or print] SetSystemCursor( "C:\path\to\my\cursor.cur" )
To restore the cursor, simply do: Formatted for AutoIt with the GeSHI Syntax Highlighter [ copy or print] RestoreCursors()
|
|
|
|
|
Logged
|
|
|
|
|
nudone
|
 |
« Reply #17 on: May 07, 2010, 05:30:23 AM » |
|
thank you very much for explaining that, skwire. i might have understood it after a (few) rereads, i just couldn't figure out what was important and what was noise in the thread.
i'll go and implement it now...
|
|
|
|
|
Logged
|
|
|
|
|