tatleoat wrote: ↑19 Jun 2021, 06:59
I'm sorry that I'm almost at this point asking you to do this for me, I'm just at my wits end trying to figure something out that should ostensibly be extremely simple. If you're stumped maybe you can point me in a direction of a more JS focused resource that might be able to help?
I wouldn't call the handling of frames "extremely simple" - they can be a bit tricky, expecially if you don't have the page available for testing. (I assume it's something you can't/don't want to share ? If we had that URL for testing, it would simplify things a lot.) It's perhaps once or twice a year I deal with frames, and I always have to recall how it's done. It helps immensely to be able to check the javascript in the browser console, before adding it to your Chrome.ahk script.
Yesterday, I tried to give you some code without being able to test anything - and I think my js syntax was not correct, and I removed it now from my post above (so that future users won't try it unsuccessfully).
So we are looking at a
frame named 'topFrame' (it's a
Name, the frame doesn't have an
Id in this case - we have to account for that).
Also, if you create a Chrome instance named
ChromeInst (
ChromeInst := new Chrome("ChromeProfile")), you should also use that instance in
TabInstance := ChromeInst.GetPage()
So, let's try this:
Code: Select all
#NoEnv
#Include Chrome.ahk
SetBatchLines, -1
ChromeInst := new Chrome("ChromeProfile")
; now navigate to your page
^F3::
TabInstance := ChromeInst.GetPage()
; names are not unique, but let's assume a frame has the index 0
frameJs =
(
var aframe = document.getElementsByName('topFrame')[0];
aframe.contentDocument.getElementById('txtSearch').value = '123456';
)
TabInstance.Evaluate(frameJs)
return
Esc::ExitApp
(js syntax should hopefully be better now
)