Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hello AHK forums!
- I am new here (but not to AHK) so hey
- I am here to share with you all my latest script which brings to chrome what has always been on Firefox: To open a new tab when middle-mouse clicking the title bar
- This script requires that you also download the appropriate reference "+" image for your browser and OS versions. I will provide you with both windows 7 and windows 10 reference images for FREE!
- [img]https://i.imgur.com/hIVCJu8.gif[/img]
- [Codebox=autohotkey file=chrome_open_tab_middleclick.ahk]
- ~MButton::
- ReferenceImageWidth = 18 ; The width of the reference image. Edit this if you used your own.
- TitlebarHeight = 40 ; The height of the title bar. You should adjust this if the detection seems bad when clicking
- ReferenceImageName = tab_plus.png ; The forum thread should explain how to make yours in case mine does not work
- if not WinActive("ahk_exe chrome.exe") { ; Our script only works in chrome duh!
- return
- }
- MouseGetPos, ClickX, ClickY
- if (ClickY > TitlebarHeight) {
- return ; If you clicked lower than the title bar, it's useless to continue
- }
- WinGetPos, , , ActiveWindowWidth, , A ; Get the chrome window width
- ImageSearch,ImageX,ImageY,0,0,%ActiveWindowWidth%,%TitlebarHeight%,*25 %ReferenceImageName% ; Search for the "+" reference image
- if (ErrorLevel = 0 and ClickX > (ImageX + ReferenceImageWidth)) {
- Send, ^t ; If we found the "+" and you clicked right of it, open a new tab!
- }
- return
- [/Codebox]
- Save one of the following and rename it as "tab_plus.png" in the folder where your .ahk is.
- Windows 7 reference image: https://i.imgur.com/L1vmOrZ.png
- Windows 10 reference image: https://i.imgur.com/QdbPhS5.png
- And that's it! Have fun :superhappy:
- [u]SUPER HIGH TECH GEEK SECTION[/u]
- [u]How to make your own reference image in case mine do not work[/u]
- [spoiler]It is possible that the reference image that I provided do not work in case you have a different OS or a more recent chrome version.
- It is easy to make a new one.
- [list]You need to take a capture of your title bar section where the "+" is [img]https://i.imgur.com/5a7lTi8.png[/img]. [b]MAKE SURE YOUR BROWSER WINDOW IS FOCUSED WHEN DOING SO!!![/b] (else the color will not be the same!!)[/list]
- [list]Crop the + out and leave out the rounded corners and background as there is transparency and will mess with ImageSearch.(take mine as an example)[/list]
- [list]I try to make my reference images 18x18 pixels, if yours is larger then update the "ReferenceImageWidth" value in the script to fit yours.[/list]
- [/spoiler]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement