AutoHotkey Community

It is currently May 27th, 2012, 12:29 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: December 11th, 2009, 6:05 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
Updated version in the first post to 0.20.

Changes:
1. Keys may now be configured at the top of the script
2. Changed some modes for the Send command - hopefully this works ok on both XP and Vista.

_________________
Sector-Seven - Freeware tools built with AutoHotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2009, 6:18 pm 
Offline

Joined: May 8th, 2008, 2:58 pm
Posts: 39
Location: C:\ESTONIA\adavere\RIST.rar
why in my windows 7 not work any mouse mod etc, scrol up/down, right click and other work but mouse not move ;/

_________________
Keegi Siin ka Eestlane? :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2009, 6:23 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
I have noticed that Send behaves differently on XP and Vista.

In line 36, try changing the SendMode to either
SendMode Input
SendMode Event
or
SendMode Play

_________________
Sector-Seven - Freeware tools built with AutoHotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2010, 5:36 pm 
Offline
User avatar

Joined: December 30th, 2009, 10:30 pm
Posts: 160
Location: Worcester, Massachusetts
sup old geezers (seriously, y'all are so Bush presidency):

I actually took 20 minutes today to do the exact same thing (i.e. I wanted a better one than the one in the docs, esp with mouse inertia, as you refer to it.) I still have a mouse, this was for laziness :) Mine is much more humble than yours with less support for various functions. Here it is.

Code:
#SingleInstance force
#NoEnv
#InstallKeybdHook
Coordmode, Mouse
Process Priority, , High
SetBatchLines -1
SetKeyDelay, -1
SetMouseDelay, -1
SetWinDelay, 1
NumPadMult = 0
NumPadDiv = 1
D = 1
U = -1
Toggle = 1
Return

Insert::reload
F10::suspend

NumPad4::Send {Browser_Back}
NumPad6::Send {Browser_Forward}

NumPadRight::
NumPadLeft::
NumPadUp::
NumPadDown::
If Down
{
   Down = 0
   Send {Shift Up}
} else {
   Down = 1
   Send {Shift Down}
}
return

NumPad5::
NumPad2::
NumPad1::
NumPad3::
Settimer, ReduceSpeed, Off
Loop
{
   DirX = 0
   DirY = 0
   If (A_Index = 6)
      Speed += 2
   Else If (Speed < 20)
      Speed += Mod(A_Index, 2)
   GetKeyState, NumPad5, NumPad5
   GetKeyState, NumPad2, NumPad2
   GetKeyState, NumPad1, NumPad1
   GetKeyState, NumPad3, NumPad3
   If (NumPad5 = "D")
      DirY -= %Speed%
   If (NumPad2 = "D")
      DirY = %Speed%
   If (NumPad1 = "D")
      DirX -= %Speed%
   If (NumPad3 = "D")
      DirX = %Speed%
   If not DirX and not DirY
      Break
   If (Toggle + 1)
      MouseMove, DirX, DirY, , R
   Else {
      WinGetPos, WinX, WinY, , , A
      WinMove, A, , WinX + DirX, WinY + DirY
   }
   Sleep 1
}
Settimer, ReduceSpeed, -50
Return

ReduceSpeed:
Speed = 0
return

NumPad0::
Send {LButton Down}
LBState = D
While (LBState = "D")
   GetKeyState, LBState, NumPad0
Send {LButton Up}
return

NumPadDot::
Send {RButton Down}
RBState = D
While (RBState = "D")
   GetKeyState, RBState, NumPadDot
Send {RButton Up}
return

NumPad8::
Send {MButton Down}
MBState = D
While (MBState = "D")
   GetKeyState, MBState, NumPad8
Send {MButton Up}
return

NumPadSub::
WUState = D
While (WUState = "D")
{
   MouseClick, WU, , , Ceil(A_Index / 3)
   Sleep 50
   GetKeyState, WUState, NumPadSub
}
return

