VBSCRIPT简单又很奇怪的Function相关有关问题
VBSCRIPT简单又很奇怪的Function相关问题VBScript codeDim Shell, win, hWndSet Shell CreateObject(Sh
VBSCRIPT简单又很奇怪的Function相关问题
VBScript codeDim Shell, win, hWndSet Shell = CreateObject("Shell.Application")Set win = Shell.windowsDim ieset ie = GetfocusHwnd()Delay 3000MessageBox typename(ie) '为EMTPYFunction GetfocusHwnd() Dim i,hWnd hWnd = GetForegroundWindow() For i = 0 To win.count - 1 If win(i).hWnd = hWnd Then Set GetfocusHwnd = win(i) MessageBox typename(GetfocusHwnd)'为IWEBBROWER2 Exit For End If NextEnd Function
求解为什么第一个MessageBox typename(ie) '为EMTPY无效而函数内的有效,请高手赐教,如何解决,为什么不能封装成函数
[解决办法]问题是啥?还要等着别人码字问问?
[解决办法]这样呢
Dim Shell, win, hWnd
Set Shell = CreateObject("Shell.Application")
Set win = Shell.windows
Dim ie
set ie = win(GetfocusHwnd())
Delay 3000
MessageBox typename(ie) '为EMTPY
Function GetfocusHwnd()
Dim i,hWnd
hWnd = GetForegroundWindow()
For i = 0 To win.count - 1
If win(i).hWnd = hWnd Then
GetfocusHwnd = i
Exit For
End If
Next
End Function
[解决办法]结贴啦
分不多