AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Wheel button emulation script
Goto page Previous  1, 2, 3  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
sinatropus
Guest





PostPosted: Wed Mar 26, 2008 12:28 am    Post subject: Reply with quote

The Iron Savior wrote:

About returning the cursor to its original location. THIS script as it is presented here (v1.1) does not move the mouse back. I did have a version before posting that would try to keep the mouse in the same spot all the time and it worked well and it was even a feature that you could turn off and on. In the end, it didn't really add anything valuable and I didn't like the way it made my code look, so I just scrapped the whole idea.


Personally I consider it very valuable because scroll wheel turn in most CAD, image editing etc programs works as zoom (not as scroll) and it is cursor orientated so it will zoom in to the point under the cursor (not to the center of the window). At the moment cursor position is not constant and therefore zoom target position is moving away from the initial zoom focus point and we end up in a wrong location.

I experimented with BlockInput MouseMove but with no effort because I don't know if it is possible to read the mouse movement without moving the cursor itself? I have very little experience with autohotkey and in programming whatsoever so even this topic is over my head. Any help would be much appreciated. Thanks.
Back to top
gioni
Guest





PostPosted: Wed Apr 09, 2008 8:42 am    Post subject: need help Reply with quote

hey guys,
i need to know if it possible for a script to do the following:

scroll with the ball from my marble mouse, while the other mouse ( a normal usb one) remains "unaffected".

Thank you verry much.
Back to top
BbErSerkK
Guest





PostPosted: Wed Apr 30, 2008 12:32 am    Post subject: Reply with quote

This is the script i use to emulate mouse wheel scrolling with my 3m ergonomic mouse (no scroll wheel)

I've played with it recently and now it has some little glitches, so any feedback welcome.
I would also like to combbine it with "katmouse"/"hotmouse" functionality (e.g. scroll the window under the mouse cursor without losing focus)

But don't have the brains to do it Wink
If anyone could give tips that would be great:
the code for the hotmouse stuff is here but i can't seem to get it to combine: http://www.autohotkey.com/forum/topic6772.html

Code:
MouseWheelSpeed = 1
MouseWheelAccelerationSpeed = 8
MouseWheelMaxSpeed = 15

MouseRotationAngle = 0

Hotkey, MButton & LButton, ButtonWheelDown
Hotkey, MButton & RButton, ButtonWheelUp

ButtonWheelUp:
ButtonWheelDown:

If Button <> 0
{
    If Button <> %A_ThisHotkey%
    {
        MouseWheelCurrentAccelerationSpeed = 0
        MouseWheelCurrentSpeed = %MouseWheelSpeed%
    }
}
StringReplace, Button, A_ThisHotkey, *

ButtonWheelAccelerationStart:
If MouseWheelAccelerationSpeed >= 1
{
    If MouseWheelMaxSpeed > %MouseWheelCurrentSpeed%
    {
        Temp = 0.001
        Temp *= %MouseWheelAccelerationSpeed%
        MouseWheelCurrentAccelerationSpeed += %Temp%
        MouseWheelCurrentSpeed += %MouseWheelCurrentAccelerationSpeed%
    }
}
;MsgBox %Button%
If Button = MButton & RButton
    MouseClick, wheelup, , , ,%MouseWheelCurrentSpeed%,  D
else if Button = MButton & LButton
    MouseClick, wheeldown, , , ,%MouseWheelCurrentSpeed%, D

SetTimer, ButtonWheelAccelerationEnd, 100
return

ButtonWheelAccelerationEnd:
GetKeyState, kstate, LButton, P
if kstate = D
    Goto ButtonWheelAccelerationStart
GetKeyState, kstate, RButton, P
if kstate = D
    Goto ButtonWheelAccelerationStart

MouseWheelCurrentAccelerationSpeed = 0
MouseWheelCurrentSpeed = %MouseWheelSpeed%
Button = 0
return
Back to top
polocanada
Guest





PostPosted: Mon Dec 28, 2009 3:42 am    Post subject: Finaly something for the 3M mouse Reply with quote

BbErSerkK wrote:
This is the script i use to emulate mouse wheel scrolling with my 3m ergonomic mouse (no scroll wheel)



This is GREAT. I also would appreciate if someone looks into this. Have same issue with 3M mouse... no scroll wheel. Comes handy.
Back to top
gutentak
Guest





