欢迎来到天天文库
浏览记录
ID:51493202
大小:282.25 KB
页数:26页
时间:2020-03-25
《Windows脚本编程核心技术精解Chapter12.pdf》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、4684-8ch12.f.qc3/3/009:38AMPage367Chapter12GainingFullControlOverAnyWindowInThisChapterAccessanywindowdirectlyusingitshandleRetrieveanywindow’sclassnameforsafeidentificationBringawindowsafelyintotheforegroundMakewindowsinvisibleandchangewindowstyledynamical
2、lyFlashawindow’stitlebarCapturewindowcontentandsaveittodiskExplorewindowinternalsandwalkingwindowhierarchiesWindowhandlesarethekeytomanipulatinganywindow.Inthischapter,youlearnmanynewmethodsforsolvingcommonproblems.Amongthemanynewsolutions,yourscriptswillbea
3、bletoswitchwindowstotheforegroundandcaptureentirewindowcontents.FullControlOverAnyWindowWindowsareallovertheplace—theyresembleuniversecontainersforyourprogramsandplayanimportantroleinreservingspace.Surprisinglyenough,theScriptingHostdoesn’tofferanywindowsupport
4、atall.Microsoftdidn’tincludeanymethodstocontrolthesizeofwindows,movethemaround,orbringthemintotheforeground.Fortunately,theWindowsAPIcontainsnumerousfunctionstoremotecontrolanywindow.Toaccessthesefeatures,allyouneedtodoisopentheCOMprojectIhavedesignedforyou:co
5、mponentswinmanagerwinmanager.vbp.Eveneasier,youcaninstallthepreparedsoftwarepackage:installwinmanagersetup.exe.4684-8ch12.f.qc3/3/009:38AMPage368368PartIII:StartingandControllingOtherSoftware■■AccessinganywindowThefirststepintothewindowworldisaccessingindi
6、vidualwindows.Windowsadministersindividualwindowssimilartoprocesses.EachwindowhasitsindividualID,thewindowhandle.It’sjustanumber.Youhavenumerouswaystofindoutthewindowhandleofanywindow.AccessingawindowbynameIfyouknowthenameofthewindowyouwanttoaccess,useGetWindow
7、-Handle.Thefollowingexampleasksyouforawindowname.Typeinanywindowname,buttakecaretotypeinthewindownameexactlyasitappearsinthewindow’stitlebar.Thescriptreturnsthewindowclass(seeFigure12-1).‘12-1.VBSsettool=CreateObject(“window.manager”)winname=InputBox(“Pleaseent
8、erthewindownameasitappearsin”_&“itstitlebar!”)handle=tool.GetWindowHandle(winname)ifhandle=0thenMsgBox“Couldn’tfindawindownamed“””&winname&“”””elseclassname=tool.GetWindowCl
此文档下载收益归作者所有