NumPadAdd::
WDState = D
While (WDState = "D")
{
   MouseClick, WD, , , Ceil(A_Index / 3)
   Sleep 50
   GetKeyState, WDState, NumPadAdd
}
return

NumPadMult = 0
NumPadDiv = 1
D = 1
U = -1

NumPadMult::
NumPadDiv::
ActiveWin := WinActive("A")
WinGet, Maxed, MinMax, ahk_id %ActiveWin%
If Maxed
{
   WinRestore, ahk_id %ActiveWin%
   WinMove, ahk_id %ActiveWin%, , 0, 0, A_ScreenWidth, A_ScreenHeight
}
WinGetPos, x, y, w, h, ahk_id %ActiveWin%
IState = D
If Not CheckKey
   Goto WinResize
If %A_ThisHotkey%
   CheckKey = NumPadMult
Else
   CheckKey = NumPadDiv
Return

WinResize:
If (%A_ThisHotkey% <> 0)
   CheckKey = NumPadMult
Else
   CheckKey = NumPadDiv
While (IState = "D")
{
   GetKeyState, AState, %CheckKey%
   y := y - %AState% * A_Index, h := h + %AState% * A_Index
;   x := x - %AState% * A_Index, w := w + %AState% * A_Index
   If (w > A_ScreenWidth) or (h > A_ScreenHeight)
   {
      WinMaximize, ahk_id %ActiveWin%
      Break
   } Else
      WinMove, ahk_id %ActiveWin%, , x, y, w, h
   GetKeyState, IState, %A_ThisHotKey%
   Sleep 1
}
CheckKey =
Return

NumSevenTimer:
Double = 0
If (MouseWin <> ActiveWin)
   Return
Else If Maxed
   WinRestore, ahk_id %ActiveWin%
Else
   WinMaximize, ahk_id %ActiveWin%
Return

NumPad7::
If Double
{
   SetTimer, NumSevenTimer, Off
   If (MouseWin <> ActiveWin) {
      ActiveWin := MouseWin
      Goto NumSevenTimer
   } Else {
      Double = 0
      WinMinimize, ahk_id %ActiveWin%
      Return
   }
}
MouseGetPos, , , MouseWin
WinGetTitle, WinTitle, ahk_id %MouseWin%
If Not WinTitle
{
   Send {Click}
   Return
}
ActiveWin := WinActive("A")
Double = 1
SetTimer, NumSevenTimer, -200
If (MouseWin <> ActiveWin)
   WinActivate, ahk_id %MouseWin%
WinGet, Maxed, MinMax, ahk_id %MouseWin%
Return

NumPad9::Winclose, A

NumLock::
Toggle := !Toggle
If Toggle
{
   ToolTip, Moving Mouse...
   Settimer, ToolTipOff, -1000
} else {
   ToolTip, Moving Window...
   Settimer, ToolTipOff, -1000
}
Return

ToolTipOff:
ToolTip
Return


As you can see, it is configured like

Code:
[Num][ / ][ * ][ - ]          [ x ][ x ][ x ][WUp]
[ 7 ][ 8 ][ 8 ][ + ]          [ x ][Mid][ x ][WDn]
[ 4 ][ 5 ][ 6 ]           ===>[Bac][Up ][For]
[ 1 ][ 2 ][ 3 ][Ent]          [Lef][Dwn][Rgt][ x ]
[   0    ][ . ]               [LeftClck][RCl]


...where the x's mean there is no function. Anyhoo, I was wondering why it would work fine in everything I wanted EXCEPT for transferring the momentum ONLY in the down/left and down/right directions and ONLY while the mouse is held down? Any thoughts?
I tested your script and it had the same problem (but then again your entire layout is different cause of the hold-mouse-down button)
Have a bright and beautiful day 8) 8)

_________________
★★★ Email me at berban at aim full stop com ★★★


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 7th, 2011, 3:57 am 
Offline

Joined: September 7th, 2011, 3:49 am
Posts: 1
Location: Ecuador
This script works. I have Windows 7 Home Premium 64 bits. All Fine.