PostPosted: Tue Feb 16, 2010 5:02 pm    Post subject: Reply with quote

Hi

The script from BbErSerkK does not work for me. I am using Logitech marble trackball under Win7

Has anyone have better solution?

thanks
Back to top
vitor



Joined: 07 Feb 2010
Posts: 9
Location: Belgium

PostPosted: Sat Mar 06, 2010 1:19 pm    Post subject: Reply with quote

xordos wrote:
I just add more change, that I add a delay, so it will only put pointer back after about 100ms.

Hope this is better Smile


Great script. Was looking for this for a long time, cause I have tablet PC and a two button pen, so scrolling was hard for me.

Just one small request...
Is it possible to launch the script by pressing xbutton1 (scroll button/combination), and closing the script by releasing it ?
I'm a "running processes maniac" Wink

Thanks anyway.

___________________________________________________
TOSHIBA Portege M700, Intel Core2 DUO, T8100 @ 2.1GHz, 2,0GB RAM
MS Windows XP Tablet Edition SP3
EmergeDesktop, Samurize, StokeIt, DOpus, PDF Revu, AHK, MenuApp.
Back to top
View user's profile Send private message
Tiago Valente
Guest





PostPosted: Thu Mar 18, 2010 12:11 am    Post subject: Logitech marble mouse and Cad software Reply with quote

I have a logitech marble mouse and have being trying to use it with a Cad application, like Autocad.
The scripts that were posted, helped me using the zooming function, by pressing a thrid button (little left one).
However for using the pan function, a regular mouse with a wheel needs to press the middle button, and then move the mouse. With the posted script's i couldn't reply this situation, because if i press the thrid little button and use the ball it only zooms.
It is possible to replicate the panning function by pressing a fourth little button and moving the ball to enable the panning function in autocad?
Can anyone, please help me, as I have no experince in creating scripts for autohotkey??


Thanks, and keep up the great work!
Back to top
The Iron Savior



Joined: 16 Aug 2005
Posts: 6

PostPosted: Tue Mar 30, 2010 11:47 am    Post subject: Re: Logitech marble mouse and Cad software Reply with quote

Tiago Valente wrote:
I have a logitech marble mouse and have being trying to use it with a Cad application, like Autocad.
The scripts that were posted, helped me using the zooming function, by pressing a thrid button (little left one).
However for using the pan function, a regular mouse with a wheel needs to press the middle button, and then move the mouse. With the posted script's i couldn't reply this situation, because if i press the thrid little button and use the ball it only zooms.
It is possible to replicate the panning function by pressing a fourth little button and moving the ball to enable the panning function in autocad?
Can anyone, please help me, as I have no experince in creating scripts for autohotkey??


Thanks, and keep up the great work!


Yeah, that's entirely possible. I assume that panning is done with a tilting mouse wheel when the wheel is tilted left or right? If that is the case, then I can have it track the side to side motion and create left and right tilt events as well.
Back to top
View user's profile Send private message
The Iron Savior



Joined: 16 Aug 2005
Posts: 6

PostPosted: Tue Mar 30, 2010 12:04 pm    Post subject: Reply with quote

vitor wrote:

Just one small request...
Is it possible to launch the script by pressing xbutton1 (scroll button/combination), and closing the script by releasing it ?
I'm a "running processes maniac" :wink:

If you're concerned about performance, you should know that it's much worse to constantly start and kill even such a tiny process like AHK. It's much better to leave it running. There's no shame in having many processes running at once, especially if they do what you want them to do.
Back to top
View user's profile Send private message
danzzzzz
Guest





PostPosted: Mon May 31, 2010 1:55 pm    Post subject: i was looking for that for sooo long Reply with quote

hi,

great thin,exactly what i was looking for for some time. i am using a wacom tablet and tried to use it in AutoCAD, but always got anoyed by the missing scrollwheelfunction...
thanks!
Back to top
gawy



Joined: 01 Jun 2010
Posts: 2

PostPosted: Tue Jun 01, 2010 5:47 pm    Post subject: Reply with quote

Hi, thanks for this awsome script. I tried it for a day and works pretty good but made a similar script after a quick learn of the AutoHotkey syntax. I've added the possibility to scroll in both X and Y direction and also enabled the browser forward and backwards options as I was really missing those.

And one other thing that I've also added is so that the window where the mouse pointer currently are pointing to will gain focus upon clicking one of the designated keys.

