我试图愚弄这个特定的代码:
<!DOCTYPE html>
<html>
<body>
<p>Click anywhere in the document (the right frame) to get focus. If you click outside the document, it will lose focus.</p>
<p id="demo"></p>
<script>
setInterval("myFunction()", 1);
function myFunction() {
var x = document.getElementById("demo");
if (document.hasFocus()) {
x.innerHTML = "The document has focus.";
} else {
x.innerHTML = "The document DOES NOT have focus.";
}
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
因此,即使我不是 Chrome 中的前台应用程序,它也会返回 True。我想到的解决方案:
以某种方式使用硒?
在 chrome JS 引擎或铬中编译新的 hasFocus() 方法?总是返回 True。
我曾经在C中工作,其中线程很容易用我选择的特定函数创建.
现在在tcl我不能使用线程来启动我想要的特定功能,我试过这个:
package require Thread
proc printme {aa} {
puts "$aa"
}
set abc "dasdasdas"
set pool [tpool::create -maxworkers 4 ]
# The list of *scripts* to evaluate
set tasks {
{puts "ThisisOK"}
{puts $abc}
{printme "1234"}
}
# Post the work items (scripts to run)
foreach task $tasks {
lappend jobs [tpool::post $pool $task]
}
# Wait for all the jobs to finish
for {set running $jobs} {[llength $running]} {} {
tpool::wait $pool $running running
}
# Get the …Run Code Online (Sandbox Code Playgroud)