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 

How to Simulate Mouse Back and Forward Buttons

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
azstuenthome



Joined: 03 Nov 2008
Posts: 7

PostPosted: Tue Oct 20, 2009 11:12 pm    Post subject: How to Simulate Mouse Back and Forward Buttons Reply with quote

My mouse does not have back or forward buttons. How can I use AHK to simulate pressing these buttons on the mouse? I found an AHK script called Mouse Gestures which interprets mouse gestures (http://www.autohotkey.com/forum/viewtopic.php?t=1435). I just need to know what keys/commands to assign to the appropriate gesture.

Any help would be much appreciated.
Back to top
View user's profile Send private message
txquestor



Joined: 22 Aug 2009
Posts: 294

PostPosted: Wed Oct 21, 2009 12:37 am    Post subject: Reply with quote

Which action are you referring to:

scroll ball left and right
or
horizontal scroll forward/back
or
browser forward/back

Check this key/button list link:
http://www.autohotkey.com/docs/commands/Send.htm Or
Send command

Examples:
Code:

; scroll ball left and right
; or
; horizontal scroll forward/back
; or
; browser forward/back

#InstallKeybdHook

; Scroll Left/Right
$+<::Send {Left}   ; Shift+Left Arrow
$+>::Send {Right}   ; Shift+Right Arrow

~LButton:: ; Left Mouse Button, Scroll left
ControlGetFocus, fcontrol, A   ; get control with input focus
Loop 2  ; <-- Increase this value to scroll faster.
    SendMessage, 0x114, 0, 0, %fcontrol%, A  ; 0x114 is WM_HSCROLL and the 0 after it is SB_LINELEFT. OR
    SendMessage, 0x115, 0, 0, %fcontrol%, A  ; 0x114 is WM_VSCROLL - vertical scrolling
return

~RButton::  ; Right Mouse Button, Scroll right.
ControlGetFocus, fcontrol, A
Loop 2  ; <-- Increase this value to scroll faster.
    SendMessage, 0x114, 1, 0, %fcontrol%, A  ; 0x114 is WM_HSCROLL and the 1 after it is SB_LINERIGHT. OR
    SendMessage, 0x115, 1, 0, %fcontrol%, A  ; 0x114 is WM_VSCROLL  vertical scrolling
return

; Horizontal Scroll forward/back
$Lalt::Send {WheelLeft}   ; Left Alt button
$Ralt::Send {WheelRight}   ; Right Alt button

; Browser Forward/Back
$<::Send {Browser_Back}   ; Left Arrow, Browser Back Button
$>::Send {Browser_Forward} ; Right Arrow, Browser Forward Button


RapidHotKey Example- need to download Rapidhotkey Function
http://www.autohotkey.com/forum/topic38795.html&highlight=rapidhotkey
Code:

~RButton::RapidHotkey("Forward""Back", 2, 1)  ;two taps RBuitton = Forward, three taps RButton = Back,  ~ prevents RButton Activating Contextmenu, instead runs script
Forward:
    ; ADD Code snippet from above script for whichever one you like. Example
    Send {Browser_Forward}
Return
   
Back:
    Send {Browser_Back}   
Return   

Have Fun Exclamation Laughing
_________________

"Man's quest for knowledge is an expanding series whose limit is infinity"


Last edited by txquestor on Wed Oct 21, 2009 3:14 am; edited 2 times in total
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Wed Oct 21, 2009 2:44 am    Post subject: Reply with quote

Code:
Send, {XButton1} ; the 'back' button on a mouse
Send, {XButton2} ; the 'forward' button on a mouse

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!
Back to top
View user's profile Send private message
azstuenthome



Joined: 03 Nov 2008
Posts: 7

PostPosted: Wed Oct 21, 2009 1:51 pm    Post subject: Reply with quote

Thanks for the quick response. I didn't know there were so many options to go forward and back. I guess what I was looking for was the browser forward and back. I ended up using the {XButton1} and {XButton2}. I will probably experiment with the others as well.

Thanks again.
Back to top
View user's profile Send private message
Relayer



Joined: 24 Nov 2008
Posts: 68

PostPosted: Wed Oct 21, 2009 8:28 pm    Post subject: Reply with quote

I use an old Logitech mouse with 2 buttons and a scroll wheel. I got tired of cursor'ing up to the browser back button so this is what I've been using. I love it. It becomes second nature after a bit. It's great too on a notebook when you have no mouse.

To go back you press right then left.
To go forward, press left then right.

Code:

~RButton & LButton:: 
SendInput, {Browser_Back}
SetTimer, RBUp, 10
Return

RBUp:
GetKeyState, state, RButton
if state = U
{
   SetTimer, RBUp, Off
   SendInput, {Alt}
}
Return

~LButton & RButton::
SendInput, {Browser_Forward}
Return
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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