Auto你的IT——AutoIt是啥?

凌云用AutoIt编写了一段代码,让同事佳佳的鼠标失控,随后解释了这段代码的功能及AutoIt的基本概念。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

凌云和佳佳是一家软件公司中的两个开发人员,由于凌云比佳佳早到公司3年,而毕业的时间更是比佳佳早了差不多10年,因此,佳佳从大学毕业之后,进入到这家公司,就和凌云一起混了,关系很简单,就和从前的师徒类似,但是现代社会中只能是叫做同事。

这一天,佳佳正在伏案编码,突然屏幕的右下角蹦出来邮件的提示信息,原来是凌云发过来的,主题很简单:帮我试试。

“哦?这又是什么东东。”佳佳也没有太在意,顺手打开邮件,看到里面有一个附件,是个压缩包。

打开压缩包,里面有一个可执行的.exe文件,图标没见过,有点像三角洲部队的标志,虽说心中有些疑惑,因为公司规定,不可以在邮件中传送可执行的文件,因为其中可能会带有病毒或者木马什么的。但是转念又一想,做师傅的总不能把不好的东西发给我吧,而且说是要试试,应该知道发送的是什么,不会有什么事儿的。

边想着,佳佳就一边双击了解压出来的文件,可真是不点不知道,一点吓一跳!屏幕上的鼠标箭头不受控制了,像一直疯狂的老鼠一样到处乱跑,而且还毫无规律!

“师父,你搞什么?是不是把病毒传给我了?!”

转头一看,之间凌云一脸坏笑地看着他,佳佳差点儿晕倒!不过回头看看自己的屏幕,鼠标箭头已经恢复了正常,还好,吓出一头的冷汗。

“你刚刚发给我的是什么东西啊?”佳佳还是心有余悸。

“呵呵,没啥,我就是做个试验,不是病毒,也不是木马。”凌云的样子很无辜,其实心里暗笑:就是个恶作剧。

“那不行,吓死我了,你得赔我。”

“怎么赔啊?”

“你必须告诉我你那个东西是怎么做出来的!”

“哦,就这么点儿要求啊,没有问题。”

说着,凌云回到自己的电脑旁,打开了一个文件,然后叫佳佳,“过来看看,这个就是让你的鼠标疯狂的东西。”

佳佳跑过去一看,只见凌云的电脑屏幕上有一段代码,非常简单的代码:

 

For $i = 1 to 20

	$x = Random(100,1000)
	$y = Random(100,800)

	MouseMove($x, $y)

Next

佳佳有点纳闷了,就这么点儿代码,就把我的鼠标给控制了?实在是不可思议。而且这段代码有点儿奇怪,不像是一般使用的语言,既不是Java,也不是C#,倒是和VB有点儿像,但是变量定义的方式又不对,而且似乎也没记得VB里面有MouseMove这个函数。

“师父,你这是什么代码啊?”

“哦,这个是AutoIt的脚本。”

“AutoIt?那是个啥?”

“怎么说呢,就是个超级强大的用来编写批处理的语言,现在有个比较流行的名称叫脚本语言。”

“哦,这么说我有点儿明白了,那么它能做什么呢?”

“我现在也刚刚开始研究,感觉功能挺强大的,主要就是可以模拟你的鼠标和键盘操作。”

“那是挺厉害的,不过也挺危险的啊!”佳佳不由得又想到了刚才自己的鼠标疯狂的样子。

“呵呵,技术本身没有好坏,问题在于使用技术的人。这个道理就和针对核能的讨论一样啊。”

“也是。呵呵。”

佳佳又低下头,看是看那几句超级简单的代码。

“哦,其实这段代码很简单,我能猜出是什么意思。”

“好啊,那么你来说说看。”

佳佳一边看,一边说:“其实就是一个for循环,循环了20次,每次都取两个变量值,应该是作为屏幕上的坐标吧,然后把鼠标指针移动到这个位置上。因为x、y两个值是随机的,所以我的指针刚才也比较疯狂,不过执行完20次就结束了。”

