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 

open links in new background tabs

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



Joined: 07 Jun 2007
Posts: 304

PostPosted: Sun Nov 22, 2009 8:36 pm    Post subject: open links in new background tabs Reply with quote

hello

this script enables in opera browser, to open links in new background tabs with right click

however it happens to open both the link in the current tab and in a new background tab (as if I clicked with left click as well)

can anybody fix it please?
thanks

Code:
; General
#SingleInstance Force
#Persistent

#IfWinActive ahk_class OpWindow
deactivate:=false
RButton::
  WinGet, operaWindow, ID, ahk_class OpWindow
  MouseGetPos, x, y, selectedWindow
  If (operaWindow==selectedWindow)
  {
    If !deactivate
    {
      MouseClick, middle
      Send {ENTER}
    }
  }
  Else
    MouseClick, right
  return
^RButton::
  WinGet, operaWindow, ID, ahk_class OpWindow
  MouseGetPos, x, y, selectedWindow
  If (operaWindow==selectedWindow)
  {
    deactivate:=true
    MouseClick, right
    deactivate:=false
  }
  Else
    Send ^{Click right}
  return
#IfWinActive

#NoTrayIcon


Last edited by azure on Sun Nov 22, 2009 9:45 pm; edited 1 time in total
Back to top
View user's profile Send private message
a_h_k



Joined: 02 Feb 2008
Posts: 344

PostPosted: Sun Nov 22, 2009 9:43 pm    Post subject: Re: open links in new background tabs Reply with quote

Am i right to assume that "deactivate" is to stop MouseClick from recursively calling RButton:: ?

If so, then try the following ...
Code:
; General
#SingleInstance Force
#Persistent
#NoTrayIcon

#IfWinActive ahk_class OpWindow
$RButton::
  WinGet, operaWindow, ID, ahk_class OpWindow
  MouseGetPos, x, y, selectedWindow
  If (operaWindow==selectedWindow)
  {
    MouseClick, middle
    Send {ENTER}
  }
  Else
    MouseClick, right
  return
$^RButton::
  WinGet, operaWindow, ID, ahk_class OpWindow
  MouseGetPos, x, y, selectedWindow
  If (operaWindow==selectedWindow)
    MouseClick, right
  Else
    Send ^{Click right}
  return
#IfWinActive
Back to top
View user's profile Send private message
azure



Joined: 07 Jun 2007
Posts: 304

PostPosted: Mon Nov 23, 2009 1:56 pm    Post subject: Re: open links in new background tabs Reply with quote

a_h_k wrote:
Am i right to assume that "deactivate" is to stop MouseClick from recursively calling RButton:: ?

If so, then try the following ...
Code:
; General
#SingleInstance Force
#Persistent
#NoTrayIcon

#IfWinActive ahk_class OpWindow
$RButton::
  WinGet, operaWindow, ID, ahk_class OpWindow
  MouseGetPos, x, y, selectedWindow
  If (operaWindow==selectedWindow)
  {
    MouseClick, middle
    Send {ENTER}
  }
  Else
    MouseClick, right
  return
$^RButton::
  WinGet, operaWindow, ID, ahk_class OpWindow
  MouseGetPos, x, y, selectedWindow
  If (operaWindow==selectedWindow)
    MouseClick, right
  Else
    Send ^{Click right}
  return
#IfWinActive


not sure about the 'deactivate' I suppose it does so

however your script doesn't work either

I have noticed that if I right click on a link while having ESC key pushed, it opens the link in a new background tab, without opening in the current tab as well (as if I left clicked the link)

however I don't want ESC to be pressed, since it stops webpage loading

also, when I leave the finger on the touchpad and then I right click, it opens the link only in a new background tab, can anyone simulate this into a AHK script?

any ideas??? about ESC or maybe a better one?
Back to top
View user's profile Send private message
a_h_k



Joined: 02 Feb 2008
Posts: 344

PostPosted: Tue Nov 24, 2009 1:31 pm    Post subject: Reply with quote

Did a google on opening tab in background, & found that Ctrl-Shift-Left_click will open a new tab in the background

So with that new info, starting from scratch...
Code:
#IfWinActive ahk_class OpWindow
$RButton::
  If A_Cursor = Unknown        ;unknown = hand cursor
    Send ^+{LButton}
Return
Back to top
View user's profile Send private message
azure



Joined: 07 Jun 2007
Posts: 304

PostPosted: Wed Nov 25, 2009 8:37 pm    Post subject: Reply with quote

a_h_k wrote:
Did a google on opening tab in background, & found that Ctrl-Shift-Left_click will open a new tab in the background

So with that new info, starting from scratch...
Code:
#IfWinActive ahk_class OpWindow
$RButton::
  If A_Cursor = Unknown        ;unknown = hand cursor
    Send ^+{LButton}
Return


it seems to work well, but the problem is that sometimes the cursor it is over a link and it is not in hand-shape, but in arrow-shape or sunglass-shape...
is there any solution for this?
Back to top
View user's profile Send private message
a_h_k



Joined: 02 Feb 2008
Posts: 344

PostPosted: Thu Nov 26, 2009 4:22 am    Post subject: Reply with quote

Yep .. it's in here Smile
Back to top
View user's profile Send private message
azure



Joined: 07 Jun 2007
Posts: 304

PostPosted: Sat Nov 28, 2009 7:10 pm    Post subject: Reply with quote

the original script I posted has solved this problem, is there a way to integrate your script to the original?
Back to top
View user's profile Send private message
a_h_k



Joined: 02 Feb 2008
Posts: 344

PostPosted: Sun Nov 29, 2009 8:39 am    Post subject: Reply with quote

Have tested it out (on Firefox), & fixed the bugs...
Code:
#NoTrayIcon
#IfWinActive ahk_class OpWindow
$RButton::
  If (A_Cursor="Unknown")   ;Ensures this operates only over links (Unknown = hand)
    Send ^+{LButton}
  Else
     Send {RButton}   ;Brings-up right-mouse menu (as normal)
Return

In Firefox there seems to be only 1 possible mouse pointer for when mouse is over a link: Hand (Unknown)


Last edited by a_h_k on Mon Nov 30, 2009 6:45 am; edited 1 time in total
Back to top
View user's profile Send private message
azure



Joined: 07 Jun 2007
Posts: 304

PostPosted: Sun Nov 29, 2009 6:15 pm    Post subject: Reply with quote

mm not, now it doesn't work at all, right click on links does nothing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   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