--此腳本針對iPhone5/5s --目前只實現一個屏幕微信群好友的添加,如果想添加更多好友, --需要划屏操作,執行划屏操作時建議循環滑動 function main() --獲取屏幕的分辨率 w,h = getScreenResolution(); --輸出屏幕的長、寬 notifyMessage(string.format("%d,%d\n",w,h)); mSleep(500); -- 運行微信 appRun("com.tencent.xin"); --處理第一個點擊位置 local base_i = w*(1/16); local base_j = h*(128/1136); local add_i = w*(15/64); local index = 0; local bool = 1; for j = base_j,2000, h*(190/1136) do for i = base_i,w,add_i do --[[mSleep(500); r,g,b = getColorRGB(i+50,j+50);--取x,y位置色 mSleep(500); if r == 0xff and g == 0xff and b == 0xff then bool = 0; notifyMessage("結束條件找到"); mSleep(2000); else --notifyMessage("沒有找到結束條件"); --mSleep(2000); end; ]] mSleep(1000); touchDown(0,i+50,j+50); mSleep(50); touchUp(0); mSleep(1000); --實現全屏找圖,添加到通訊錄 image_x,image_y = findImage("var/mobile/Applications/add.bmp"); --mSleep(500); if image_x ~= -1 and image_y ~= -1 then --notifyMessage("找到圖"); --添加好有 touchDown(0,image_x+5,image_y+5); mSleep(50); touchUp(0); mSleep(500); touchDown(0,600,50); mSleep(50); touchUp(0); --時間間隔設置稍微長點,受網絡環境影響 mSleep(2000); --發送添加好友成功后返回,不用找圖或找色,直接單擊返回按鈕的點效率比較高 touchDown(0,20,80); mSleep(50); touchUp(0); --如果沒有找到添加通訊圖圖,則全屏查找發消息 else -- mSleep(1000); message_x,message_y = findImage("var/mobile/Applications/message.bmp"); mSleep(50); if message_x ~= -1 and message_y ~= -1 then --notifyMessage("找到圖"); mSleep(50); --notifyMessage("如果是消息直接返回"); --發送添加好友成功后返回 touchDown(0,20,80); mSleep(50); touchUp(0); --添加通訊錄和發消息都沒有找到則提示一下信息 else mSleep(500); notifyMessage("既沒有添加通訊錄也沒有發送消息"); end; end; --[[ --全屏模糊找色,尋找添加通訊錄按鈕 x,y = findColorFuzzy(0x00B92F,90); if x ~= -1 and y ~= -1 then touchDown(3,x,y); mSleep(500); touchUp(3); else notifyMessage("沒有找到"); mSleep(2000); end mSleep(2000); --添加好友驗證消息並尋找發送按鈕 send_x,send_y = findColorFuzzy(0x00B92F,85); if send_x ~= -1 and send_y ~= -1 then touchDown(4,send_x,send_y); mSleep(500); touchUp(4); end mSleep(2000); x_back,y_back = findColorInRegionFuzzy(0xffffff,95,20,60,80,200); if x_back ~= -1 and y_back ~= -1 then touchDown(2,x_back,y_back); mSleep(200); touchUp(2); --mSleep(100); end ]] mSleep(50); end base_j = base_j+h*(190/1136); mSleep(200); end -- end