Navigation of Chrome Webpage (not the same question again)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PaulLeavitt
Posts: 58
Joined: 21 Oct 2014, 10:04

Navigation of Chrome Webpage (not the same question again)

19 Apr 2016, 14:31

Hey all! So I know Chrome and Firefox don't support COM, but given my work environment, I can't require that everyone who uses my code be using IE. I've been using AHK for a couple of years, so I'm pretty comfortable with it.

I need to select a specific box on a webpage, and the way I currently do it is like this:

Code: Select all

Send ^l	;Selects the address bar
Sendinput {Tab 5}	;tab to the desired control
This works pretty well, unless they have some other items in their toolbar that receive tab focus before hitting the webpage, causing the tab count to fail. So, here's my question. Is there a keyboard shortcut or something that AHK could send to at least get focus INSIDE the webpage? Like, if hitting Control+Alt+1 would highlight/focus the very first item/option/control in the webpage, then I could send tabs from there.

Thanks!

Paul
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Navigation of Chrome Webpage (not the same question again)

19 Apr 2016, 16:58

I have been unable to find any useful shortcut, but I made an alternative using Acc.ahk, the below script is intended for firefox.

Code: Select all

#Include Acc.ahk

a::
	run, firefox.exe https://www.google.com
	FFwait()
	Send, {Tab} ; remove focus from search field for demonstrative purposes.
	
	; the correct path in danish to rhe search field.
	;pos := Acc_Get("Location", "program.gruppering2.egenskabsside6.ukendt objekt.dokument.ukendt objekt.ukendt objekt3.ukendt objekt2.ukendt objekt2.ukendt objekt.ukendt objekt.ukendt objekt.ukendt objekt.ukendt objekt.ukendt objekt3.kombinationsboks", , "ahk_class MozillaWindowClass")
	
	; translated path may be wrong.
	pos := Acc_Get("Location", "application.grupping.property_page6.unknown_object.document.unknown_object.unknown_object3.unknown_object2.unknown_object2.unknown_object.unknown_object.unknown_object.unknown_object.unknown_object.unknown_object3.combo_box", , "ahk_class MozillaWindowClass")
	
	pos := StrSplit(pos, " ")
	; adding 10 to the coordinates of the search field to ensure the click is within it.
	x := SubStr(pos[1], 2) + 10, y := SubStr(pos[2], 2) + 10
	
	ControlClick, x%x% y%y%, ahk_class MozillaWindowClass, , , , NA
	ControlSend, , {Tab}, ahk_class MozillaWindowClass
	
return

;4,27,6,1,1,1,4,2,2,1,1,1,1,1,3,1

;"program.gruppering2.egenskabsside6.ukendt objekt.dokument.ukendt objekt.ukendt objekt3.ukendt objekt2.ukendt objekt2.ukendt objekt.ukendt objekt.ukendt objekt.ukendt objekt.ukendt objekt.ukendt objekt3.kombinationsboks"
;"application.grupping.property_page6.unknown_object.document.unknown_object.unknown_object3.unknown_object2.unknown_object2.unknown_object.unknown_object.unknown_object.unknown_object.unknown_object.unknown_object3.combo_box"

FFwait() {
	loading := "Stop loading this page"
	loaded := "Reload current page"
	
	button := "application.tool_bar3.combo_box.push_button3"
	;button := "program.værktøjslinje3.kombinationsboks.trykknap3"
	
	; sleep until the description indicates page is loaded
	loop {
		description := Acc_Get("Name", button, 0, "ahk_class MozillaWindowClass")
		OutputDebug, %description%
		if(description = loaded) {
			break
		}
		sleep, 10
	}
}
Too find the paths you will need use Accessible Info Viewer.
Please excuse my spelling I am dyslexic.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Draken, oktavimark and 338 guests