Add "https://" in URL if specific error page is displayed on Google Chrome

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Bragato
Posts: 13
Joined: 28 Jun 2017, 07:38

Add "https://" in URL if specific error page is displayed on Google Chrome

28 Jun 2017, 07:54

Hi guys, first post here.
I've used AHK for a while now, started using it on Skyrim, now I use it to work with AUTOCAD and EXCEL, just basic simple macros with "Send", "Loop", etc, never used it with google chrome.

Where I work the internet access is blocked to some sites, but if I add "https://" before the site URL the access is permited, imgur always works, but it's boring to always go there and type it haha
Is there a way to automate this proccess on autohotkey?

This is the error message that displays:
http://imgur.com/WYlYrd5

With "https://":
http://imgur.com/l1znf9Q
BoBo
Posts: 2518
Joined: 13 May 2014, 17:15

Re: Add "https://" in URL if specific error page is displayed on Google Chrome

28 Jun 2017, 08:37

Hotkey

Code: Select all

!i::Run, "<yourPathTo>\chrome.exe" "https://imgur.com" ; press Alt+i to call imgur.com
Hotstring

Code: Select all

::imgur.com::https://imgur.com ; once you type imgur.com it should replace it with https://imgur.com
User avatar
Bragato
Posts: 13
Joined: 28 Jun 2017, 07:38

Re: Add "https://" in URL if specific error page is displayed on Google Chrome

28 Jun 2017, 08:42

BoBo wrote:Hotkey

Code: Select all

!i::Run, "<yourPathTo>\chrome.exe" "https://imgur.com" ; press Alt+i to call imgur.com
Hotstring

Code: Select all

::imgur.com::http://imgur.com
That should work only for imgur, I want the script to detect the error image and then add "https://" on the beginning of the URL for every site.
As I browse reddit for example, I open a reddit image on another tab and the error image is displayed, I want the script to detect that error image and add https:// to the url start so I can see the image
BoBo
Posts: 2518
Joined: 13 May 2014, 17:15

Re: Add "https://" in URL if specific error page is displayed on Google Chrome

28 Jun 2017, 09:28

Bragatp wrote:
BoBo wrote:Hotkey

Code: Select all

!i::Run, "<yourPathTo>\chrome.exe" "https://imgur.com" ; press Alt+i to call imgur.com
Hotstring

Code: Select all

::imgur.com::http://imgur.com
That should work only for imgur, I want the script to detect the error image and then add "https://" on the beginning of the URL for every site.
As I browse reddit for example, I open a reddit image on another tab and the error image is displayed, I want the script to detect that error image and add https:// to the url start so I can see the image
Well, that wasn't said/requested in your inital post.
Best case, you provide your full requirements in the beginning.
Otherwise you end up acting like my wife :lol:

IMHO it makes sense to "correct"/pimp your entries before you call a webpage, instead of messing around how to detect a servers online response.
Let's guess your admin will get a nice salary to monitor your behaviour via the server logs and will block any variants of calling blacklisted pages sooner or later.
Good luck :)
Last edited by BoBo on 28 Jun 2017, 09:37, edited 1 time in total.
User avatar
Bragato
Posts: 13
Joined: 28 Jun 2017, 07:38

Re: Add "https://" in URL if specific error page is displayed on Google Chrome

28 Jun 2017, 09:33

BoBo wrote:
Bragatp wrote:
BoBo wrote:Hotkey

Code: Select all

!i::Run, "<yourPathTo>\chrome.exe" "https://imgur.com" ; press Alt+i to call imgur.com
Hotstring

Code: Select all

::imgur.com::http://imgur.com
That should work only for imgur, I want the script to detect the error image and then add "https://" on the beginning of the URL for every site.
As I browse reddit for example, I open a reddit image on another tab and the error image is displayed, I want the script to detect that error image and add https:// to the url start so I can see the image
Well, that wasn't said/requested in your inital post.
Best case, you provide your full requirements in the beginning.
Otherwise you end up acting like my wife :lol:
You misunderstood me, imgur was only an example of a site that works with https.
As I said, I want to automate all the proccess to type https, implied that the script must detect the error page then type https on the url
User avatar
jeeswg
Posts: 5942
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Add "https://" in URL if specific error page is displayed on Google Chrome

28 Jun 2017, 10:02