Hope this will help someone ^^

Code:

;;
;; MarbleMagic 1.1
;; "Logitech Marble Mouse Optical" Configuration
;; Version: 1.1 (Jun 1, 2010)
;;
;; Created by Gawy, gawy.gawy@gmail.com

;;
;; Enables you to both scroll and use the back & forward
;; buttons for web browsing!
;;
;; Current configuration is:
;;       Left small button = Back (in browser)
;;      Left small button + right big = Forward (in browser) (Hold down the left small while pressing the right big)
;;      Right small button = Enable scrolling with the trackball (Right small has to be held down)
;;
;; I wrote this simple code for the Logitech Marble Mouse as
;; it doesn't support scrolling by default and because the
;; logitech software sucks for customization.
;;

;; //Configuration
   ;; //Display a tray icon or not
   ;#NoTrayIcon

   ;; // Enable/disable
   mm_EnableScrollX = y
   mm_EnableScrollY = y
   mm_EnableBrowserButtons = y
   mm_EnableFocusGain = y ;; // Enable/disable windows focusing
   
   ;; //Lower = slower scrolling, 1.2 is pretty smooth
   mm_ScrollAcceleration := 1.2
   
   ;; // Higher = slower scrolling (is dependent on the ScrollAcceleration!)
   mm_VerticalScrollMultiplier := 1
   
   ;; // Higher = slower scrolling (is dependent on the ScrollAcceleration!)
   mm_HorizontalScrollMultiplier := 20
   
   ;; // Higher = lower sense between X and Y scrolling, I would suggest moving it at 2 (will only take integers!)
   mm_XScrollDivider := 2
   
   ;; // Timer
   mm_TimerDelay := 10
   
   ;; // Triggers
   ;; //XButton2 = Right small, XButton1 = Left small, RButton = Right mouse button
   mm_ScrollTrigger = XButton2   
   mm_BrowseBackwardsTrigger = XButton1
   mm_BrowseForwardsTrigger = XButton1 & RButton
   
;; //End of configuration

#Persistent
   CoordMode, Mouse, Screen
   Hotkey, %mm_ScrollTrigger%, mm_ScrollTriggerDown
   HotKey, %mm_ScrollTrigger% Up, mm_ScrollTriggerUp
   
   if mm_EnableBrowserButtons = y
   {
      HotKey, %mm_BrowseForwardsTrigger%, mm_TriggerBrowseForward
      HotKey, %mm_BrowseBackwardsTrigger%, mm_TriggerBrowseBackward
   }
   
   mm_KeyDown = n
return


;;;;;;;;;;;;;;;;
;; SETTERS
;;;;;;;;;;;;;;;;

;; //The backward action in the browser
mm_TriggerBrowseBackward:
   if mm_EnableFocusGain = y
      GainFocus()
   
   SendInput, {Browser_Back}
return

;; //The forward action in the browser
mm_TriggerBrowseForward:
   if mm_EnableFocusGain = y
      GainFocus()
      
   SendInput, {Browser_Forward}
return

;; //Scroll is triggered, update timers
mm_ScrollTriggerDown:
   
   if mm_EnableFocusGain = y
      GainFocus()

   mm_HasMoved = n   
   mm_KeyDown = y
   MouseGetPos, temp_OldX, temp_OldY
   MouseGetPos, temp_OrigX, temp_OrigY
   SetTimer, mm_CheckForScrollEvent, %mm_TimerDelay%
return

;; //Scroll is untriggered (key up), check if it was a simple click or if we scrolled
mm_ScrollTriggerUp:
   ;; //Key is not down any more
   mm_KeyDown = n
   
   ;; //Turn of the scrollevent timer
   SetTimer, mm_CheckForScrollEvent, Off
   
   ;; //Send a middle-click if we did not scroll
   if mm_HasMoved = n
      MouseClick, Middle
return

