当前位置:网站首页>脚本之美│VBS 入门交互实战
脚本之美│VBS 入门交互实战
2022-06-24 12:38:00 【51CTO】
目录
一、什么是 VBS
VBS是一种Windows脚本语言,全称是Microsoft Visual Basic Script Editon,微软公司可视化 BASIC 脚本版vbs是系统内置的,代码可在windows系统中直接执行,不需要编译环境,非常的方便vbs脚本简单,高效,大部分功能都可以实现,利用好vbs脚本,可以极大的提高效率,可以用它来做一些反复繁琐的机器操作
二、第一个 VBS 脚本
- 在桌面上新建一个文本文档
- 打开文本文档,在其中输入
msgbox "Hello World!" - 将文本文档的格式后缀
.txt改为.vbs - 然后双击运行文件即可

三、msgbox 语法
- 语法:
msgbox "对话框内容","对话框类型(参数:0,1,2,3,4,5)","对话框标题" - 对话框内容:是指弹窗的主体内容
- 对话框类型:可以选择
0-5共6种类型的对话框模式,0时对话框只有确定按钮;1时对话框有确定按钮、取消按钮;2时对话框有中止按钮、重试按钮、忽略按钮;3时对话框有是按钮、否按钮、取消按钮;4时对话框有是按钮、否按钮并且对话框禁止点击右上角的关闭按钮;5时对话框有重试按钮、取消按钮。如果不填默认为0 - 对话框标题:是指弹窗的标题

四、中文乱码
- 上图可以看到中文乱码了
- 这主要是因为编码错误导致的,正常的文本文档它的编码格式是
UTF-8的,但是VBS脚本需要编码格式是ANSI才可以正常运行中文 - 这时候我们需要
打开文本文档►点击左上角文件►另存为►选择编码为ANSI►确定即可解决

五、弹窗交互功能
- 上面我们只是实现了很简单的展示功能,那么我们需要实现交互功能,就要用到变量了
- 在
vbs中可以通过dim定义变量,语法为:dim 变量名1,变量名2,变量名3...变量名n - 其中
inputbox可以用来接收用户手动输入的参数


六、表白恶搞
- 之前很火的关闭不了的表白弹窗,就是
vbs做出来的 - 使用
dim a(5)可以定义数组,5表示这个数组里面有多少元素 - 使用
Select Case表示这是一个选项 - 其中选择同意的返回值为6,不同意的返回值为7
- 如果点击了不同意,那就循环从数组中取值展示
- 如果用户点击了同意,那就阴谋得逞,退出选项


边栏推荐
- Argo 全家桶如何让 DevOps 变的更容易?
- From theory to practice, decipher Alibaba's internal MySQL optimization scheme in simple terms
- WPF从零到1教程详解,适合新手上路
- [live broadcast of celebrities] elastic observability workshop
- Continuous testing | key to efficient testing in Devops Era
- Essential key steps in the construction of e-commerce live broadcast source code
- Configuration (enable_*) parameter related to execution plan in PG
- 强化学习之父Richard Sutton论文:追寻智能决策者的通用模型
- Sqlserver 2000 has long-lasting vitality
- How to efficiently analyze online log
猜你喜欢

使用 Abp.Zero 搭建第三方登录模块(一):原理篇

Parse NC format file and GRB format file dependent package edu ucar. API learning of netcdfall

Detailed explanation of abstractqueuedsynchronizer, the cornerstone of thread synchronization

钉钉、飞书、企业微信:迥异的商业门道

【数据库】期末复习(计科版)

Use terminal to activate CONDA service in pypharm (the ultimate method is definitely OK)

Babbitt | metauniverse daily must read: 618 scores have been announced. How much contribution has the digital collection made behind this satisfactory answer

Several common DoS attacks

“有趣” 是新时代的竞争力

LVGL库入门教程 - 颜色和图像
随机推荐
What are the software prototyping tools?
go Cobra命令行工具入门
The pod is evicted due to insufficient disk space of tke node
Making daily menu applet with micro build low code
实现领域驱动设计 - 使用ABP框架 - 创建实体
Another prize! Tencent Youtu won the leading scientific and technological achievement award of the 2021 digital Expo
YOLOv6:又快又准的目标检测框架开源啦
微医CodeReview工具链
Engage in audio and video development? Several things I have to say about SRT live broadcast protocol
用一个软件纪念自己故去的母亲,这或许才是程序员最大的浪漫吧
what the fuck! I'm flattered. He actually wrote down the answers to the redis interview questions that big companies often ask!
Fbnet/fbnetv2/fbnetv3: Facebook's lightweight network exploration in NAS | lightweight network
About me, a 19 line programmer
Getting started with scrapy
A scheme for crawlers to collect public opinion data
"I, an idiot, have recruited a bunch of programmers who can only" Google "
WPF从零到1教程详解,适合新手上路
Codereview tool chain for micro medicine
实现领域驱动设计 - 使用ABP框架 - 创建实体
文本转语音功能上线,可以体验专业播音员的服务,诚邀试用