This might be good, refresh a page as https://. Possible hotkey: ^F5:: (ctrl+F5). It uses the Acc library:

Code: Select all

;Acc library (MSAA) and AccViewer download links - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

q:: ;url 'special refresh', reload page as 'https://'
WinGet, hWnd, ID, A
oAcc := Acc_Get("Object", "window.client.client.client2.tool_bar2.grouping1.editable_text", 0, "ahk_id " hWnd)
vUrl := oAcc.accValue(0)
if (SubStr(vUrl, 1, 7) = "http://")
	vUrl := SubStr(vUrl, 8)
if (SubStr(vUrl, 1, 8) = "https://")
	vUrl := SubStr(vUrl, 9)
vUrl := "https://" vUrl
oAcc.accValue(0) := vUrl
;oAcc.accDoDefaultAction(0) ;didn't work
SendInput !d{Enter}
oAcc := ""
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Guest

Re: Add "https://" in URL if specific error page is displayed on Google Chrome

28 Jun 2017, 13:37

jeeswg wrote:This might be good, refresh a page as https://. Possible hotkey: ^F5:: (ctrl+F5). It uses the Acc library:

Code: Select all

;Acc library (MSAA) and AccViewer download links - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

q:: ;url 'special refresh', reload page as 'https://'
WinGet, hWnd, ID, A
oAcc := Acc_Get("Object", "window.client.client.client2.tool_bar2.grouping1.editable_text", 0, "ahk_id " hWnd)
vUrl := oAcc.accValue(0)
if (SubStr(vUrl, 1, 7) = "http://")
	vUrl := SubStr(vUrl, 8)
if (SubStr(vUrl, 1, 8) = "https://")
	vUrl := SubStr(vUrl, 9)
vUrl := "https://" vUrl
oAcc.accValue(0) := vUrl
;oAcc.accDoDefaultAction(0) ;didn't work
SendInput !d{Enter}
oAcc := ""
return
Didn't work :(
When I press the hotkey the URL just gets highlighted, but nothings happens beyond that
User avatar
jeeswg
Posts: 5942
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Add "https://" in URL if specific error page is displayed on Google Chrome

28 Jun 2017, 14:41

A slightly improved (logic) version of the original script, with a ToolTip line that should contain the original url (that can be commented out), and a simple version that uses the clipboard. So hopefully at least the clipboard script should work. Try AccViewer to identify the correct Acc path. Otherwise it could be possible issues like Admin windows.

[EDIT:] I've also commented out the original Acc path, and added a numeric version instead. It may be that the string version only works on English language PCs, whereas the numeric version should probably work on any PC.

Code: Select all

q:: ;url 'special refresh', reload page as 'https://'
WinGet, hWnd, ID, A
;oAcc := Acc_Get("Object", "window.client.client.client2.tool_bar2.grouping1.editable_text", 0, "ahk_id " hWnd)
oAcc := Acc_Get("Object", "4.1.2.2.3.5.2", 0, "ahk_id " hWnd)
vUrl := oAcc.accValue(0)
ToolTip, % "url: " vUrl
if (SubStr(vUrl, 1, 7) = "http://") ;http to https
	vUrl := "https://" SubStr(vUrl, 8)
else if !(SubStr(vUrl, 1, 8) = "https://") ;not http/https, prepend https
	vUrl := "https://" vUrl
oAcc.accValue(0) := vUrl
;oAcc.accDoDefaultAction(0) ;didn't work
SendInput !d{Enter}
oAcc := ""
return

;==================================================

;q:: ;url 'special refresh', reload page as 'https://'
WinGet, hWnd, ID, A
ClipSaved := ClipboardAll
Clipboard := ""
SendInput !d
Sleep 1000
SendInput ^c
ClipWait
vUrl := Clipboard
ToolTip, % "url: " vUrl
if (SubStr(vUrl, 1, 7) = "http://") ;http to https
	vUrl := "https://" SubStr(vUrl, 8)
else if !(SubStr(vUrl, 1, 8) = "https://") ;not http/https, prepend https
	vUrl := "https://" vUrl
Clipboard := vUrl
SendInput !d^v{Enter}
Clipboard := ClipSaved
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: ah_sis90, AviationGuy, electrone77, israelss, ktbjx, MannyKSoSo, peperami, scriptor2016, sinkfaze and 159 guests