SHARE
TWEET

Untitled

a guest Feb 12th, 2019 14 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Hello AHK forums!
  2.  
  3. I am new here (but not to AHK) so hey
  4.  
  5. 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
  6.  
  7. 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!
  8.  
  9. [img]https://i.imgur.com/hIVCJu8.gif[/img]
  10. [Codebox=autohotkey file=chrome_open_tab_middleclick.ahk]
  11. ~MButton::
  12.     ReferenceImageWidth = 18 ; The width of the reference image. Edit this if you used your own.
  13.     TitlebarHeight = 40 ; The height of the title bar. You should adjust this if the detection seems bad when clicking
  14.     ReferenceImageName = tab_plus.png ; The forum thread should explain how to make yours in case mine does not work
  15.  
  16.     if not WinActive("ahk_exe chrome.exe") { ; Our script only works in chrome duh!
  17.         return
  18.     }
  19.    
  20.     MouseGetPos, ClickX, ClickY
  21.     if (ClickY > TitlebarHeight) {
  22.         return ; If you clicked lower than the title bar, it's useless to continue
  23.     }
  24.    
  25.     WinGetPos, , , ActiveWindowWidth, , A ; Get the chrome window width
  26.    
  27.     ImageSearch,ImageX,ImageY,0,0,%ActiveWindowWidth%,%TitlebarHeight%,*25 %ReferenceImageName% ; Search for the "+" reference image
  28.    
  29.     if (ErrorLevel = 0 and ClickX > (ImageX + ReferenceImageWidth)) {
  30.         Send, ^t ; If we found the "+" and you clicked right of it, open a new tab!
  31.     }
  32.     return
  33. [/Codebox]
  34.  
  35. Save one of the following and rename it as "tab_plus.png" in the folder where your .ahk is.
  36. Windows 7 reference image: https://i.imgur.com/L1vmOrZ.png
  37. Windows 10 reference image: https://i.imgur.com/QdbPhS5.png
  38.  
  39. And that's it! Have fun  :superhappy:
  40.  
  41. [u]SUPER HIGH TECH GEEK SECTION[/u]
  42. [u]How to make your own reference image in case mine do not work[/u]
  43. [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.
  44. It is easy to make a new one.
  45. [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]
  46. [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]
  47. [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]
  48. [/spoiler]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top