按键精灵循环指令问答题:循环如果a=b,且c=0,则c=1,如果a=b,且c=1,则退出循环,请给出代码

当前位置: >>
按键精灵5级认证考题添加了考试时候自己遇到的题
红色为自己总结的考题,黑色为网上资料 在路径为: C:\ajjl.txt 文本的每行内容后加上对应的行数,例如:ajjl-第 1 行.请写出代码 (禁止使 用命令库) wenben = Plugin.File.OpenFile(&c:\ajjl.txt&) //打开 ajjl.txt 文件,以备读写使用 Call Plugin.File.SeekFile(we
nben, 0) //设置文件的当前读写位置 For UBound(hangshu) // Call Plugin.File.WriteFile(wenben, hangshu(i) & &-第& & ii & &行& & vbcrlf) 向目标文件写入行数并换行 i = i + 1:ii = ii + 1Next Call Plugin.File.CloseFile(wenben) //关闭一个已经打开的文件。文件关闭后,其句柄不再有效EndScript如果鼠标停止动作超过 5 秒,则执行弹出信息提示框&鼠标停止动作&,请写出代码 GetCursorPos x1, y1 //得到鼠标位置 Delay 5000 //等待五秒重新判断鼠标位置, GetCursorPos x2, y2 If x1 = x2 and y1 = y2 then MessageBox &鼠标停止动作& End If限制鼠标范围在屏幕坐标(200,300)到(500,600)范围内,超出范围则回到边界(鼠 标范围限制) ,请写出代码。 x1 = 200 x2 = 500 y1 = 300 y2 = 600 Do GetCursorPos x, y If x & x1 or x & x2 or y & y1 or y & y2 Then // 当 x,y 有一个超出范围后, If x & x1 Then x = x1 ElseIf x & x2 Then x=x2 End If If y & y1 Then y = y1 ElseIf y & y2 Then y=y2 End If MoveTo x, y End If Loop写一个子程序,可以使鼠标从当前的坐标逐点的移动到目的坐标(带轨迹的鼠标移动),请写出 代码 (要求:轨迹为一条直线) etCursorPos x1, y1 //得到鼠标位置坐标 //x2,y2 为目标坐标 For i = 1 To 100 //把 x 和 y 等分 100 份 nx = (x2 - x1) / 100 ny = (y2 - y1) / 100 MoveTo int(x1 + i * nx), int(y1 + i * ny) Delay 10 Next End Sub鼠标按圆型移动,半径为 r=100,圆点为(200,200),请写出代码 Dim n, x, y MoveTo 100, 200 //确定圆点 For n = 0 To 360 x = 200 - 100 * cos(n*3.14/180) y = 200 - 100 * sin(n*3.14/180) // 根据直角三角形公式求两个直角边边长 MoveTo x, y Delay 10 Next EndScript 1、鼠标按圆型移动,半径为 r=100,圆点为(200,200),请写出代码. Dim a, x, y MoveTo 100, 200 For a = 0 To 360 x = 200 - 100 * cos(a*3.14/180) y = 200 - 100 * sin(a*3.14/180) MoveTo x, y Delay 5 Next EndScript1、(前台)区域范围为(100,150)到(200,300)内的所有点是否均为&FFFFFF&,是则弹出对话框&没 有其他颜色&,否则弹出第一个点的颜色值并退出程序. 请写出代码 x = 100 y = 150 RtColor = Plugin.Color.GetPixelColor(x, y, 0) RtColor1 = RtColor While (y & 300) x=100 While (x & 200) If RtColor = &FFFFFF& Then x=x+1 Else MessageBox RtColor1 ExitScript End If RtColor = Plugin.Color.GetPixelColor(x, y, 0) Wend y=y+1 Wend MessageBox &没有其他颜色& 2、利用多线程对多个记事本的窗口位置进行随机移动.请写出代码 RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& Delay 2000 DimEnv Hwnd1 HwndEx = Plugin.Window.Search(&记事本&) Hwnd = Split(HwndEx,&|&) If UBound(Hwnd) &= 0 Then For i = 0 To UBound(Hwnd) - 1 wnd = Clng(Hwnd(i)) Hwnd1 = wnd BeginThread 移动 Delay 100 Next End If Do Delay 1000 Loop Sub 移动 Hwnd2 = Hwnd1 Randomize x = Int(Rnd * 500) Randomize y = Int(Rnd*500) MessageBox x&&,&&y Call Plugin.Window.Move(Hwnd2, x+ 100, y + 100) End Sub 3、筛选出 100 以内所有个位数加十位数等于 10 的数,例如 82,8+2=10 满足条件,请写出代码 s=&& For i = 1 To 99 a = i mod 10 b = int(i / 10) If (a + b) = 10 Then s=s&i&&|& End If Next MessageBox s 4、写一个算法可以将十进制的字符串转成八进制的字符串.例如&8&-&&10&,请写出代码 Public Function DEC_to_OCT(Dec) DEC_to_OCT = && Do While Dec & 0 DEC_to_OCT = Dec Mod 8 & DEC_to_OCT Dec = Dec \ 8 Loop End Function a=DEC_to_OCT(&8&) MessageBox a 5、有 N 个窗口,第一个窗口移动到(0,0)点,其余的窗口根据第一个窗口平铺,窗口不超出屏幕 边缘(窗口平铺),请写出代码 RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& HwndEx = Plugin.Window.Search(&记事本&) Hwnd = Split(HwndEx, &|&) ScreenX = Plugin.Sys.GetScRX() ScreenY = Plugin.Sys.GetScRY() MessageBox ScreenX sRect = Plugin.Window.GetWindowRect(Hwnd(0)) MessageBox sRect xy = Split(sRect, &|&) x = xy(2) - xy(0) y = xy(3) - xy(1) sx = 0 sy = 0 i=0 MessageBox x While (Screeny-sy &y) While (ScreenX - sx & x) Delay 10 Call Plugin.Window.Move(Hwnd(i),Cstr(sx),Cstr(sy)) sx = sx + x i=i+1 If i &UBound(Hwnd)-1 Then ExitScript End If Wend sy = sy + y sx=0 MessageBox sy Wend 写一个子程序,可以使鼠标从当前的坐标逐点的移动到目的坐标(带轨迹的鼠标移动),请写出 代码 Do Call a(50, 50) Call a(800, 600) Loop sub a(x,y) Do GetCursorPos x0, y0 If x & x0 Then i=1 ElseIf x & x0 Then i = -1 ElseIf x = x0 Then i=0 End If If y & y0 then ii = 1 ElseIf y & y0 then ii = -1 ElseIf y = y0 then ii = 0 End If MoveR i, ii If x = x0 and y = y0 Then Exit do End If Loop End sub11、 随机生成一个 1~100 之间的整数,玩家可以通过 inputbox 输入数字,猜对则退出游戏,猜错 则提示答案的范围(猜数游戏),请 写出代码 例如: 随机数为:60,用户输入 20,程序提示&答案范围为:20~100&. 用户再次输入 75,程序提示&答案范围为:20~75&. 用户再次输入 60,程序提示&猜中&,然后退出程序.Randomize 答案 = int(Rnd * 100) + 1 最小数 = 1 最大数 = 100 数字 = InputBox(&(猜数游戏),输入 1~100 之间的整数,玩家可以通过输入数字,猜对则退出游 戏,猜错则提示答案的范围&) 数字=int(数字) Do If 数字 = 答案 Then MsgBox 数字& &,恭喜答对了& EndScript ElseIf 数字&答案 Then 最大数 = 数字 ElseIf 数字&答案 Then 最小数 = 数字 End If 数字 = InputBox(&答案范围为:& &最小数& &~& &最大数) 数字 = int(数字) Loop13、 锁定鼠标位置在(200,300)到(500,600)之间,超出范围则回到边界(鼠标范围锁定),请写出代 码 Call 锁范围(200,300,500,600) Function 锁范围(x1,y1,x2,y2) Do GetCursorPos x, y If x & x1 or x & x2 or y & y1 or y & y2 Then If x & x1 Then x = x1 ElseIf x & x2 Then x=x2 End If If y & y1 Then y = y1 ElseIf y & y2 Then y=y2 End If MoveTo x, y End If Loop End Function 15、获取数组 array(10,9,1,5,2,3,4,5,6,11)中最接近平均数的值,请写出代码 a = array(10, 9, 1, 5, 2, 3, 4, 5, 6, 11) i=0 For UBound(a) + 1 ii = ii + a(i) i=i+1 Next 均值 = ii /( UBound(a) + 1) i=0 For UBound(a) If Abs(均值 - a(i)) & Abs(均值 - a(i + 1)) Then ii = a(i + 1) ElseIf Abs(均值 - a(i)) & Abs(均值 - a(i + 1)) Then ii = a(i) End If i=i+1 Next MsgBox ii16、有一个字符串,里面包含一些数字,写一个函数,把这些数字加起来。比如“我 30 你 40 他 50”结果就是 120。请写出代码 a = &我 30 你 40 他 50ni& For i = 1 To Len(a) + 1 If IsNumeric(Mid(a, i, 1)) = True Then ii = ii & Mid(a, i, 1) Else b = b + ii ii = 0 End If Next Msgbox b17、 遍历字符串&A1a2d5m8Qz&,取出所有小写字母及数字,并按照与原来相反的顺序拼接成新 的字符串,请写出代码 MsgBox 反提取小写数字(&A1a2d5m8Qz&) Function 反提取小写数字(字符) i = Len(字符) For Len(字符) If (Asc(mid(字符,i,1)) & 96 and Asc(mid(字符,i,1)) & 123 ) or (Asc(mid(字符,i,1)) & 47 and Asc(mid(字符,i,1)) & 58 ) Then 反提取小写数字 = 反提取小写数字& mid(字符, i, 1) End If i=i-1 Next End Function//4、写一个函数,可以让普通窗口(例如记事本)在屏幕内移动,碰到屏幕边缘随机反向移动(类 似屏幕保护的汽泡程序),请写出 Function moveWin(Hwnd) Dim ary, h, w, maxh, maxw, fa, fb ScreenW = Plugin.GetSysInfo.GetScreenResolutionX() ScreenH = Plugin.GetSysInfo.GetScreenResolutionY() sRect = Plugin.Window.GetWindowRect(Hwnd) ary = Split(sRect, &|&) W1 = Clng(ary(0)): H1 = Clng(ary(1)) W2 = Clng(ary(2)) : H2 = Clng(ary(3)) w = W2 - W1 : h = H2 - H1 fa = true : fa = true Call Plugin.Window.Active(Hwnd) Call Plugin.Window.Show(Hwnd) Do Randomize If fa Then W1 = Round(Rnd * 5) + W1 Else W1 = W1 - Round(Rnd * 5) End If If fb Then H1 = Round(Rnd * 5) + H1 Else H1 = H1 - Round(Rnd * 5) End If maxw = w + W1 : maxh = h + H1 If W1 &= 0 Then W1 = 0 fa = true End If If H1 &= 0 Then H1 = 0 fb = true End If If maxw &= ScreenW Then W1 = ScreenW - w fa = false End If If maxh &= ScreenH Then H1 = ScreenH - h fb = false End If Call Plugin.Window.Move(Hwnd, W1, H1) Delay 10 Loop End Function //Call RunApp(&notepad.exe&) //Delay 1000 //Hwnd = Plugin.Window.Find(&Notepad&, 0) //If Hwnd & 0 Then // moveWin(Hwnd) //Else // MessageBox &记事本未找到!& //End If'写一个子程序,可以使鼠标从当前的坐标逐点的移动到目的坐标(带轨迹的鼠标移动),请写出 代码 Sub moveMou(x, y) Dim fa, fb, xx, yy, maxl GetCursorPos x0, y0 xx = Abs(x0 - x) yy = Abs(y0 - y) If xx & yy Then maxl = xx Else maxl = yy End If MessageBox maxl If x0 & x Then fa = 1 Else fa = - 1 End If If y0 & y Then fb = 1 Else fb = - 1 End If For maxl If x0 x0 = x0 + fa y0 = y0 + fb MoveTo x0, y0 Delay 10 Next End Sub Call moveMou() //////(API)利用 SetWindowPos 函数将窗口置前,相关说明请百度,请写出代码 Private Declare Function SetWindowPos Lib &user32& Alias &SetWindowPos& (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Function 窗口层次(hwnd, mode) 窗口层次 = SetWindowPos(hwnd, mode, 0, 0, 0, 0, 3) End Functionhwnd = 661156 Call Lib.API.窗口层次(hwnd, -1) 4、 利用 ShowScrTXT 命令制作一个放大镜,效果类似抓抓工具的放大镜,可以放大显示鼠标指 向的 5*5 区域的颜色.请写出代码 While true GetCursorPos x, y se = GetPixelColor(x + l, y + s) Call Plugin.Msg.ShowScrTXT(x + l * 15 + 15, y + s * 15 + 15, x + 170, y + 170, &■&, se) If l = 4 Then l=0 s=s+1 Else l=l +1 End If If s = 5 Then s=0 Delay 500 Call Plugin.Msg.HideScrTXT() Delay 100 End If Wend 5、获取鼠标无动作的时间,返回值是鼠标无动作的时间(鼠标监控),请写出代码 1、 同种窗口多开,操作一个窗口(键盘和鼠标)能够同时操作其他同种窗口,且操作过程一致(模 拟同步器),请写出代码 5、(API)利用 SendMessage 函数向 QQ 对话窗口发送文本里的所有内容(QQ 消息发送器),请 写出代码RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& HwndEx = Plugin.Window.Search(&记事本&) hw_sp = Split(HwndEx, &|&) hw_ub = UBound(hw_sp) TracePrint hw_ub x=0 y=0 i=0 m=1 For hw_ub hw_ck = hw_sp(i) call ckcz i=i+1:m=m+1 Delay 100 Next Sub ckcz If m = 1 or m = 2 Then Call Plugin.Window.Active(hw_ck) Call Plugin.Window.Move(Hwnd, x, y) x = x + 600 If m = 2 Then x=0 End If ElseIf m = 3 or m = 4 Then Call Plugin.Window.Active(hw_ck) y = y + 600 Call Plugin.Window.Move(Hwnd, x, y) x = x + 600:y=0 End If End Sub 在路径为: C:\ajjl.txt 文本的每行内容后加上对应的行数,例如:ajjl-第 1 行.请写出代码 nr = Plugin.File.ReadFileEx(&c:\ajjl.txt&) hs = Split(nr, &|&) i = 0:ii = 1 fileLen = Plugin.File.GetFileLength(&c:\ajjl.txt&) handle = Plugin.File.OpenFile(&c:\ajjl.txt&) Call Plugin.File.SeekFile(handle, 0) For UBound(hs) Call Plugin.File.WriteFile(handle,hs(i)&&-第&&ii&&行&& vbcrlf) i = i + 1:ii = ii + 1 Next Call Plugin.File.CloseFile(handle) Delay 500 RunApp &c:\ajjl.txt& EndScript 请提供至少两种判断程序卡死(无响应)的思路,请写出关键代码.请写出代码 Private Declare Function IsHungAppWindow Lib &user32.dll& ( ByVal hWnd As Long) As Long Sub 子程序() Hwnd = Plugin.Window.MousePoint() If IsHungAppWindow(Hwnd)=0 Then MsgBox &窗口正常& End If End SubPrivate Declare Function IsHungAppWindow Lib &user32.dll& ( ByVal hWnd As Long) As Long Hwnd = Plugin.Window.MousePoint() If IsHungAppWindow(Hwnd)=0 Then MsgBox &窗口正常& End If根据系统时间生成一个 0~1 之间的小数点数字,需要写出生成的过程(伪随机数),请写出代码 MsgBox 伪随机() Function 伪随机() 时间 = Split(Time, &:&) Randomize 时 = Int(int(时间(0)) * Rnd + 1) / 24 * 100 Randomize 分 = Int(int(时间(1)) * Rnd + 1) / 60 * 10000 Randomize 秒 = Int(int(时间(2)) * Rnd + 1) / 60 * 1000000 伪随机 = round((时 + 分 + 秒) / 100, 6) End Function1、鼠标按圆型移动,半径为 r=100,圆点为(200,200),请写出代码. Dim a, x, y MoveTo 100, 200 For a = 0 To 360 x = 200 - 100 * cos(a*3.14/180) y = 200 - 100 * sin(a*3.14/180) MoveTo x, y Delay 5 Next EndScript 1、(前台)区域范围为(100,150)到(200,300)内的所有点是否均为&FFFFFF&,是则弹出对话框&没 有其他颜色&,否则弹出第一个点的颜色值并退出程序. 请写出代码 x = 100 y = 150 RtColor = Plugin.Color.GetPixelColor(x, y, 0) RtColor1 = RtColor While (y & 300) x=100 While (x & 200) If RtColor = &FFFFFF& Then x=x+1 Else MessageBox RtColor1 ExitScript End If RtColor = Plugin.Color.GetPixelColor(x, y, 0) Wend y=y+1 Wend MessageBox &没有其他颜色& 2、利用多线程对多个记事本的窗口位置进行随机移动.请写出代码 RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& Delay 2000 DimEnv Hwnd1 HwndEx = Plugin.Window.Search(&记事本&) Hwnd = Split(HwndEx,&|&) If UBound(Hwnd) &= 0 Then For i = 0 To UBound(Hwnd) - 1 wnd = Clng(Hwnd(i)) Hwnd1 = wnd BeginThread 移动 Delay 100 Next End If Do Delay 1000 Loop Sub 移动 Hwnd2 = Hwnd1 Randomize x = Int(Rnd * 500) Randomize y = Int(Rnd*500) MessageBox x&&,&&y Call Plugin.Window.Move(Hwnd2, x+ 100, y + 100) End Sub 3、筛选出 100 以内所有个位数加十位数等于 10 的数,例如 82,8+2=10 满足条件,请写出代码 s=&& For i = 1 To 99 a = i mod 10 b = int(i / 10) If (a + b) = 10 Then s=s&i&&|& End If Next MessageBox s 4、写一个算法可以将十进制的字符串转成八进制的字符串.例如&8&-&&10&,请写出代码 Public Function DEC_to_OCT(Dec) DEC_to_OCT = && Do While Dec & 0 DEC_to_OCT = Dec Mod 8 & DEC_to_OCT Dec = Dec \ 8 Loop End Function a=DEC_to_OCT(&8&) MessageBox a 5、有 N 个窗口,第一个窗口移动到(0,0)点,其余的窗口根据第一个窗口平铺,窗口不超出屏幕 边缘(窗口平铺),请写出代码 RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& HwndEx = Plugin.Window.Search(&记事本&) Hwnd = Split(HwndEx, &|&) ScreenX = Plugin.Sys.GetScRX() ScreenY = Plugin.Sys.GetScRY() MessageBox ScreenX sRect = Plugin.Window.GetWindowRect(Hwnd(0)) MessageBox sRect xy = Split(sRect, &|&) x = xy(2) - xy(0) y = xy(3) - xy(1) sx = 0 sy = 0 i=0 MessageBox x While (Screeny-sy &y) While (ScreenX - sx & x) Delay 10 Call Plugin.Window.Move(Hwnd(i),Cstr(sx),Cstr(sy)) sx = sx + x i=i+1 If i &UBound(Hwnd)-1 Then ExitScript End If Wend sy = sy + y sx=0 MessageBox sy Wend 写一个子程序,可以使鼠标从当前的坐标逐点的移动到目的坐标(带轨迹的鼠标移动),请写出 代码 Do Call a(50, 50) Call a(800, 600) Loop sub a(x,y) Do GetCursorPos x0, y0 If x & x0 Then i=1 ElseIf x & x0 Then i = -1 ElseIf x = x0 Then i=0 End If If y & y0 then ii = 1 ElseIf y & y0 then ii = -1 ElseIf y = y0 then ii = 0 End If MoveR i, ii If x = x0 and y = y0 Then Exit do End If Loop End sub11、 随机生成一个 1~100 之间的整数,玩家可以通过 inputbox 输入数字,猜对则退出游戏,猜错 则提示答案的范围(猜数游戏),请 写出代码 例如: 随机数为:60,用户输入 20,程序提示&答案范围为:20~100&. 用户再次输入 75,程序提示&答案范围为:20~75&. 用户再次输入 60,程序提示&猜中&,然后退出程序.Randomize 答案 = int(Rnd * 100) + 1 最小数 = 1 最大数 = 100 数字 = InputBox(&(猜数游戏),输入 1~100 之间的整数,玩家可以通过输入数字,猜对则退出游 戏,猜错则提示答案的范围&) 数字=int(数字) Do If 数字 = 答案 Then MsgBox 数字& &,恭喜答对了& EndScript ElseIf 数字&答案 Then 最大数 = 数字 ElseIf 数字&答案 Then 最小数 = 数字 End If 数字 = InputBox(&答案范围为:& &最小数& &~& &最大数) 数字 = int(数字) Loop13、 锁定鼠标位置在(200,300)到(500,600)之间,超出范围则回到边界(鼠标范围锁定),请写出代 码 Call 锁范围(200,300,500,600) Function 锁范围(x1,y1,x2,y2) Do GetCursorPos x, y If x & x1 or x & x2 or y & y1 or y & y2 Then If x & x1 Then x = x1 ElseIf x & x2 Then x=x2 End If If y & y1 Then y = y1 ElseIf y & y2 Then y=y2 End If MoveTo x, y End If Loop End Function 15、获取数组 array(10,9,1,5,2,3,4,5,6,11)中最接近平均数的值,请写出代码 a = array(10, 9, 1, 5, 2, 3, 4, 5, 6, 11) i=0 For UBound(a) + 1 ii = ii + a(i) i=i+1 Next 均值 = ii /( UBound(a) + 1) i=0 For UBound(a) If Abs(均值 - a(i)) & Abs(均值 - a(i + 1)) Then ii = a(i + 1) ElseIf Abs(均值 - a(i)) & Abs(均值 - a(i + 1)) Then ii = a(i) End If i=i+1 Next MsgBox ii16、有一个字符串,里面包含一些数字,写一个函数,把这些数字加起来。比如“我 30 你 40 他 50”结果就是 120。请写出代码 a = &我 30 你 40 他 50ni& For i = 1 To Len(a) + 1 If IsNumeric(Mid(a, i, 1)) = True Then ii = ii & Mid(a, i, 1) Else b = b + ii ii = 0 End If Next Msgbox b17、 遍历字符串&A1a2d5m8Qz&,取出所有小写字母及数字,并按照与原来相反的顺序拼接成新 的字符串,请写出代码 MsgBox 反提取小写数字(&A1a2d5m8Qz&) Function 反提取小写数字(字符) i = Len(字符) For Len(字符) If (Asc(mid(字符,i,1)) & 96 and Asc(mid(字符,i,1)) & 123 ) or (Asc(mid(字符,i,1)) & 47 and Asc(mid(字符,i,1)) & 58 ) Then 反提取小写数字 = 反提取小写数字& mid(字符, i, 1) End If i=i-1 Next End Function//4、写一个函数,可以让普通窗口(例如记事本)在屏幕内移动,碰到屏幕边缘随机反向移动(类 似屏幕保护的汽泡程序),请写出 Function moveWin(Hwnd) Dim ary, h, w, maxh, maxw, fa, fb ScreenW = Plugin.GetSysInfo.GetScreenResolutionX() ScreenH = Plugin.GetSysInfo.GetScreenResolutionY() sRect = Plugin.Window.GetWindowRect(Hwnd) ary = Split(sRect, &|&) W1 = Clng(ary(0)): H1 = Clng(ary(1)) W2 = Clng(ary(2)) : H2 = Clng(ary(3)) w = W2 - W1 : h = H2 - H1 fa = true : fa = true Call Plugin.Window.Active(Hwnd) Call Plugin.Window.Show(Hwnd) Do Randomize If fa Then W1 = Round(Rnd * 5) + W1 Else W1 = W1 - Round(Rnd * 5) End If If fb Then H1 = Round(Rnd * 5) + H1 Else H1 = H1 - Round(Rnd * 5) End If maxw = w + W1 : maxh = h + H1 If W1 &= 0 Then W1 = 0 fa = true End If If H1 &= 0 Then H1 = 0 fb = true End If If maxw &= ScreenW Then W1 = ScreenW - w fa = false End If If maxh &= ScreenH Then H1 = ScreenH - h fb = false End If Call Plugin.Window.Move(Hwnd, W1, H1) Delay 10 Loop End Function //Call RunApp(&notepad.exe&) //Delay 1000 //Hwnd = Plugin.Window.Find(&Notepad&, 0) //If Hwnd & 0 Then // moveWin(Hwnd) //Else // MessageBox &记事本未找到!& //End If'写一个子程序,可以使鼠标从当前的坐标逐点的移动到目的坐标(带轨迹的鼠标移动),请写出 代码 Sub moveMou(x, y) Dim fa, fb, xx, yy, maxl GetCursorPos x0, y0 xx = Abs(x0 - x) yy = Abs(y0 - y) If xx & yy Then maxl = xx Else maxl = yy End If MessageBox maxl If x0 & x Then fa = 1 Else fa = - 1 End If If y0 & y Then fb = 1 Else fb = - 1 End If For maxl If x0 x0 = x0 + fa y0 = y0 + fb MoveTo x0, y0 Delay 10 Next End Sub Call moveMou() //////(API)利用 SetWindowPos 函数将窗口置前,相关说明请百度,请写出代码 Private Declare Function SetWindowPos Lib &user32& Alias &SetWindowPos& (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Function 窗口层次(hwnd, mode) 窗口层次 = SetWindowPos(hwnd, mode, 0, 0, 0, 0, 3) End Functionhwnd = 661156 Call Lib.API.窗口层次(hwnd, -1) 4、 利用 ShowScrTXT 命令制作一个放大镜,效果类似抓抓工具的放大镜,可以放大显示鼠标指 向的 5*5 区域的颜色.请写出代码 While true GetCursorPos x, y se = GetPixelColor(x + l, y + s) Call Plugin.Msg.ShowScrTXT(x + l * 15 + 15, y + s * 15 + 15, x + 170, y + 170, &■&, se) If l = 4 Then l=0 s=s+1 Else l=l +1 End If If s = 5 Then s=0 Delay 500 Call Plugin.Msg.HideScrTXT() Delay 100 End If Wend 5、获取鼠标无动作的时间,返回值是鼠标无动作的时间(鼠标监控),请写出代码 1、 同种窗口多开,操作一个窗口(键盘和鼠标)能够同时操作其他同种窗口,且操作过程一致(模 拟同步器),请写出代码 5、(API)利用 SendMessage 函数向 QQ 对话窗口发送文本里的所有内容(QQ 消息发送器),请 写出代码RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& RunApp &notepad.exe& HwndEx = Plugin.Window.Search(&记事本&) hw_sp = Split(HwndEx, &|&) hw_ub = UBound(hw_sp) TracePrint hw_ub x=0 y=0 i=0 m=1 For hw_ub hw_ck = hw_sp(i) call ckcz i=i+1:m=m+1 Delay 100 Next Sub ckcz If m = 1 or m = 2 Then Call Plugin.Window.Active(hw_ck) Call Plugin.Window.Move(Hwnd, x, y) x = x + 600 If m = 2 Then x=0 End If ElseIf m = 3 or m = 4 Then Call Plugin.Window.Active(hw_ck) y = y + 600 Call Plugin.Window.Move(Hwnd, x, y) x = x + 600:y=0 End If End Sub 在路径为: C:\ajjl.txt 文本的每行内容后加上对应的行数,例如:ajjl-第 1 行.请写出代码 nr = Plugin.File.ReadFileEx(&c:\ajjl.txt&) hs = Split(nr, &|&) i = 0:ii = 1 fileLen = Plugin.File.GetFileLength(&c:\ajjl.txt&) handle = Plugin.File.OpenFile(&c:\ajjl.txt&) Call Plugin.File.SeekFile(handle, 0) For UBound(hs) Call Plugin.File.WriteFile(handle,hs(i)&&-第&&ii&&行&& vbcrlf) i = i + 1:ii = ii + 1 Next Call Plugin.File.CloseFile(handle) Delay 500 RunApp &c:\ajjl.txt& EndScript 请提供至少两种判断程序卡死(无响应)的思路,请写出关键代码.请写出代码 Private Declare Function IsHungAppWindow Lib &user32.dll& ( ByVal hWnd As Long) As Long Sub 子程序() Hwnd = Plugin.Window.MousePoint() If IsHungAppWindow(Hwnd)=0 Then MsgBox &窗口正常& End If End SubPrivate Declare Function IsHungAppWindow Lib &user32.dll& ( ByVal hWnd As Long) As Long Hwnd = Plugin.Window.MousePoint() If IsHungAppWindow(Hwnd)=0 Then MsgBox &窗口正常& End If根据系统时间生成一个 0~1 之间的小数点数字,需要写出生成的过程(伪随机数),请写出代码 MsgBox 伪随机() Function 伪随机() 时间 = Split(Time, &:&) Randomize 时 = Int(int(时间(0)) * Rnd + 1) / 24 * 100 Randomize 分 = Int(int(时间(1)) * Rnd + 1) / 60 * 10000 Randomize 秒 = Int(int(时间(2)) * Rnd + 1) / 60 * 1000000 伪随机 = round((时 + 分 + 秒) / 100, 6) End Function//利用 ShowScrTXT 命令制作一个放大镜,效果类似抓抓工具的放大镜,可以放大显示鼠标指 向的 5*5 区域的颜色.请写出代码 //放大范围 5*5 While True Call FDJ() Delay 5 Wend //放大镜函数 Function FDJ() //放大镜的起点坐标 st_x = 10 st_y = 10 //获取鼠标的坐标 GetCursorPos x, y //计算 5*5 区域范围 x1 = x - 2 x2 = x + 2 y1 = y - 2 y2 = y + 2 //获取并输出 5*5 区域内所有颜色 For a = x1 To x2 For b = y1 To y2 RtColor = Plugin.Color.GetPixelColor(a, b, 1) //其中:4 - x2 + a = 5 - (x2 - a + 1),以下同理 scr_x1 = st_x + (14 - x2 + a) * 16 scr_y1 = st_y + (14 - y2 + b) * 16 scr_x2 = scr_x1 + 16 scr_y2 = scr_y1 + 16 Call Plugin.Msg.ShowScrTXT(scr_x1, scr_y1, scr_x2, scr_y2, &&, RtColor) Next Next End Function//、(API)利用 SendMessage 函数向 QQ 对话窗口发送文本里的所有内容(QQ 消息发送器),请 写出代码 //举例:a=发送 qq 消息(&漂亮妹子&,&d:\123.txt&) //说明:QQ 发送消息方式需设置为按“enter”发送消息 Private Declare Function SendMessage Lib &user32& Alias &SendMessageA& (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As string) As Long function 发送 qq 消息(qq 名称,文件路径) Hwnd = Plugin.Window.Find(&TXGuiFoundation&, qq 名称) If Hwnd = 0 Then MessageBox &未找到该用户:& & qq 名称 Exit Function End If Text = Plugin.File.ReadFileEx(文件路径) //Call Plugin.Window.SendString(Hwnd, text) Call Plugin.Sys.SetCLB(Text) SendMessage hwnd, &H302, 0, 0 Call Plugin.Window.SendKeyPress(Hwnd, 13) End Function//写一个子程序,可以使鼠标从当前的坐标逐点的移动到目的坐标(带轨迹的鼠标移动),请写 出代码 Sub 鼠标从当前位置匀速移动到目标(x2,y2) GetCursorPos x1, y1 For i=1 to 50 dx = (x2 - x1) / 50 dy = (y2 - y1) / 50 MoveTo int(x1 + i * dx), int(y1 + i * dy) Delay 10 Next End Sub写一个函数,要求:使用单点找色功能写出多点找色效果。 提示:多点找色命令:FindMutiColorExFunction FindMutiColorEx(x1, y1, x2, y2, 颜色) FindMutiColorEx = && If instr(颜色, &|&) & 0 Then FindColor x1, y1, x2, y2,颜色,intX,intY If intX & 0 And intY & 0 Then FindMutiColorEx=颜色&&,&&intX&&,&&intY Else FindMutiColorEx = 0 End If Exit Function End if ss = split(颜色,&|&) index = 0 count = UBound(ss) + 1 Do While index & count FindColor x1, y1, x2, y2, ss(index), intX, intY If intX & 0 And intY & 0 Then FindMutiColorEx = FindMutiColorEx &ss(index) & &,& & intX & &,& & intY & &|& End if index=index+1 Loop If right(FindMutiColorEx, 1) = &|& Then FindMutiColorEx=left(FindMutiColorEx,len(FindMutiColorEx)-1) End If End Function //编写一个脚本,对至少三个以上记事本窗口做相同操作,对任意一个窗口进行手动操作, 其余窗口由脚本执行相同步骤的键鼠操作,记得是键盘操作+鼠标操作,要求不使用多线程 实现该效果。num=3//设置记事本数量为 3,可更改 For num RunApp &notepad.exe& next Delay 2000//启动 3 个记事本测试用 //等待 3 个记事本工具打开HwndEx = Plugin.Window.Search(&记事本&) hwnd = Split(HwndEx, &|&) // // If UBound(Hwnd) &= 0 Then //判断是否搜到句柄? For i = 0 To UBound(hwnd) - 1 Call Plugin.Window.Move(Hwnd(i), 0, 0) Hwnd(i) = Plugin.Window.FindEx(Hwnd(i), 0, &Edit&, 0) Next End If //循环判断键盘鼠标操作 do anjian = GetLastKey() If anjian && 0 Then For i = 0 To num - 1 call mykeypress(hwnd(i),anjian) Next End if Mouse = GetLastClick() If Mouse&& 0 Then For i = 0 To num - 1 If Mouse = 32770 Or Mouse = 32769 Then GetCursorPos x, y Call Plugin.Bkgnd.leftClick(Hwnd(i), x-8, y-51)//相对前台坐标 End If If Mouse = 32774 Or Mouse = 32773 Then GetCursorPos x, y Call Plugin.Bkgnd.RightClick(Hwnd(i), x-8, y-51)//相对前台坐标 End If Next End if Loop sub mykeypress(hwnd, text)//作用是检测当前窗口,不重复输入 Hwndnote = Plugin.Window.MousePoint() If hwnd = Hwndnote Then Exit sub End If Call Plugin.Bkgnd.KeyPress(Hwnd,text) End Sub

我要回帖

更多关于 按键精灵无限循环 的文章

 

随机推荐