65.9K
CodeProject 正在变化。 阅读更多。
Home

VBSCRIPT - 窗口置顶

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.17/5 (3投票s)

2005年2月22日

viewsIcon

119258

这个程序的作用是加载目标网址,并使其保持焦点,覆盖整个屏幕,直到用户选择屏幕上的按钮关闭窗口,或者按下 <ALT-F4> 键。

引言

这个程序的作用是加载目标网址,并使其保持焦点,覆盖整个屏幕,直到用户选择屏幕上的按钮关闭窗口,或者按下 <ALT-F4> 键。 

 

使用代码

代码本身就具有自文档化的特性。只需将其复制并粘贴到 .vbs 文件中即可。将 URL 更改为任何地址,无论是网络地址还是网络 UNC 路径。< /p>< /p>

'**************************************************************************************************
'This code will open a web browser and point it at the url specified.
'sURL is the url to the website you want to load.
'This vbscript will not allow the user to switch to any other window till this script ends.
'**************************************************************************************************
dim sURL
'**************************************************************************************************
'**************************************************************************************************



'The url to the webpage that you want the user to go to.
sURL= "http://www.google.com"




'**************************************************************************************************
'**************************************************************************************************
'**************************************************************************************************
'!!!!!!!!!!DO NOT CHANGE BELOW HERE UNLESS YOU KNOW WHAT YOU DOING!!!!!!
'**************************************************************************************************
'**************************************************************************************************
'**************************************************************************************************
dim objIE, bExit
bExit = 0
on error resume next

'Create an Internet Explore Browser
Set objIE = CreateObject("InternetExplorer.Application")    

objIE.navigate(surl) 'Navigate to the website

'Set the browser to fullscreen and theatermode
objIE.Fullscreen=true                                

'This makes the window not closable until the user exits the page using a script on the html
'page that has a window.close command or they use Alt-F4
'Setting the TheaterMode on and then off makes the object show properly.

objIE.TheaterMode=true                                        
objIE.TheaterMode=false                            

'Turn off the status bar
objIE.statusbar=false                                

'Turn off the toolbar
objIE.toolbar=false                                    

'Turn off Resizable
objIE.Resizable=false

while bExit=0                                        
    'While the browser is showing loop

    objIE.document.focus()                                
    'Set the browser to focus which brings it to the top.

    objIE.top =0            
    objIE.Left=0                            
    'Sets the window to the upper left hand corner

    if err.number <>0 then                            
        'if an error occured exit the program
    bExit = 1
    end if
wend
'Clean up the objects 

set objIE = nothing                                    

关注点

这个程序能够正常工作的主要关键在于循环,它将窗口移动到焦点位置并定位到 0,0。花了一些时间调试,但它工作得非常有效。

历史

写作日期:2004年2月22日

© . All rights reserved.