Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Second Mouse Cursor (Alpha)


  • Please log in to reply
19 replies to this topic
friese
  • Guests
  • Last active:
  • Joined: --
here is a very buggy script, makes lot of problems, but its cool, it creates a second mouse curosr completely independent form the original and controls it via numpad:

#persistent


gui, color, 000000
gui -Caption -sysmenu
gui, show, w30 h30 x0 y0, luuu
WinSet, Region, 5-10 0-10 0-0, luuu
winset, alwaysontop, on, luuu
speed = 30
return



Numpad8::
y -= speed
gosub reload
return

Numpad2::
y += speed
gosub reload
return

Numpad4::
x -= speed
gosub reload
return

Numpad6::
x += speed
gosub reload
return



Numpad5::
gosub reload
hwnd := dllcall("WindowFromPoint", "Int", x, "Int", y)
wingetpos, winx, winy,,, ahk_id %hwnd%
temp1 := x - winx
temp2 := y - winy
controlclick, x%temp1% y%temp2%, ahk_id %hwnd%,,,, NA
return


reload:
winset, alwaysontop, on, luuu
xt := x - 1
yt := y - 1
winmove, luuu,, %xt%, %yt%
return
have fun, i know its very crappy, but it works (a bit...)

ManaUser
  • Members
  • 1121 posts
  • Last active: Dec 07 2016 04:24 PM
  • Joined: 24 May 2007
Interesting idea. What inspired you to make it?

  • Guests
  • Last active:
  • Joined: --
i wanted to control vlc on my second tft while playing 3d games in fullscreen, and because that works enough fr me it got te way i n my autostart flder

Bingo324_NLI
  • Guests
  • Last active:
  • Joined: --
Cool and interesting concept. I will use this. I'll also try and refine it too, so you get less bugs.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
The idea of a gui for mouse and use of WindowFromPoint is really great :)
I experimented a little and created a multiple mouse script

You can define up to 20 MouseHotkeys each hotkey will have its own mouse cursor and will be shown on press and hold of that hotkey.
MoveHotkey (KeyDown, KeyLeft...) get activated when one of MouseHotkeys is pressed and deactivated when it releases.
So you need to hold your MouseHotkey and press MoveHotkey to Move the mouse.
Releasing the MouseHotkey will do the controlclick at its coordinates (this will happen only if the mouse was moved too)
Each Mousehotkey can have its own speed, startdelay and color! (you can specify as many as you like 1-20)

All MoveHotkeys are activated uppon press of MouseHotkey!
After moving and releasing MouseHotkey, you can press MouseHotkey again to click and activate that window as well.


! Note ! some of the examples are only to show the effect of value, you definitely should change it to your needs
I hope you find it useful

MainHotkey=      ~LWin|~<^RAlt|~CapsLock|~<^<Alt|Numpad0|NumpadDot

;!!!   the higher the value the slower mouse will move   !!!
speed=         2.5|5|7|10|20|50
startdelay=      30|10|20|40|10|100

color=         0000FF|FF0000|00FF00|AA55EE|EEFF00|553344

KeyUp=          w|Numpad8
KeyDown=        s|Numpad2
KeyLeft=        a|Numpad4
KeyRight=       d|Numpad6
KeyUpLeft=      Numpad7
KeyUpRight=     Numpad9
KeyDownLeft=    Numpad1
KeyDownRight=   Numpad3
Exit=           Escape

