Mouse hotkeys to do useful things and a screenshot saver

Post your working scripts, libraries and tools for AHK v1.1 and older
virtualauto
Posts: 26
Joined: 19 Jun 2016, 01:04

Mouse hotkeys to do useful things and a screenshot saver

22 Apr 2018, 20:41

Well I leave my current script. It handles more or less mouse clicks (double click, right plus left, left plus right, the middle one too)- also called "rocker" actions, checks if mouse is over a particular window and saves a screenshot automatically. Sometimes the mouse part fails, I don't know why :? A know issue is that when you right plus left click an extra right click is sent showing usually a menu. Hope it helps a lot of you and if you can improve any part, feel free to do so and post your results :)

Code: Select all

;;;;;;;Check if mouse button has been double clicked
DoubleClick() {
	KeyWait, %A_ThisHotkey% 
	Sleep, 10
	KeyWait, %A_ThisHotkey%, D, T0.1
	if (ErrorLevel = 0) {	
		Return True
	}
	else {
		Return False
	}
}
;;;;;;;;;;;;Mouse over a window or program
MouseIsOver(WinTitle) {;To get know the correct WinTitle needed use a message box displaying the result of "Win" returned by MouseGetPos
    MouseGetPos,,,, Win
	if(Win = WinTitle) {
		Return true
	}
	else {
		Return false
	}
}

;;;;;;;;;;;;;;;If mouse is over taskbar
#If MouseIsOver("MSTaskListWClass1")

	;;;;;;;;;;;;;;;;;;;;Middle click over taskbar closes window
	MButton::
		MouseClick, Right
		Sleep, 100
		Send {Up}
		Send {Enter}
		Return

	;;;;;;;;;;;;;;;;;;;;Scrolling over taskbar adjusts volume
	WheelUp::
		Send {Volume_Up}
		Return
	WheelDown::
		Send {Volume_Down}
		Return
#If

;;;;;;;;;;;;;;;If mouse is over Chrome
#If MouseIsOver("Chrome_RenderWidgetHostHWND1")
	RButton::
		;;;;;;;;;;;;Holding click for 0.3 second reopens previously closed tab
		KeyWait, RButton, U T0.3
		if (ErrorLevel = 1) {
			Send, {LCtrl Down}{LShift Down}t{LShift Up}{LCtrl Up}	
		}
		;;;;;;;;;;;;;Double click opens new tab
		else if(DoubleClick()) {
			Sleep, 150
			Send {Esc}
			Send ^{t}
		}
		;;;;;;;;;;;;;;;Single click sends single click
		else {
			Click, right
		}
		return

	MButton::
		;;;;;;;;;;;;;;;Right click and middle click sends password
		if (GetKeyState("RButton", "P")){
			SendInput password
		 	Send {Enter}
		}
		;;;;;;;;;;;;;;;Single click sends single click
		else {
			Send {MButton}
		}
		Return
#If

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Right click plus left click opens Z (a folder)
~RButton & LButton::
	Run, "Z:"
	WinActivate, Z (Z:)
	WinWaitActive, Z (Z:)
	WinMaximize, Z (Z:)
	Return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Left click plus right click opens Chrome
~LButton & RButton::
	Run, "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Google Chrome"
	WinActivate, New tab - Google Chrome
	WinWaitActive, New tab - Google Chrome
	WinMaximize, New tab - Google Chrome
	Return

;;;;;;;;;;;;;;;;;;;;;;;ScrLk imputs [email protected]
ScrollLock::
	SendInput [email protected]
	Return

;;;;;;;;;;;;;;;;;;;;;;PScrLk imputs [email protected]
Pause::
	SendInput [email protected]
	Return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ImpPnt saves a screenshot as a png file
PrintScreen::
	Send !{PrintScreen}
	Run, "%windir%\system32\mspaint.exe"
	WinActivate, Untitled - Paint
	WinWaitActive, Untitled - Paint
	Send ^{v}
	Send ^{s}
	Random, rand, 1, 100
	Send %rand%
	Send {Enter}
	Send !{F4}
	Return
Last edited by virtualauto on 23 Apr 2018, 07:54, edited 1 time in total.
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: Mouse hotkeys to do useful things and a screenshot saver

23 Apr 2018, 03:00

thanks sharing that. May one day I need that.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 125 guests