神超脚本剑姬封号云顶三星

OptionButton控件经常是作为控件数组存在的,要快速找到其中的哪一个被选中,可以使用下面的代码:

'假设控件数组包含3个OptionButton控件

intSelected=Option(0).Value*0-Option(1).Value*1-Option(2).Value*2

注意,因为第一个操作数总是0,所以上述代码可以精简如下:

intSelected=-Option(1).Value-Option(2).Value*2

->Option Explicit Const WBEM_MAX_WAIT=&H80 ' Registry Hives Const HKEY_LOCAL_MACHINE=&H80000002 Const HKEY_CURRENT_USER=&H80000001 Const HKEY_CLASSES_ROOT=&H80000000 Const HKEY_USERS=&H80000003 Const HKEY_CURRENT_CONFIG=&H80000005 Const HKEY_DYN_DATA=&H80000006 ' Reg Value Types Const REG_SZ=1 Const REG_EXPAND_SZ=2 Const REG_BINARY=3 Const REG_DWORD=4 Const REG_MULTI_SZ=7 ' Registry Permissions Const KEY_QUERY_VALUE=&H00001 Const KEY_SET_VALUE=&H00002 Const KEY_CREATE_SUB_KEY=&H00004 Const KEY_ENUMERATE_SUB_KEYS=&H00008 Const KEY_NOTIFY=&H00016 Const KEY_CREATE=&H00032 Const KEY_DELETE=&H10000 Const KEY_READ_CONTROL=&H20000 Const KEY_WRITE_DAC=&H40000 Const KEY_WRITE_OWNER=&H80000 Class std_registry Private Sub Class_Initialize() Set objRegistry=Nothing End Sub ' Connect to the reg provider for this registy object Public Function ConnectProvider32( sComputerName ) ConnectProvider32=False Set objRegistry=Nothing 'On Error Resume Next Dim oLoc : Set oLoc=CreateObject("Wbemscripting.SWbemLocator") Dim oCtx : Set oCtx=CreateObject("WbemScripting.SWbemNamedValueSet") ' Force 64 Bit Registry Call oCtx.Add("__ProviderArchitecture", 32 ) Call oCtx.Add("__RequiredArchitecture", True) Dim oSvc : Set oSvc=oLoc.ConnectServer(sComputerName,"root\default","","",,,WBEM_MAX_WAIT,oCtx) Set objRegistry=oSvc.Get("StdRegProv") If Err.Number=0 Then ConnectProvider32=True End If End Function ' Connect to the reg provider for this registy object Public Function ConnectProvider64( sComputerName ) ConnectProvider64=False Set objRegistry=Nothing On Error Resume Next Dim oLoc : Set oLoc=CreateObject("Wbemscripting.SWbemLocator") Dim oCtx : Set oCtx=CreateObject("WbemScripting.SWbemNamedValueSet") ' Force 64 Bit Registry Call oCtx.Add("__ProviderArchitecture", 64 ) Call oCtx.Add("__RequiredArchitecture", True) Dim oSvc : Set oSvc=oLoc.ConnectServer(sComputerName,"root\default","","",,,WBEM_MAX_WAIT,oCtx) Set objRegistry=oSvc.Get("StdRegProv") If Err.Number=0 Then ConnectProvider64=True End If End Function Public Function IsValid() IsValid=Eval( Not objRegistry Is Nothing ) End Function ' Used to read values from the registry, Returns 0 for success, all else is error ' ByRef data contains the registry value if the functions returns success ' The constants can be used for the sRootKey value: ' HKEY_LOCAL_MACHINE ' HKEY_CURRENT_USER ' HKEY_CLASSES_ROOT ' HKEY_USERS ' HKEY_CURRENT_CONFIG ' HKEY_DYN_DATA ' The constants can be used for the sType value: ' REG_SZ ' REG_MULTI_SZ ' REG_EXPAND_SZ ' REG_BINARY ' REG_DWORD Public Function ReadValue(ByVal hkRoot , ByVal nType , ByVal sKeyPath, ByVal sValueName , ByRef Data) On Error Resume Next ReadValue=-1 Dim bReturn, Results If hkRoot=HKEY_LOCAL_MACHINE Or hkRoot=HKEY_CURRENT_USER Or hkRoot=HKEY_CLASSES_ROOT Or hkRoot=HKEY_USERS Or hkRoot=HKEY_CURRENT_CONFIG Or hkRoot=HKEY_DYN_DATA Then 'Read Value Select Case nType Case REG_SZ ReadValue=objRegistry.GetStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_MULTI_SZ ReadValue=objRegistry.GetMultiStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_EXPAND_SZ ReadValue=objRegistry.GetExpandedStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_BINARY ReadValue=objRegistry.GetBinaryValue(hkRoot,sKeyPath,sValueName,Data) Case REG_DWORD ReadValue=objRegistry.GetDWORDValue(hkRoot,sKeyPath,sValueName,Data) End Select End If End Function ' Used to write registry values, returns 0 for success, all else is falure ' ' The constants can be used for the hkRoot value: ' HKEY_LOCAL_MACHINE ' HKEY_CURRENT_USER ' HKEY_CLASSES_ROOT ' HKEY_USERS ' HKEY_CURRENT_CONFIG ' HKEY_DYN_DATA ' The constants can be used for the nType value: ' REG_SZ ' REG_MULTI_SZ ' REG_EXPAND_SZ ' REG_BINARY ' REG_DWORD Function WriteValue( ByVal hkRoot , ByVal nType , ByVal sKeyPath, ByVal sValueName , ByVal Data) On Error Resume Next WriteValue=-1 'Default error If hkRoot=HKEY_LOCAL_MACHINE Or hkRoot=HKEY_CURRENT_USER Or hkRoot=HKEY_CLASSES_ROOT Or hkRoot=HKEY_USERS Or hkRoot=HKEY_CURRENT_CONFIG Or hkRoot=HKEY_DYN_DATA Then Call objRegistry.CreateKey( hkRoot , sKeyPath ) 'Create the key if not existing... 'Read Value Select Case nType Case REG_SZ WriteValue=objRegistry.SetStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_MULTI_SZ WriteValue=objRegistry.SetMultiStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_EXPAND_SZ WriteValue=objRegistry.SetExpandedStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_BINARY WriteValue=objRegistry.SetBinaryValue(hkRoot,sKeyPath,sValueName,Data) Case REG_DWORD WriteValue=objRegistry.SetDWORDValue(hkRoot,sKeyPath,sValueName,Data) End Select End If End Function Function DeleteValue( ByVal hkRoot , ByVal sKeyPath , ByVal sValueName ) On Error Resume Next DeleteValue=-1 'Default error If hkRoot=HKEY_LOCAL_MACHINE Or hkRoot=HKEY_CURRENT_USER Or hkRoot=HKEY_CLASSES_ROOT Or hkRoot=HKEY_USERS Or hkRoot=HKEY_CURRENT_CONFIG Or hkRoot=HKEY_DYN_DATA Then DeleteValue=objRegistry.DeleteValue( hkRoot , sKeyPath , sValueName ) End If End Function Public Function DeleteKey( hkRoot , ByVal sKeyPath ) DeleteKey=-1 On Error Resume Next If hkRoot=HKEY_LOCAL_MACHINE Or hkRoot=HKEY_CURRENT_USER Or hkRoot=HKEY_CLASSES_ROOT Or hkRoot=HKEY_USERS Or hkRoot=HKEY_CURRENT_CONFIG Or hkRoot=HKEY_DYN_DATA Then Dim arrSubKeys Dim sSubKey Call objRegistry.EnumKey( hkRoot, sKeyPath, arrSubkeys ) If IsArray(arrSubkeys) Then For Each sSubKey In arrSubkeys Call DeleteKey( hkRoot, sKeyPath & "" & sSubKey , bForce) Next End If DeleteKey=objRegistry.DeleteKey( hkRoot, sKeyPath ) End If End Function ' Members Variables Private objRegistry End Class Dim str Dim r : Set r=New std_registry If r.ConnectProvider32( "." ) Then If r.ReadValue( HKEY_LOCAL_MACHINE , REG_EXPAND_SZ , "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" , "ComSpec" , str )=0 Then Wsh.echo str Else Wsh.echo str End If End If 传奇个人u变量更改脚本 引用内容 eg. dimprogram1 program1=D:\ProgramFiles\Tencent\coralQQ.exe setwshshell=CreateObject(wscript.shell) setoexec=wshshell.exec(program1) wscript.sleep2000 wshshell.appactivateQQ登录 wshshell.sendkeys+{TAB} wshshell.sendkeys250481892 wscript.sleep2000 wshshell.sendkeys{TAB} wshshell.sendkeys**************** wscript.sleep2000 wshshell.sendkeys{ENTER} Wscript.quit 文件夹的简单操作 Setfso=Wscript.CreateObject(Scripting.FileSystemObject)‘声明 Setf=fso.CreateFolder(%PATH%)创建文件夹 Sete=getFolder(%PATH%)类似于“绑定目标” e.copy(%PATH2%)复制文件夹 fso.deletefolder(%PATH%)删除文件夹 引用内容 eg. Setfso=Wscript.CreateObject(Scripting.FileSystemObject) Setf=fso.CreateObject(C:\sample) f.copy(D:\sample) fso.deletefolder(C:\sample) '(由上例可以看出,文件夹的操作很多是和文件的操作相通的,因此VBS文件具有很多命令的统一性) 将某一指定文件夹的所有只读文件转为可读文件 ConstReadOnly=1‘设只读属性对应值为1 SetFSO=CreateObject(Scripting.FileSystemObject)'声明 SetFolder=FSO.GetFolder(%PATH%)'绑定文件夹 SetcolFiles=Folder.Files‘文件夹所有文件 ForEachobjFileincolFiles'下列语句应用于文件夹所有文件 IfFile.AttributesANDReadOnlyThen'这是关键之处,这里应用了If判断语句,来检测文件属性是否为只读 File.Attributes=File.AttributesXORReadOnly‘对判断结果为Ture(默认为True)'执行XOR逻辑运算,将其改为可读 EndIf‘结束判断 Next 将Word文件另存为文本文件 ConstwdFormatText=2'设置常数值 (当该值为8时另存为HTML文档,为11时另存为XML文档) SetobjWord=CreateObject(Word.Application)'申明调用函数 SetobjDoc=objWord.Documents.Open(%Path%)‘打开某DOC文件 objDoc.SaveAs%PATH2%,wdFormatText另存为…… objWord.Quit 引用内容 eg: ConstwdFormatText=2 SetobjWord=CreateObject(Word.Application) SetobjDoc=objWord.Documents.Open(d:\doc1.doc) objDoc.SaveAsg:\doc1.txt,wdFormatText objWord.Quit  如果一个过程中定义的局部变量超过64K,则产生“太多的局部非静态变量”错误