;=======================================================================================
#persistent
#MaxHotkeysPerInterval,1000
SetWinDelay,0
SetBatchLines,-1
CoordMode,ToolTip,Screen
CoordMode,Mouse,Screen
StringSplit,color,color,|
StringSplit,speed,speed,|
StringSplit,startdelay,startdelay,|
keys=KeyUp|KeyDown|KeyLeft|KeyRight|KeyUpLeft|KeyUpRight|KeyDownLeft|KeyDownRight
Loop,Parse,MainHotkey,|
{
   hotkeyvar:=RegExReplace(A_LoopField,"\<|\>|\*|\$|\^|\!|\+|\~")
   Hotkey,$%A_LoopField%,Main,UseErrorLevel
   If ErrorLevel
      MsgBox You cannot use HotKey: $%A_LoopField%`nProgram will not work if this is the only Main hotkey
   else
      %hotkeyvar%:=A_Index
}
return

Main:
mainhotkey:=A_ThisHotkey
thishotkey:=RegExReplace(A_ThisHotkey,"\>|\<|\*|\$|\^|\!|\+|\~")
Tooltip:=%thishotkey% ;assign number of tooltip
Loop,Parse,keys,|
   Loop,Parse,%A_LoopField%,|
      Hotkey,% "$*" A_LoopField,Move,On
Hotkey,*%Exit%,Exit,On
If !x%Tooltip%
   ToolTip % "   `n`n",% A_ScreenWidth/2,% A_ScreenHeight/2,%ToolTip%
else
   ToolTip % "   `n`n",% x%ToolTip%,% y%ToolTip%,%ToolTip%
tthwnd:=WinExist("ahk_class tooltips_class32")
WinSet, Region, 1-4 15-18 9-18 13-27 10-28 5-19 1-23, ahk_id %tthwnd%
WinSet,ExStyle,^0x20,ahk_id %tthwnd%
SetToolTipColor(tthwnd,!color%ToolTip% ? color1 : color%ToolTip%)
speed:=!speed%ToolTip% ? speed1 : speed%ToolTip%
startdelay:=!startdelay%ToolTip% ? startdelay1 : startdelay%ToolTip%
KeyWait,%thishotkey%
If InStr(mainhotkey,"~")
   Send, {%thishotkey% Up}
Loop,Parse,keys,|
   Loop,Parse,%A_LoopField%,|
      Hotkey,% "$*" A_LoopField,Move,Off
Hotkey,*%Exit%,Exit,Off
If MouseMoved
{
   wingetpos, winx, winy,,,% "ahk_id " . hwnd:=Dllcall("WindowFromPoint", "Int", x%ToolTip%, "Int", y%ToolTip%)
   KeyWait,%thishotkey%, D T0.15
   ErrorLevel_:=ErrorLevel
   KeyWait,%thishotkey%
   If ErrorLevel_
      ControlClick,% "x" . (x%ToolTip%+1 - winx) . " y" . (y%ToolTip%+5 - winy), ahk_id %hwnd%,,,, NA
   else {
      WinActivate,ahk_id %hwnd%
      WinWaitActive,ahk_id %hwnd%,,0.1
      MouseClick,Left,% (x%ToolTip%+1),% (y%ToolTip%+5)
   }
}
else if !InStr(mainhotkey,"~")
   Send, {%thishotkey%}
ToolTip,,,,%ToolTip%
MouseMoved=
Return

Move:
MouseMoved:=True
WinGetPos,x%ToolTip%,y%ToolTip%,,,ahk_id %tthwnd%
SysGet,xmin,76
SysGet,xmax,78
SysGet,ymin,77
SysGet,ymax,79
Loop
{
   i:=Round(A_Index/speed)
   Loop,Parse,keys,|
   {
      key:=A_LoopField
      Loop,Parse,%A_LoopField%,|
      {
         If GetKeyState(A_LoopField,"P"){
            IfInString,key,Up
               y%ToolTip%-=(y%ToolTip%-i)<=ymin ? 0 : i
            IfInString,key,Down
               y%ToolTip%+=(y%ToolTip%+i)>=ymax ? 0 : i
            IfInString,key,Left
               x%ToolTip%-=(x%ToolTip%-i)<=xmin ? 0 : i
            IfInString,key,Right
               x%ToolTip%+=(x%ToolTip%+i)>=xmax ? 0 : i
            stopbreak:=1
         }
      }
   }
   If !stopbreak
      Break
   stopbreak=
   WinMove,ahk_id %tthwnd%,,% x%ToolTip%,% y%ToolTip%
   Sleep % (startdelay-i) > 1 ? Round(startdelay-i) : 1
}
Return

SetToolTipColor(hwnd,B){
   B := (StrLen(B) < 8 ? "0x" : "") . B
   B := ((B&255)<<16)+(((B>>8)&255)<<8)+(B>>16) ; rgb -> bgr
   DllCall("SendMessage", "Uint", hWnd, "Uint", 1043, "Uint", B, "Uint", 0)   ; TTM_SETTIPBKCOLOR   
}

exit:
ExitApp


ManaUser
  • Members
  • 1121 posts
  • Last active: Dec 07 2016 04:24 PM
  • Joined: 24 May 2007
That's really neat... but I found the way it clicks a little confusing.

Anyway, here's my contribution, prettier (and more accurate) cursors:
If !x%Tooltip%
   ToolTip % "   `n`n",% A_ScreenWidth/2,% A_ScreenHeight/2,%ToolTip%
else
   ToolTip % "   `n`n",% x%ToolTip%,% y%ToolTip%,%ToolTip%
tthwnd:=WinExist("ahk_class tooltips_class32")
WinSet, Region, 1-4 15-18 9-18 13-27 10-28 5-19 1-23, ahk_id %tthwnd%
That section comes 8 lines after "Main:".

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Thats really nice, thanks ManaUser, i've updated my script.
I also changed to wait only for 150 ms for second click (this is to activate the window on click) :wink:

EDIT:
I have changed my script to do a true click when after releasing MouseHotkey it is pressed again (within 150 ms).
I have also added WinSet,ExStyle,^0x20, otherwise tooltip is found at this coordinates.

etopsirhc
  • Members
  • 62 posts
  • Last active: Apr 03 2011 12:27 AM
  • Joined: 12 Mar 2008
AWESOME!!!! as soon as i get my other comp working i'm adding a second mouse on my xbox controler :p
life is but a dream
death is the reality

CraSH23000
  • Members
  • 40 posts
  • Last active: Apr 15 2013 06:03 AM
  • Joined: 22 Jun 2007
I tried this a while back but I did not spend that much time on it. I always wanted to be able to have 2 people using the same computer via 2 mice.

The primary difference is I made mine based on joystick input instead of the numpad.

The post I made: Un-Interrupting Second Mouse Used by Joystick

Awesome to see that I'm not the only one that shows interest in this.

Madd0g_
  • Guests
  • Last active:
  • Joined: --
Would be really cool if the second cursor could be moved by the mouse as well

Instead of holding the win-key to control the other cursor with the keyboard - the modifier key would just switch the mouse control from one cursor to another.

Is it possible at all?

Thanks

GeekDude
  • Spam Officer
  • 391 posts
  • Last active: Oct 05 2015 08:13 PM
  • Joined: 23 Nov 2009
i am using 2nd cursor now... fixed the clicking so it will move the mouse back to original position

blockinput, on
      mousegetpos, newvariablex, newvariabley
      WinActivate, ahk_id %hwnd%
      WinWaitActive, ahk_id %hwnd%,,0.1
      MouseClick, Left, % (x%ToolTip%+1), % (y%ToolTip%+5),, 0
      mousemove, %newvariablex%, %newvariabley%, 0
      blockinput, off


HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Would be really cool if the second cursor could be moved by the mouse as well

Instead of holding the win-key to control the other cursor with the keyboard - the modifier key would just switch the mouse control from one cursor to another.

Is it possible at all?

Thanks


Try this, MasterHotkey + [0-9] will restore mouse position and save latest position:
MasterHotkey=LWin
Hotkey,% "~" MasterHotkey,Master
MouseGetPos,X_0,Y_0
Loop 10
	Hotkey,% "*" . A_Index-1,Change,Off
last:=0
Loop 10
{
	X_%A_Index%:=A_ScreenWidth/2
	Y_%A_Index%:=A_ScreenHeight/2
}
Master:
Loop 10
	Hotkey,% "*" . A_Index-1,On
KeyWait,% SubStr(A_ThisHotkey,2)
Loop 10
	Hotkey,% "*" . A_Index-1,Off
Return

Change:
Hotkey:=SubStr(A_ThisHotkey,2)
MouseGetPos,X,Y
X_%last%:=X
Y_%last%:=Y
MouseMove,% X_%Hotkey%,% Y_%Hotkey%,0
last:=Hotkey
Return


Stefan VV
  • Guests
  • Last active:
  • Joined: --
I have an idea. If you have two mouses make the script get the pid's of each mouse and make a script that allows you to move your second cursor with the second mouse.

Anyway great script.

Madd0g
  • Guests
  • Last active:
  • Joined: --

Try this, MasterHotkey + [0-9] will restore mouse position and save latest position...


That's really nice! Thanks!

RIST
  • Members
  • 39 posts
  • Last active: Aug 17 2012 08:36 PM
  • Joined: 08 May 2008
is any second mouse script for windows7 ?
Keegi Siin ka Eestlane? :)