凌云对佳佳阅读代码的能力表示赞许,“不错,你理解的完全正确。”

佳佳抬起头,笑嘻嘻地说:“师父,你还挺仁慈的啊,没把循环变量的值设置为200,要不我就惨了,哈哈。”

凌云很高兴,“那是那是。”

“不过你必须要把你所知道的都告诉我,否则我就向公司举报,说你给我发恶意程序!”

得,原来是先礼后兵,后面还有目的的啊。不过本来就是要和佳佳分享这些知识的,凌云想到这,也就释然了。

“那以后的几天里,我们就一起来研究这个AutoIt吧。”

“太好了!”

#include "ContactPerson.h" #include <iostream> #include"Person.h" #ifndef ContactPerson.cpp #include<string> #include<vector> #include<fstream> #include <algorithm> #include<sstream> using namespace std; void contact_Person::Menu() { //菜单 ; cout << "=======================================================================" << endl; cout << "=========================== 联系人管理系统 ============================" << endl; cout << "=======================================================================" << endl; cout << "|| 1. 添加人员 ||" << endl; cout << "|| 2. 按姓名电话查询 ||" << endl; cout << "|| 3. 按地址模糊查询 ||" << endl; cout << "|| 4. 按类别查询 ||" << endl; cout << "|| 5. 按姓名排序输出 ||" << endl; cout << "|| 6. 修改信息 ||" << endl; cout << "|| 7. 按姓名电话删除 ||" << endl; cout << "|| 8. 显示所有联系人 ||" << endl; cout << "|| 0. 退出系统 ||" << endl; cout << "=======================================================================" << endl; } void contact_Person::output() { //输入功能; string name1, sex, address, postal_code1, classification,qq; string telephone; string chiose, Letter_box2; ofstream mycout("D:\\Flie.txt",ios::app); if (!mycout) { cout << "打开文件失败" << endl; } else { do { cout << "请输入名字" << " "; cin >> name1; std::system("cls"); cout << "请输入性别" << " "; cin >> sex; std::system("cls"); cout << "请输入电话" << " "; cin >> telephone; std::system("cls"); cout << "请输入地址" << " "; cin >> address; std::system("cls"); cout << "请输入邮编" << " "; cin >> postal_code1; std::system("cls"); cout << "请输入邮箱" << " "; cin >> Letter_box2; std::system("cls"); cout << "请输入QQ号" << " "; cin >> qq; std::system("cls"); cout << "请输入类别" << " "; cin >> classification; std::system("cls"); mycout << "名字" << name1 << " " << "性别" << sex << " " << " 电话" << telephone << " " << "地址" << address << " " << "邮编" << postal_code1 << " " << " 邮箱" << Letter_box2 << " " << "QQ号" << qq << " " << "类别" << classification << endl; ifstream mycin("D:\\Flie.txt", ios::in); if (!mycin) { cout << "读取失败" << endl; } //将读取的文件存放到一个line变量 string line; while (getline(mycin, line)) { istringstream iss(line); iss >> name1 >> sex >> address >> classification >> Letter_box2 >> postal_code1 >> qq >> telephone; //这是把输入的变量先存放到一个新的contact_Person类的对象, // 然后把这个新的对象作为被读取的值传给一个contact_Person类型的contact容器中; contact_Person newcontact_Person(name1, sex, address, classification, Letter_box2, postal_code1, qq, telephone); contact.push_back(newcontact_Person); contact.size(); } cout << " 添加成功" << endl; cout << " 是否继续输入y(是)/n(否)" << endl; cin >> chiose; } while (chiose != "n"); mycout.close(); } } void contact_Person::Query_function1() { string chiose; //查询功能1(姓名·电话查询信息); do { cout << "请选择1名字查寻,2电话查询" << endl; int a; cin >> a; if (a == 1) { cout << " 请输入要查询的人名字" << endl; string NAME; cin >> NAME; //用find_if查找(find_if,为algorithm库中函数),遍历容器contact(容器contact在输入是已经输入过值) //此时只需找到name==NAME; auto it = find_if(contact.begin(), contact.end(), [&NAME]( contact_Person& obj) { return obj.Name == NAME; }/*这里是所要查询的元素,返回contact_Person类中和输入相同的name,作为find_if的需查询内容的参数*/); if (it != contact.end()) { // 找到 contact_Person& found = *it; // 解引用迭代器,得到对象 std::system("cls"); cout << "姓名" << found.Name << " " << "性别" << found.Sex << " " << "电话" << found.TelePhone << " " << "地址" << found.Address << " " << "邮编" << found.Postal_code << " " << " 邮箱" << found.Letter_box << " " << "QQ号" << found.QQ << " " << "类别" << found.Classification << endl; } else { cout << "未找到姓名为 [" << NAME << "] 的联系人" << endl; system("pause"); } system("cls"); cout << "是否继续查询y(是)/n(否)" << endl; cin >> chiose; } else if (a == 2) { // 电话查询 cout << "请输入要查询的人电话" << endl; string TELEPHONE; cin >> TELEPHONE; //用find_if查找(find_if, 为algorithm库中函数), // 遍历容器contact(容器contact在输入是已经输入过值) auto IT = find_if(contact.begin(), contact.end(), [&TELEPHONE]( contact_Person& obj2) { return obj2.TelePhone == TELEPHONE; }); if (IT != contact.end()) { contact_Person& found = *IT; std::system("cls"); cout << "姓名" << found.Name << " " << "性别" << found.Sex << " " << "电话" << found.TelePhone << " " << "地址" << found.Address << " " << "邮编" << found.Postal_code << " " << " 邮箱" << found.Letter_box << " " << "QQ号" << found.QQ << " " << "类别" << found.Classification << endl; } else { cout << "未找到电话为 [" << TELEPHONE << "] 的联系人" << endl; system("pause"); } system("cls"); cout << "是否继续查询y(是)/n(否)" << endl; cin >> chiose; } } while (chiose != "n" ); } //查询功能2(地址模糊查寻) ; void contact_Person::Query_function2() { string chiose; do { string ADDRESS; cout << " 请输入地址" << endl; cin >> ADDRESS; //用find_if查找(find_if, 为algorithm库中函数), // 遍历容器contact(容器contact在输入是已经输入过值) auto IT2 = find_if(contact.begin(), contact.end(), [&ADDRESS]( contact_Person obj3) { return obj3.Address == ADDRESS; }); if (IT2 != contact.end()) { contact_Person& found = *IT2; std::system("cls"); cout << "姓名" << found.Name << " " << "性别" << found.Sex << " " << "电话" << found.TelePhone << " " << "地址" << found.Address << " " << "邮编" << found.Postal_code << " " << " 邮箱" << found.Letter_box << " " << "QQ号" << found.QQ << " " << "类别" << found.Classification << endl; } else { cout << "未找到地址为 [" << ADDRESS << "] 的联系人" << endl; } cout << "是否继续查询y(是)/n(否)" << endl; cin >> chiose; } while (chiose != "n"); } //查询功能3(类别查询); void contact_Person::Query_function3() { string chiose; do { string CLASSIFICATION; cout << " 请输入类别" << endl; cin >> CLASSIFICATION; //find_if( auto TI3 = find_if(contact.begin(), contact.end(), [&CLASSIFICATION]( contact_Person& obj4){ return obj4.Classification == CLASSIFICATION; }); if (TI3 != contact.end()) { contact_Person& found4 = *TI3; std::system("cls"); cout << "姓名" << found4.Name << " " << "性别" << found4.Sex << " " << "电话" << found4.TelePhone << " " << "地址" << found4.Address << " " << "邮编" << found4.Postal_code << " " << " 邮箱" << found4.Letter_box << " " << "QQ号" << found4.QQ << " " << "类别" << found4.Classification << endl; } else { cout << "未找到类别为 [" << CLASSIFICATION << "] 的联系人" << endl; } cout << "是否继续查询y(是)/n(否)" << endl; cin >> chiose; } while (chiose != "n"); } //根据姓名排序输出(名字首字母顺序); void contact_Person::Name_sorting_output() { } void contact_Person::Alter() { //修改信息; cout << "请输入你要修改的内容" << endl; string name, sex, Address, QQ, Classification; string Postal_code, TlePhone; cout << "请选择修改的字段:" << endl; cout << "1: 姓名" << endl; cout << "2: 性别" << endl; cout << "3: 电话" << endl; cout << "4: 地址" << endl; cout << "5: 邮编" << endl; cout << "6: 邮箱" << endl; cout << "7: QQ" << endl; cout << "8: 类别" << endl; int choice; cin >> choice; switch (choice) { case 1: cout << "请输入修改后的姓名" << endl; cin >> name; break; case 2: cout << "请输入修改后的性别" << endl; break; case 3: default: break; } } //未完待续 void contact_Person::Name_TelePhone_Alter() {} //根据姓名·电话修改; void contact_Person::Name_TelePhone_Delete() {} //根据姓名·电话删除 ; void contact_Person::Dispiay() { cout << " " << endl; system("cls"); cout << "______________________________这是从文件中读取的————————————————" << endl; ifstream mycin("D:\\Flie.txt", ios::in); if (!mycin) { cout << "读取失败" << endl; } string line; while (getline(mycin, line)) { // 读取整行内容 cout << line << endl; } mycin.close(); cout << "____________________________________________________________________________" << endl; cout << "__________________________下面是读取的一个string容器contac2的内容———————————————" << endl; ifstream mycin1("D:\\Flie.txt", ios::in); if (!mycin1) { cout << "读取失败" << endl; } string line1; while (getline(mycin1, line1)) { contact2.push_back(line1); for ( auto& str : contact2) { cout << str << endl; contact2.clear(); } } mycin.close(); system("pause"); system("cls"); } #endif // !Contact_Person.cpp
最新发布
06-19
### AutoIt 中文编程教程和资源 对于希望学习AutoIt中文编程的人来说,yidabu.com提供了精心编写的Autoit中文帮助零起点系列中文教程,使得即使没有任何编程语言基础的人也能够轻松入门[^1]。这些教程覆盖了从基础知识到高级特性的广泛主题,确保用户可以逐步深入理解这门脚本语言。 #### 官方论坛交流 完成初步的学习之后,鼓励访问者前往bbs.yidabu.com参与社区讨论。这里不仅是分享经验的好地方,也是解决遇到的具体问题的有效途径之一。活跃于这样的技术社群有助于加深对AutoIt的理解,并能与其他爱好者共同进步。 #### GUI测试工具中的控件操作 当涉及到图形界面的应用程序自动化时,掌握如何精确控制各个组件变得至关重要。具体来说,在处理GUI元素的选择与取消方面,可以通过`ControlCommand`函数实现这一目标。该函数允许发送特定指令给指定窗口内的某个控件,从而达到改变其状态的效果。例如: ```autoit ; 假设我们要在一个对话框里勾选复选框并取消另一个复选框的状态 ControlCommand("我的应用程序", "", "[CLASS:Button; INSTANCE:1]", "Check", "") ; 勾选第一个实例的按钮 ControlCommand("我的应用程序", "", "[CLASS:Button; INSTANCE:2]", "Uncheck", "") ; 取消第二个实例的按钮 ``` 这段代码展示了怎样利用`ControlCommand`来分别执行“检查”(即勾选) 和 “未检查” (即取消勾选) 的动作[^2]。
评论 56
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值