Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Autohotkey 将脚本转换为在后台运行_Autohotkey - Fatal编程技术网

Autohotkey 将脚本转换为在后台运行

Autohotkey 将脚本转换为在后台运行,autohotkey,Autohotkey,当我在前台使用Send和MouseClick而不是ControlSend和ControlClick(wb.Visible=true)运行该脚本时,它工作正常。在后台运行它有什么问题 code1 := "foobar" url := "https://app.powerbi.com/groups/me/reports/xxx" wb := ComObjCreate("Intern

当我在前台使用Send和MouseClick而不是ControlSend和ControlClick(wb.Visible=true)运行该脚本时,它工作正常。在后台运行它有什么问题

code1           := "foobar"
url             := "https://app.powerbi.com/groups/me/reports/xxx"
wb              := ComObjCreate("InternetExplorer.Application")     ;create com object  
wb.Visible      := false                            ;true to show IE
wb.Navigate(url)

while (wb.busy)                                     ;wait while page loads
    sleep 10

ControlSend,, {LWin down}{Up down}
ControlSend,, {LWin up}{Up up}

sleep 20000

ControlClick, left, 1275, 320
sleep 3000
ControlClick, left, 1275, 510
sleep 500
ControlClick, left, 2200, 1380
sleep 3000
ControlClick, left, 2200, 1380
sleep 3000
ControlClick, left, 2200, 1380
sleep 120000
ControlClick, left, 2760, 2000
sleep 500
ControlClick, left, 2760, 2000
sleep 5000
ControlClick, left, 2760, 2000
sleep 3000
ControlClick, left, 2760, 2000

DetectHiddenWindows,On
指令可以检测运行在 背景

#SingleInstance, Force 

DetectHiddenWindows, On

Run, Notepad, , Hide      ; run notepad in the background
if WinExist("ahk_class Notepad")
    ControlSend, Edit1, sending a string to the notepad.exe, Untitled

; verify: wait for 2s to see the effect
sleep 2000
WinShow

击键和字符串可以传递到隐藏窗口或非活动窗口。 例如,下面的代码段启动notepad.exe,发送消息“向notepad.exe发送字符串”,即使notepad正在后台运行

#SingleInstance, Force 

DetectHiddenWindows, On

Run, Notepad, , Hide      ; run notepad in the background
if WinExist("ahk_class Notepad")
    ControlSend, Edit1, sending a string to the notepad.exe, Untitled

; verify: wait for 2s to see the effect
sleep 2000
WinShow

同样地,对于您的问题,它也很有希望工作(无法测试,没有powerbi帐户)


由于AHK仅通过Windows的鼠标和键盘输入方法工作,并且所有这些方法都仅适用于活动窗口(或桌面),因此您无法使用AHK将任何键盘或鼠标操作发送到后台窗口。即使使用IE COM对象访问字段,也意味着页面可见(但不必处于活动状态)。我的意思是,您的页面已经在对象中,只需使用
getElementById()
getElementsByName()
getElementsByTagName()
,然后使用
.focus()
。单击()
.value=
,即可完成所需操作。