码迷,mamicode.com
首页 > Web开发 > 详细

QuickMacroForNetEase

时间:2020-07-06 00:58:11      阅读:80      评论:0      收藏:0      [点我收藏+]

标签:设置   控制   nap   了解   UNC   roc   back   message   连接   

按键精灵的语法和逻辑相对来说属于比较简单那种.
在使用过程当中完全可以根据需要,现学现用.
不过一些API在使用的过程当中还是需要有一定的了解之后, 才能在需要的时候立马能够想到.

在手机操这方面, 按键精灵的Q小语言相对来说比较方便.
不管是获取屏幕还是在使用的过程当中,有一些非常好用的借口提供. 如果采用编程语言, 需要提前部署好相当多的包和环境.

在使用过程当中, 需要搭配按键精灵手机助手, 和模拟器.
同时在模拟器中安装按键精灵手机版. 这时候通过PC上的按键精灵手机助手, 可以连接虚拟机. 实现对界面的控制.

在使用脚本的过程当中需要开启安卓的ROOT权限, 不管是获取屏幕还是运行脚本都需要权限.

SetScreenScale 1920,1080,0

// 内容
Dim SayHello
SayHello = "Content"

// 总次数
Dim SayHeyTimes
SayHeyTimes = 20

// 计数器
Dim Counter
Counter = 0




// 启动程序
Function initApp
    KillApp "com.netease.cloudmusic"
    ShowMessage "重启应用"
    Delay 1000
    RunApp "com.netease.cloudmusic"
    Delay 4000
End Function

// 寻找左上角菜单
Function FindSetButton(startButton)
    Dim intX,intY
    FindMultiColor 0,0,0,0,"333333","0|10|333333,0|21|333333,28|21|333333,28|11|3F3F3F,28|0|333333,15|2|FFFFFF,11|9|CDCDCD,10|20|666666",0,0.9,intX,intY
    If intX > -1 And intY > -1 Then
        TracePrint intX
        TracePrint intY
        startButton = Array(intX,intY)
        FindSetButton=startButton
    End If
	
End Function
// 寻找设置按钮
Function FindSet(setSignal)
    Dim intX,intY
    FindMultiColor 0,0,0,0,"4D4D4D","9|2|4E4E4E,17|1|4D4D4D,26|1|4D4D4D,14|15|4D4D4D,13|-14|828282,13|-4|6B6B6B,13|2|FFFFFF,50|-8|343434",0,0.9,intX,intY
    If intX > -1 And intY > -1 Then
        TracePrint intX
        TracePrint intY
		
        setSignal = Array(intX,intY)
        FindSet=setSignal
    End If
End Function

// 寻找按钮
Function findNearlyButton(nearlyButton)
    Dim intX,intY
    FindMultiColor 0,0,0,0,"4F4F4F","0|8|515151,0|22|4D4D4D,-11|2|717171,-3|2|505050,1|4|FFFFFF,4|3|585858,11|2|6A6A6A,38|-1|333333",0,0.9,intX,intY
    If intX > -1 And intY > -1 Then
        TracePrint intX
        TracePrint intY
        nearlyButton = Array(intX,intY)
        findNearlyButton=nearlyButton
    End If

End Function

// 人标识
Function findNearlySignal(nearlySignal)
    Dim intX,intY
    FindMultiColor 0,0,0,0,"747474","-10|13|F9F9F9,-11|18|DDDDDD,-17|15|404040,0|31|6A6A6A,16|16|565656,-11|16|464646,45|4|333333,45|29|454545",0,0.9,intX,intY
    If intX > -1 And intY > -1 Then
        TracePrint intX
        TracePrint intY
        nearlySignal = Array(intX,intY)
        findNearlySignal=nearlySignal
    End If
End Function

// 性别标志
Function findFemale(femaleSignal)
    Dim intX,intY
    FindMultiColor 0,0,0,0,"B685FF","16|-16|B685FF,-1|-5|B685FF,6|0|DFCAFF,16|-6|B685FF,5|-16|B685FF,7|-6|CFAEFF,15|-15|D5B9FF,-2|2|FFFFFF,14|-15|FEFDFF",0,0.9,intX,intY
    If intX > -1 And intY > -1 Then
        TracePrint intX
        TracePrint intY
        femaleSignal = Array(intX,intY)
        findFemale=femaleSignal
    End If

End Function

// 通过关注标志找按钮
Function findFollowButton(followButton)
    Dim intX,intY
    FindMultiColor 0,0,0,0,"3A3AFF","129|0|3A3AFF,21|-24|3A3AFF,109|-25|3A3AFF,19|25|3A3AFF,109|25|3A3AFF,36|0|FFFFFF,50|0|FFFFFF,43|-7|FFFFFF,43|7|FFFFFF",4,0.9,intX,intY
    If intX > -1 And intY > -1 Then
        TracePrint intX
        TracePrint intY
        intX = intX + 200
        followButton = Array(intX,intY)
        findFollowButton=followButton
    End If
End Function

// 返回上个界面
Function backPrePage()
    Tap 70,88
End Function

// 点击 编辑内容
Function clickContentButton()
    Tap 100,1050
End Function

// 点击 发送内容
Function clickSendContentButton()
    Tap 1870,1035
End Function

// 判断是否有发送过信息

