AutoHotkey Community

It is currently May 27th, 2012, 2:52 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: April 8th, 2009, 2:00 am 
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:

Code:
#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...)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2009, 5:19 pm 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
Interesting idea. What inspired you to make it?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2009, 7:10 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject: Second mouse thing
PostPosted: April 9th, 2009, 8:59 am 
Cool and interesting concept. I will use this. I'll also try and refine it too, so you get less bugs.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2009, 2:25 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
The idea of a gui for mouse and use of WindowFromPoint is really great :)
I experimented a little and created a multiple mouse script
MultiMouse wrote:
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

Code:
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

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Last edited by HotKeyIt on April 10th, 2009, 7:24 pm, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2009, 5:29 pm 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
That's really neat... but I found the way it clicks a little confusing.

Anyway, here's my contribution, prettier (and more accurate) cursors:
Code:
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:".


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2009, 7:00 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
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.

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2009, 6:14 am 
Offline

Joined: March 12th, 2008, 8:45 pm
Posts: 62
Location: OR
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2009, 6:30 am 
Offline

Joined: June 22nd, 2007, 4:42 am
Posts: 40
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2009, 11:39 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 11:52 pm 
Offline

Joined: November 23rd, 2009, 2:11 pm
Posts: 104
i am using 2nd cursor now... fixed the clicking so it will move the mouse back to original position

Code:
      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

_________________
  /\ /\ This is Kitty
(>';'<) Cut, copy, and paste kitty onto your sig.
((")(")) Help Kitty gain World Domination.

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2009, 1:00 am 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Madd0g_ wrote:
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:
Code:
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

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 6th, 2009, 6:21 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2009, 4:06 pm 
HotKeyIt wrote:
Try this, MasterHotkey + [0-9] will restore mouse position and save latest position...


That's really nice! Thanks!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2009, 3:47 pm 
Offline

Joined: May 8th, 2008, 2:58 pm
Posts: 39
Location: C:\ESTONIA\adavere\RIST.rar
is any second mouse script for windows7 ?

_________________
Keegi Siin ka Eestlane? :)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group