Jump to content


Photo

Click and Hold - Open Web Pages in New Tabs


  • Please log in to reply
2 replies to this topic

#1 Xx7

Xx7
  • Members
  • 612 posts

Posted 16 August 2012 - 07:18 AM

Very simple script that I use alot. Instead of pressing Ctrl+click to open a webpage in a new tab, just hold down the left mouse button for 0.5 seconds instead. If you release it earlier, it acts as it normally would.

Just wanted to share the IDEA since I think time-delayed actions (eg. holding down a key for a certain period of time) could be very useful. :D

LButton::
if (A_Cursor = "Unknown") [color=#008000];eg. mouse over hyperlink[/color]
{
	now_1 := A_TickCount  [color=#008000];initial time[/color]
	
	loop,
	{
		now_2 := A_TickCount  [color=#008000];current time[/color]
		elapsed_time := now_2 - now_1  [color=#008000];elapsed time since Lbutton held down[/color]
		
		GetKeyState, state, Lbutton, P
		if (state = "U" and elapsed_time < 500)
		{
			Click [color=#008000];retain native function if released under 500 ms[/color]
			break
		}
		else if (state = "D" and elapsed_time > 500)
		{
			gosub Label1 [color=#008000];if held down longer than 500 ms... open link in new tab[/color]
			break
		}
	}
}
else
	gosub Label2
return


Label1:
	Send, {ctrl down}
	Click
	Send, {ctrl up}
	return

Label2:
	Click Down
	KeyWait, Lbutton
	Click Up
	return


#2 Wingfat

Wingfat
  • Members
  • 932 posts

Posted 16 August 2012 - 10:47 PM

Fun script. thanks..
Isn't "Always Open Links in a New Tab" an option in FireFox and IE and Chrome though?

#3 Xx7

Xx7
  • Members
  • 612 posts

Posted 17 August 2012 - 02:05 AM

Hmmmm... couldn't find it in Chrome. If you changed your browser default settings to that... you could use this script to open links in the same tab when needed too.