;; //Used for checking scroll position
mm_CheckForScrollEvent:
   
   ;; //If there is no key down, we don't want to do anything
   if mm_KeyDown = n
   {
      SetTimer, mm_CheckForScrollEvent, Off
      return
   }   
   
   ;; //Get the current position
   MouseGetPos, mm_NewX, mm_NewY
   
   ;; //Calculate the difference in Y
   
   if mm_EnableScrollY = y
      mm_MoveDistanceY := (mm_NewY - temp_OldY)
   else
      mm_MoveDistanceY := 0
   
   if mm_EnableScrollX = y
      mm_MoveDistanceX := (mm_NewX - temp_OldX)
   else
      mm_MoveDistanceX := 0
      
   ;; //Have we moved or not?
   if (mm_MoveDistanceY == 0 && mm_MoveDistanceX == 0)
      return
   
   ;; //We have movement, so no middle click
   mm_HasMoved = y

   if Abs(mm_MoveDistanceY) > Abs(mm_MoveDistanceX) // mm_XScrollDivider
   {
      ;; //Check if we moved down or up
      if mm_MoveDistanceY > 0
      {
         ;; //Moved down, move the scroll the correct position
         Loop
         {
            if mm_MoveDistanceY <= 0
               break
               
            MouseClick, WheelDown
            mm_MoveDistanceY -= mm_ScrollAcceleration * mm_VerticalScrollMultiplier
         }
      }
      else if mm_MoveDistanceY < 0
      {
         ;; //We moved up
         Loop
         {
            ;; //Loop until the distance has changed to below zero
            if mm_MoveDistanceY >= 0
               break
               
            MouseClick, WheelUp
            mm_MoveDistanceY += mm_ScrollAcceleration * mm_VerticalScrollMultiplier
         }      
      }
   }
   else
   {
      ;; //Check if we moved right or left
      if mm_MoveDistanceX > 0
      {
         ;; //Moved right, move the scroll the correct position
         Loop
         {
            if mm_MoveDistanceX <= 0
               break
               
            MouseClick, WheelRight
            mm_MoveDistanceX -= mm_ScrollAcceleration * mm_HorizontalScrollMultiplier
         }
      }
      else if mm_MoveDistanceX < 0
      {
         ;; //We moved left
         Loop
         {
            ;; //Loop until the distance has changed to below zero
            if mm_MoveDistanceX >= 0
               break
               
            MouseClick, WheelLeft
            mm_MoveDistanceX += mm_ScrollAcceleration * mm_HorizontalScrollMultiplier
         }      
      }
   }

   ;; //Move and reset mouse position
   MouseMove, temp_OrigX, temp_OrigY
   MouseGetPos, temp_OldX, temp_OldY
   
return

;;;;;;;;;;;;;;;;
;; HELPERS
;;;;;;;;;;;;;;;;

;; //Sets focus for a window
GainFocus()
{
   ;; //Get mouse window
   MouseGetPos,,, MouseWin
   
   ;; //Make a dll call to ask for focus
    DllCall("SwitchToThisWindow", "UInt", MouseWin, "UInt", 1)
}
Back to top
View user's profile Send private message
valiskane



Joined: 23 Sep 2010
Posts: 1

PostPosted: Thu Sep 23, 2010 8:35 pm    Post subject: Reply with quote

Thanks gawy, I was looking for something like this. I was wondering if you might know how to make it so it will work for horizontal scrolling in Excel? It tries to move but doesn't go. I am new at this so I have no clue what I'd need to do.

Thanks,
Back to top
View user's profile Send private message
gawy



Joined: 01 Jun 2010
Posts: 2

PostPosted: Tue Dec 28, 2010 7:42 am    Post subject: Reply with quote

valiskane wrote:
Thanks gawy, I was looking for something like this. I was wondering if you might know how to make it so it will work for horizontal scrolling in Excel? It tries to move but doesn't go. I am new at this so I have no clue what I'd need to do.

Thanks,


Havn't scripted in autohotkey since I made those changes so I really don't know. It seems that the script doesn't really focus on the object sometimes (or that it's not 100% emulated scrolling). I'll try to checkup on it when I got time if nobody else knows how.

Gawy
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Jan 04, 2011 12:17 pm    Post subject: Re: need help Reply with quote

gioni wrote:
hey guys,
i need to know if it possible for a script to do the following:

scroll with the ball from my marble mouse, while the other mouse ( a normal usb one) remains "unaffected".

Thank you verry much.
Arrow Rolling Eyes
Back to top
Guest






PostPosted: Fri Jan 14, 2011 11:13 pm    Post subject: Reply with quote

Thanks! Exactly what I needed for a Logitech Marble.
The scroll amount seems to be much bigger than usual, I seem to get almost an entire page each time. Adjusting the lines per scroll doesn't help, neither in the Windows (7) control panel, nor in SetPoint.
Any way to change the WheelUp / Down amount?
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group