附近的人打招呼V1.0

//微信附近的人打招呼的脚本

//开始按钮的响应事件
Event Form1.Button1.Click

T1 = BeginThread (senMsg())

End Event

//发送打招呼信息
Sub senMsg

	//读取文本框中要执行的人数
	personNumber = Form1.InputBox1.Text
//	MessageBox "人数是:" & personNumber
	
 	Delay 100
 	
 	MsgArray = ReadMsg(SelectMsgFile)
 	MsgNumber = UBound(MsgArray)
 	
// 	MessageBox "消息数是:" & MsgNumber
 	
 	For count = 1 To personNumber
 		selectPerson = getRnd(1, 4)
 		Call SlideScreenUp(selectPerson)
 		selectMyMsg = getRnd(0, MsgNumber)
// 		Msgbox "第 " & selectMyMsg & " 内容为:" & Cstr(MsgArray(selectMyMsg))
 		Call ClickItem (1)
 		Delay 1000
 		//打招呼
 		Call Plugin.Sys.SetCLB(Cstr(MsgArray(selectMyMsg)))
 		//判断是否找到“发消息按钮”
 		Delay 3000
 		isFind = ClickHi
 		If isFind > 0 Then 	
 			Delay 3000
 			Call Paste
 			Delay 1000
 			Call ClickSend
 			Delay 2000 
 		End If
 		//返回,返回到附近的人列表
 		Call ClickRetun
 		
 	Next
End Sub

//带返回值的函数,读取提示语文件路径
Function SelectMsgFile()
	SelectMsgFile = Plugin.File.SelectFile()
End Function

//读取提示语内容,返回提示语数组
Function ReadMsg(Path)
	Text = Plugin.File.ReadFileEx(path)   
//	Msgbox "向目标文件读出文本内容为:"& Text    
	ReadMsg  = Split(Text, "|")
End Function

//查看读取到的内容
//Sub LogMsg(array)
//	ArrayLength = UBound(array)
//	If ArrayLength>=0 Then   
//    	i=0   
//    For ArrayLength
//        Msgbox "第 " & i+1 &" 行文本内容为:"& Cstr(array(i))   
//        i=i+1   
//    Next
//	End If
//End Sub

//获取随机数
Function getRnd(from, toNumber)
	Randomize
	getRnd = Int(Rnd * (toNumber-from) + from )
End Function

//点击指定条目
Sub ClickItem(index)

	//每一条的高度
	Dim  ItemHeight
	ItemHeight = 67
	//第一条中心的Y坐标
	Dim  The1stY_coordinate
	The1stY_coordinate = 168
	//所显示列表条目中心的X坐标
	Dim  ItemX_coordinate
	ItemX_coordinate = 550
	
    y_coordinate  = (The1stY_coordinate + ItemHeight * (index - 1))
    MoveTo ItemX_coordinate, y_coordinate
//    MessageBox "ClickItem x= " & ItemX_coordinate & ", y = " & y_coordinate
    Delay 2110
    LeftDown 1
    Delay 20
    LeftClick 1
    Delay 3
    LeftUp 1
    Delay 3
End Sub

//向上滑动屏幕,向上滑动count条
Sub SlideScreenUp(count)

	//每一条的高度
	Dim  ItemHeight
	ItemHeight = 67
	//第一条中心的Y坐标
	Dim  The1stY_coordinate
	The1stY_coordinate = 168
	//所显示列表条目中心的X坐标
	Dim  ItemX_coordinate
	ItemX_coordinate = 550
	
    startY = The1stY_coordinate + ItemHeight * count
    MoveTo ItemX_coordinate, startY
    Delay 2110
    LeftDown 1
    Delay 20
    For c = 1 To count*13
        MoveTo ItemX_coordinate, startY - ItemHeight/13*c
        Delay 100
    Next
    MoveTo ItemX_coordinate, The1stY_coordinate-3
    Delay 100
    LeftUp 1
    Delay 20
End Sub

//鼠标左键单击
Sub MyLeftClick
	LeftDown 1
    Delay 2
    LeftClick 1
    Delay 1
    LeftUp 1
End Sub

//点击返回
Sub ClickRetun
    MoveTo 375, 111
    Delay 4547
    MyLeftClick
End Sub

//点击“打招呼”:打招呼按钮的位置不一定,因为有的有“更多”有的没有
Function ClickHi

Dim checked_x
Dim checked_Y

//这里点击窗口边缘很重要,为了更新屏幕显示,否则查不到对应颜色值
MoveTo 288, 73
Delay 1000
MyLeftClick 


FindCenterColor 450, 350, 451, 600, "1AC045", checked_x, checked_Y 
MoveTo checked_x, checked_Y

//MessageBox "rentun at " & checked_x & ", " & checked_Y
ClickHi = checked_Y
If checked_Y >0  Then 
		Delay 500
		MyLeftClick 
End If

End Function

//点击发送
Sub ClickSend
	MoveTo 815, 107
	Delay 3000
	
	MyLeftClick
	//如果点击了发送就不需要点击返回了,返回到详细信息页面
// 	Call ClickRetun
 	
End Sub

//粘贴内容
Sub Paste
	KeyDown "Ctrl", 1
	Delay 30
	KeyDown "V", 1
	Delay 200
	KeyUp "V", 1
	Delay 100
	KeyUp "Ctrl", 1
	Delay 30
End Sub

猜你喜欢

转载自blog.csdn.net/liu_zhen_wei/article/details/51200091