Function findSendMessage(sendMessageContent)
	
    Dim intX,intY
    FindMultiColor 0,0,0,0,"3A3AFF","73|0|4343FF,11|20|3A3AFF,-31|0|4343FF,-8|45|E6E6E6,-104|129|4452FC,70|126|4452FC,52|125|FFFFFF,34|190|4452FC,-138|154|4452FC",4,0.9,intX,intY
    If intX > -1 And intY > -1 Then
        TracePrint intX
        TracePrint intY
        sendMessageContent = Array(intX,intY)
        findSendMessage=sendMessageContent
    End If
End Function



// 上滑400
Function swipDown
    Swipe 1000, 600, 1000, 200
End Function

// 开始应用程序
Function start
    Dim startButton
    Dim i
    i = 0
    While i <= 5 and IsNull(startButton)
        startButton = FindSetButton(startButton)
    	
        If not IsNull(startButton) Then 
            TracePrint startButton[1],startButton[2]
            Tap startButton[1],startButton[2]
            Exit While
        End If
        If i = 5 Then 
            Call initApp()
            i = 0
        End If
        i = i+1
        TracePrint "try", i
        Delay 1000
    	
    Wend
End Function


// 打开功能
Function nearlyPeople
	
    // 确定页面符合要求	
    Dim setSignal
    setSignal = FindSet(setSignal)
    
    If IsNull(setSignal) Then
        TracePrint "非功能页面"
        Call initApp()
        Call start()
    End If
	
    TracePrint "123"
    
    //  寻找功能按钮
    Dim i = 0
    Dim nearlyButton
    While i <= 5 and IsNull(nearlyButton)
        nearlyButton=findNearlyButton(nearlyButton)
        If not IsNull(nearlyButton) Then 
            TracePrint nearlyButton[1],nearlyButton[2]
            Tap nearlyButton[1], nearlyButton[2]
            ShowMessage "进入页面"
            Delay 2000
            Exit While
		
        End If
        call swipDown()
        Delay 1000
        i = i + 1
        TracePrint i
    Wend

End Function




// 筛选
Function filterPeople
    ShowMessage "确认页面"
    Dim nearlySignal
    nearlySignal = findNearlySignal(nearlySignal)
    If IsNull(nearlySignal) Then
        TracePrint "非功能页面"
        Call nearlyPeople()
    End if
    Delay 1000

    ShowMessage "开始筛选"
    Delay 1000
	
    Dim femaleSignal
    Dim i=0
    While i<5
		
        femaleSignal = findFemale(femaleSignal)
		
        If not IsNull(femaleSignal) Then 
            TracePrint femaleSignal
            Tap femaleSignal[1], femaleSignal[2]
            i =0
            Delay 1000
            Call sendMessage()
            
        	Delay 1000
            Call swipDown()
        	Delay 3000
    		
        End If
		
        // 向下滑		
        Call swipDown()
        Delay 1000
        i=i+1
    Wend
	
End Function

// 发送信息
// 1. 找到发送按钮, 找不到返回按键
// 2. 进入发送界面, 核对是否发送过信息
// 3. 如果发送过信息则直接返回, 没有发送过信息就发送信息后返回
// 4. 再次返回.

Function sendMessage
    i = 10
    While i <> 0
        i = i - 1
    Wend
    //当循环条件成立的时候,反复执行循环体

    Dim followButton
    Dim i=0
    While i < 3 and IsNull(followButton)
        followButton = findFollowButton(followButton)
        Delay 1000
        i = i + 1
        
    Wend
	
    If not IsNull(followButton) Then 
        Tap followButton[1], followButton[2]
        ShowMessage "发送信息"
        Call sendMessageProcess()
		
        Delay 1000
        
    End If
	
    Call backPrePage()
	
End Function



// 发送信息过程
Function sendMessageProcess()
    // 判断是否发送过信息
    Dim sendMessageContent
    Dim i
    i=0
    // 检测3次
    While i < 3 and IsNull(sendMessageContent)
        sendMessageContent = findSendMessage(sendMessageContent)
        i = i + 1
		
    Wend
    // 有内容则直接返回
    TracePrint sendMessageContent
    
    If IsNull(sendMessageContent) Then 
//        TracePrint "~无记录: 发送信息"
		Call sendingTheMessage()
        
        
    	Counter = Counter + 1
    	If Counter > SayHeyTimes Then 
    		ShowMessage "打招呼次数已经足够"
    		TracePrint "Enough, Ending The Script"
    		EndScript
    		
    	End If
    	
    	
    	
        
    End If
	
    // 无内容则发送信息
    If not IsNull(sendMessageContent) Then 
        TracePrint "!存在记录: 返回" 
    End If
    
    Delay 1000
    Call backPrePage()
    Delay 1000
	
End Function

Function sendingTheMessage()
    TracePrint "发送信息过程ing"
    Call clickContentButton()
	
    Delay 2000
    InputText SayHello
    Delay 2000
	
    Call clickSendContentButton()
    Delay 4000
	
	
End Function




// 主程序

//Call start()

//Call nearlyPeople()

Call filterPeople()
//Call sendMessage()


QuickMacroForNetEase

标签:设置   控制   nap   了解   UNC   roc   back   message   连接   

原文地址:https://www.cnblogs.com/jrri/p/13252565.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!