Only someone can tell me how to decrease the mouse speed.

I attempted to do this. Change from:

MinSpeed:= 1 ; Pixels to move at the beginning of the movement

to:

MinSpeed:= 0.5 ; Pixels to move at the beginning of the movement

But, no working.

Some Help.

God Bless You.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2011, 4:45 am 
Offline

Joined: March 16th, 2011, 6:12 pm
Posts: 172
Location: Worcester, Massachusetts
Code:
;-------------------------------------------------------------------------------
; No Mouse Today! 0.20
; A Numpad Mouse Replacement (for days without a mouse...)
;-------------------------------------------------------------------------------
;
;   • Disable Numlock to Activate
;   +------------+------------+------------+------------+
;   | Numlock    | / (Toggle) | *          | -          |
;   | Off        | Drag       |            | Center Win |
;   +------------+------------+------------+------------+
;   | 7          | 8          | 9          | +          |
;   | Wheel Up   | Up         | Navgat Fwd | Right Clik |
;   +------------+------------+------------+            |
;   | 4          | 5          | 6          |            |
;   | Left       | Click      | Right      |            |
;   +------------+------------+------------+------------+
;   | 1          | 2          | 3          | Enter      |
;   | Wheel Down | Down       | Navgat Bck | Dbl Click  |
;   +------------+------------+------------+            |
;   | 0 (Hold)                | .          |            |
;   | Constant Move Speed     | Clockwise  |            |
;   +-------------------------+------------+------------+
;   • Hold down Shift while moving for one pixel movement
;   • Hold down Alt for 2468 to act like mouse wheel scroll (4 directions)
;   • Pressing two movement keys together will move diagonally
;   • Pressing Ctrl, Alt or Shift while clicking or mousewheeling works the same
;     as with a normal mouse
;   • Pressing NumpadDot will move the mouse through the four quarters of the
;     screen (clockwise)   
;   
;-------------------------------------------------------------------------------
#SingleInstance Force
#HotkeyInterval 1000
#MaxHotkeysPerInterval 1000
CoordMode Mouse, Screen
SendMode InputThenPlay         ; If not working, try: SendMode Input

; --- GENERAL CONFIGURATION ----------------------------------------------------
  ConstantSpeed := 2      ; Pixels to move when Numpad0 is held down
  MinSpeed      := 1      ; Pixels to move at the beginning of the movement
  MaxSpeed      := 4      ; Pixels to move at the fastest inertia
  Inertia       := 0.1    ; How fast should we increase speed (higher=faster, 0=none)
  InertiaDelay  := 0      ; Number of movements to wait before starting inertia
  WheelSleep    := 80     ; MSeconds to sleep between wheel sends
  MouseSleep    := 10     ; MSeconds to sleep between moving the mouse
 
; --- KEYBOARD CONFIGURATION ---------------------------------------------------
  RightKey      := "NumpadRight"
  DownKey       := "NumpadDown"
  UpKey         := "NumpadUp"
  LeftKey       := "NumpadLeft"
 
  ClickKey      := "NumpadClear"   ; Clear is 5 in the numpad
  DoubleClickKey:= "NumpadEnter"   ; Double click cn also be done by double tapping the click key
  RightClickKey := "NumpadAdd"
  ForwardKey    := "NumpadPgUp"   
  BackKey       := "NumpadPgDn"
 
  WheelUpKey    := "NumpadHome"
  WheelDownKey  := "NumpadEnd"
 
   CornerKey     := "NumpadDel"      ; Moves the mouse between the 4 quarters of the screen
  CenterKey     := "NumpadSub"      ; Centers the mouse on the screen
  DragKey       := "NumpadDiv"      ; Toggle to start/stop dragging 
  ConstantKey   := "NumpadIns"      ; Hold while moving to ignore inertia
 
; --- END OF CONFIGURATION -----------------------------------------------------

