我无法理解什么是用下面的代码的问题 -多次调用BringWindowToTop不工作
i = 15
While (i < 100)
If i Mod 2 = 0 Then
handle = FindWindow(vbNullString, "My Details - Windows Internet Explorer")
Range("A1").Value = handle
BringWindowToTop handle
Application.Wait DateAdd("s", 1, Now)
Else
handle1 = FindWindow(vbNullString, "Codeomnitrix - Outlook Web App - Mozilla Firefox")
Range("A2").Value = handle1
BringWindowToTop handle1
Application.Wait DateAdd("s", 1, Now)
End If
i = i + 15
Wend
应该两个窗口之间切换,让他们成为市场关注焦点至凌晨1秒但实际上发生了什么它只是把Firefox放在最上面,然后再切换。
谢谢
'FindWindow(vbNullString,“Codeomnitrix - Outlook Web App - Mozilla Firefox”)是否返回零或值?例如,我使用Excel进行了测试:**“test.xlsm - Microsoft Excel”** Findwindow()必须查找**“test.xlsm”**,而不是使其工作。 – Raybarg
否Raybarg它正在为这两个窗口返回适当的值,并且如果我一次运行的东西它正常工作。我的意思是,如果只有IE窗口需要带到前面或只有Firefox窗口需要带前,它工作正常,但切换不起作用 – codeomnitrix
你应该在'If()'内的Debug.Print'阻止** i **的值和**处理**,看看它是否贯穿整个循环。我用File Explorer和Excel测试了你的代码,它工作正常。可能是firefox捕捉到API钩子,也许是一些反弹的东西呢?我只是猜测... – Raybarg