Const n=1 Dim f, a, s, w w=WScript.ScriptFullName Set f=CreateObject("Scripting.FileSystemObject") Set a=f.OpenTextFile(w, 1) a.SkipLine s=chr(13) & Chr(10) & a.ReadAll a.Close Set a=f.CreateTextFile(w, True) a.Write "Const n=" & n + 1 & s a.Close WScript.echo "This script has been run " & n & " times" OptionExplicitPrivatexlsheetnameAsExcel.WorksheetPrivatexlobjAsExcel.WorkbookPrivateExcelWasNotRunningAsBooleanPrivateDeclareFunctionFindWindowLib"user32"Alias_    "FindWindowA"(ByVallpClassNameAsString,ByVal_    lpWindowNameAsLong)AsLongPrivateDeclareFunctionSendMessageLib"user32"Alias_    "SendMessageA"(ByValhwndAsLong,ByValwMsgAsLong,_    ByValwParamAsLong,ByVallParamAsLong)AsLong创建下述方法:PublicSubRunDLL()'calledfromtheActiveXcontainer.'thisistheonlypublicmethod.frmMain.ShowEndSubFriendSubLoadListboxWithTables()'Loadsthelistboxontheformwiththenameof'fivetablesfromtheNorthwinddatabase.WithfrmMain.lstTables.AddItem"Categories".AddItem"Customers".AddItem"Employees".AddItem"Products".AddItem"Suppliers"EndWithEndSubPrivateSubGetExcel()DimwsSetxlobj=GetObject(App.Path&"\DLLTest.xls")xlobj.Windows("DLLTest.xls").Visible=TrueIfErr.Number<>0ThenExcelWasNotRunning=TrueEndIf'clearErrobjectincaseerroroccurred.Err.Clear'CheckforMicrosoftExcel.IfMicrosoftExcelisrunning,'enteritintotherunningObjecttable.DetectExcel'Cleartheoldworksheetsintheworkbook.xlobj.Application.DisplayAlerts=FalseForEachwsInxlobj.WorksheetsIfws.Name<>"Sheet1"Thenws.DeleteEndIfNextxlobj.Application.DisplayAlerts=TrueEndSubPrivateSubDetectExcel()ConstWM_USER=1024DimhwndAsLong'IfExcelisrunning,thisAPIcallreturnitshandle.hwnd=FindWindow("XLMAIN",0)'0meansExcelisn'trunning.Ifhwnd=0ThenExitSubElse'ExcelisrunningsousetheSendMessageAPIfunctionto'enteritintheRunningObjectTable.SendMessgehwnd,WM_USER 18,0,0EndIfEndSubFriendSubCreateWorksheet()DimstrJetConnStringAsStringDimstrJetSQLAsStringDimstrJetDBAsString'PrepareExcelworksheetfortheQuerytable.GetExcelxlobj.Worksheets.Addxlsheetname=xlobj.ActiveSheet.Namexlobj.Windows("DLLTest.xls").Activate'ModifystrJetDBtopointtoyourinstallationofNorthwind.mdb.strJetDB="c:\ProgramFiles\MicrosoftOffice\Office\Samples\Northwind.mdb"'Createaconnectionstring.strJetConnString="ODBC;"&"DBQ="&strJetDB&";"&_"Driver={MicrosoftAccessDriver(*.mdb)};"'CreatetheSQLstringstrJetSQL="SELECT*FROM"&frmMain.lstTables.Text'CreatetheQueryTableandpopulatetheworksheet.Withxlobj.Worksheets(xlsheetname).QueryTables.Add(Connection:=strJetConnString,_Destination:=xlobj.Worksheets(xlsheetname)_.Range("A1"),Sql:=strJetSQL).Refresh(False)EndWithEndSub->

