Bei mir funktioniert es leider nicht.
z.B. Aus der Ordner Examples > InjectJS.ahk
Vor update auf version 90: Wenn ich die Datei InjectJS.ahk ausgeführt habe, wurde der Ordner ChromeProfile erstellt, in diesem Ordner wurden meine Dateien gespeichert. Wenn ich jetzt ausführe, also mit Version 90. bleibt der Ordner leer und Chrome greift immer auf Ordner: C:\Program Files (x86)\Google\Chrome\Application\ChromeProfile\Default zu.
Code: Select all
#NoEnv
SetBatchLines, -1
#Include ../Chrome.ahk
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try
{
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
; --- Create a new Chrome instance ---
FileCreateDir, ChromeProfile
ChromeInst := new Chrome("ChromeProfile", "https://autohotkey.com/")
; --- Connect to the page ---
if !(PageInst := ChromeInst.GetPage())
{
MsgBox, Could not retrieve page!
ChromeInst.Kill()
}
else
{
; --- Perform JavaScript injection ---
Loop
{
InputBox, JS,,
( LTrim
Enter some JavaScript to be run on the page, or leave blank to exit. For example:
alert('hi');
window.location = "https://p.ahkscript.org/";
)
if (JS == "" || ErrorLevel)
break
try
Result := PageInst.Evaluate(JS)
catch e
{
MsgBox, % "Exception encountered in " e.What ":`n`n"
. e.Message "`n`n"
. "Specifically:`n`n"
. Chrome.Jxon_Dump(Chrome.Jxon_Load(e.Extra), "`t")
continue
}
MsgBox, % "Result:`n" Chrome.Jxon_Dump(Result, "`t")
}
; --- Close the Chrome instance ---
try
PageInst.Call("Browser.close") ; Fails when running headless
catch
ChromeInst.Kill()
PageInst.Disconnect()
}
ExitApp
return