Menu Tray, NoStandard
Menu Tray, Add, Exit No Mouse Today!, Exit

SysGet ScreenW, 78
SysGet ScreenH, 79

; • Mouse Moves •
Hotkey *%RightKey%, MouseRight
Hotkey *%DownKey%, MouseDown
Hotkey *%UpKey%, MouseUp
Hotkey *%LeftKey%, MouseLeft
Hotkey %ConstantKey%, MouseConstant

; • Mouse Clicks •
Hotkey *%ClickKey%, MouseClickHandler
Hotkey *%ForwardKey%, MouseForward
Hotkey *%BackKey%, MouseBack
Hotkey $*%DoubleClickKey%, MouseDoubleClick
Hotkey $*%RightClickKey%, MouseRightClick

; • Special Functions •
Hotkey $*%DragKey%, MouseDrag
Hotkey $%CenterKey%, CenterMouse
Hotkey $%CornerKey%, CornerMouse

; • Mouse Wheel •
Hotkey *%WheelUpKey%, MouseWheelUp
Hotkey *%WheelDownKey%, MouseWheelDown

Return

;
; This routine handles the 2468 keys: Mouse moves, or mouse wheel emulation
;
MouseMoveHandler:
  ControlGetFocus, fcontrol, A
 
  Counter := 0
  Loop {
    If( GetKeyState( "Alt", "P" ) ) {    ; Wheel Emulation through Ctrl+2468
   
      WX := ( GetKeyState( RightKey, "P" ) ? 1 : GetKeyState( LeftKey, "P" ) ? 0 : -1 )
      WY := ( GetKeyState( DownKey , "P" ) ? "WheelDown" : GetKeyState( UpKey, "P" )  ? "WheelUp" : -1 )
     
      If( WX<>-1 )
        SendMessage, 0x114, %WX%, 0, %fcontrol%, A  ; 0x114 is WM_HSCROLL and the 0 after it is SB_LINERIGHT.

      If( WY<>-1 )
        SendInput {%WY%}

      Sleep %WheelSleep%
    }
    Else {    ; Mouse moves
     InsPressed := GetKeyState( ConstantKey, "P" )
      Speed := InsPressed ? ConstantSpeed : Counter>InertiaDelay ? MinSpeed+(Counter-InertiaDelay)*Inertia : MinSpeed
      Speed := Speed > MaxSpeed ? MaxSpeed : Speed
      Counter := InsPressed ? 0 : Counter+1      ; Reset Inertia
     
      X := Speed * ( GetKeyState( RightKey, "P" ) ? 1 : GetKeyState( LeftKey, "P" ) ? -1 : 0 )
      Y := Speed * ( GetKeyState( DownKey , "P" ) ? 1 : GetKeyState( UpKey, "P" )   ? -1 : 0 )
     
      If( X or Y ) {
        MouseMove %X%,%Y%,,R
        If( GetKeyState( "Shift" , "P" ) )
          Break
      }
      Else
       Break
     Sleep %MouseSleep%
    }
  }
Return

;
; This routine handles the 17 keys: mouse wheel
;
MouseWheelHandler:
   Loop {
      WUp  := GetKeyState( WheelUpKey, "P" )
      WDn  := GetKeyState( WheelDownKey, "P" ) 
     
      If( WUp ) or ( WDn ) {
         SendEvent % GetModifier() . ( WUp ? "{WheelUp}" : "{WheelDown}" )
         Sleep %WheelSleep%
      }   
      Else
         Break
   }
Return

;
; Hotkeys
; These functions are called when the hotkeys are pressed.
; For each one, if the numlock is off, we will emulate mouse functions,
; otherwise, we will echo the pressed key back to the OS.
;
MouseLeft:
   If( Not GetKeyState( "Numlock", "T" ) )
      Gosub MouseMoveHandler
   Else
      SendInput % GetModifier() . "{" . LeftKey . "}"
Return