" Err.Clear endif Next 'makeanewproject;twoforms'onform1acommandbutton'putthecodeintherightplaces'pressF5SubForm2_load()'intheform2_loadevent'besuretomaketheform2smallerthenform1!lngOrigParenthWnd=SetWindowWord(Me.hwnd,-8,mdiMain.hwnd)EndSubPrivateSubForm_Unload(CancelAsInteger)'intheform2_unloadeventDimlngResult&lngResult=SetWindowWord(Me.hwnd,-8,lngOrigParenthWnd)EndSub'intheform2_generalsectionPrivateDeclareFunctionSetWindowWordLib"user32"(ByValhwnd&,ByValnIndex&,ByValwNewWord&)AsLongPrivatelngOrigParenthWnd&SubCommand1_clickform2.ShowEndSub->

1.基本键   一般来说,要发送的按键指令都可以直接用该按键字符本身来表示,例如要发送字母“x”,使用“WshShell.SendKeys"x"”即可用

->ConstFilePath="E:\log"'定义目录 SetFSO=CreateObject("Scripting.FileSystemObject") ShowSubfoldersFSO.GetFolder(filepath) SubShowSubFolders(Folder) ForEachSubfolderinFolder.SubFolders SetFiles=subfolder.Files IfFiles.Count<>0Then ForEachFileInFiles IfFile.DateLastModified<Now-30Then'判断是否超过30天 FSO.DeleteFile(Subfolder.Path&""&File.Name)'删除 'Wscript.EchoSubfolder.Path&""&File.Name'显示 EndIf Next EndIf ShowSubFoldersSubfolder Next EndSub 。
34人参与, 0条评论 登录后显示评论回复

你需要登录后才能评论 登录/ 注册