MouseRight:
   If( Not GetKeyState( "Numlock", "T" ) )
      Gosub MouseMoveHandler
   Else
      SendInput % GetModifier() . "{" . RightKey . "}"
Return

MouseUp:
   If( Not GetKeyState( "Numlock", "T" ) )
      Gosub MouseMoveHandler
   Else
      SendInput % GetModifier() . "{" . UpKey . "}"
Return

MouseDown:
   If( Not GetKeyState( "Numlock", "T" ) )
      Gosub MouseMoveHandler
   Else
      SendInput % GetModifier() . "{" . DownKey . "}"
Return

MouseConstant:
   If( Not GetKeyState( "Numlock", "T" ) )
      Gosub MouseMoveHandler
   Else
      SendInput % GetModifier() . "{" . ConstantKey . "}"
Return

MouseWheelDown:
   If( Not GetKeyState( "Numlock", "T" ) )
      Gosub MouseWheelHandler
   Else
      SendInput % GetModifier() . "{" . WheelDownKey . "}"
Return

MouseWheelUp:
   If( Not GetKeyState( "Numlock", "T" ) )
      Gosub MouseWheelHandler
   Else
      SendInput % GetModifier() . "{" . WheelUpKey . "}"
Return




MouseClickHandler:
   If( Not GetKeyState( "Numlock", "T" ) )
      SendInput % GetModifier() . "{Click}"
   Else
      SendInput % GetModifier() . "{" . ClickKey . "}"
Return

MouseForward:
   If( Not GetKeyState( "Numlock", "T" ) )
      SendEvent {XButton2}
   Else
      SendInput % GetModifier() . "{" . ForwardKey . "}"
Return

MouseBack:
   If( Not GetKeyState( "Numlock", "T" ) )
      SendEvent {XButton1}
   Else
      SendInput % GetModifier() . "{" . BackKey . "}"
Return

MouseDoubleClick:
  If( Not GetKeyState( "Numlock", "T" ) )
    Click 2
  Else
    SendInput % GetModifier() . "{" . DoubleClickKey . "}"
Return

MouseRightClick:
  If( Not GetKeyState( "Numlock", "T" ) )
    SendInput % GetModifier() . "{RButton}"
  Else
    SendInput % GetModifier() . "{" . RightClickKey . "}"
Return

MouseDrag:
  If( Not GetKeyState( "Numlock", "T" ) ) {
    SendInput % "{LButton " . ( _Drag ? "Up}" : "Down}" )
    _Drag := Not _Drag
  }     
  Else
    SendInput % GetModifier() . "{" . DragKey . "}"
Return

CenterMouse:
  If( Not GetKeyState( "Numlock", "T" ) ) {
    WinGetPos X,Y,W,H,A
    MouseMove % X+W/2, % Y+H/2
  }
  Else
    SendInput % GetModifier() . "{" . CenterKey . "}"
Return

CornerMouse:
  If( Not GetKeyState( "Numlock", "T" ) ) {
      MouseGetPos MX, MY
      NewX := ( MY < ScreenH/2 ) ? ScreenW/4*3 : ScreenW/4
      NewY := ( MX > ScreenW/2 ) ? ScreenH/4*3 : ScreenH/4
    MouseMove %NewX%, %NewY%
  }
  Else
    SendInput % GetModifier() . "{" . CornerKey . "}"
Return


GetModifier() {
  Return GetKeyState( "Ctrl", "P" ) ? "^" : GetKeyState( "Alt", "P" ) ? "!" : GetKeyState( "Shift", "P" ) ? "+" : ""
}

Exit:
  ExitApp
Return

^ESC::ExitApp


Hey watchin_id,
Try the above modification. (Added lines are in red font.) Increase the MouseSleep variable as needed to make the speed slower.
Also, change MinSpeed back to 1.
This code is untested because I don't have a numpad on my laptop - sorry! :(

_________________
★★★ Email me at berban at aim full stop com ★★★


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Cristi®, Google Feedfetcher, tidbit and 57 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