WinForm天貓雙11自動搶紅包源碼分享
本文實例為大家分享了搶紅包源碼,供大家參考,具體內容如下
1. 正確獲取紅包流程
2. 軟件介紹
2.1 效果圖:
2.2 功能介紹
2.2.1 賬號登錄
頁面開始時,會載入這個網站:https://login.taobao.com/member/login.jhtml?redirect_url=http%3A%2F%2F1111.tmall.com%2F
登錄成功后,會自動跳轉到1111.tmall.com活動頁面。
2.2.2 【去抽獎】按鈕
這按鈕是手動跳轉到1111.tmall.com頁面
2.2.3 【開始狂歡】按鈕
隱藏活動界面的載入Div
2.2.4 【親品牌】按鈕
調用Js,觸發(fā)點擊"親品牌,贏紅包"
2.2.5 【開始游戲】按鈕
①在這之前,會顯示"游戲攻略"界面,需要手動點擊"不再提示"和"開始游戲"
②然后點擊【開始游戲】按鈕,會模擬鼠標點擊和"再來一次"。
3. 主要代碼
備注:wbTmall 為System.Windows.Forms.WebBrowser 控件。
3.1 操作js代碼
WbTmall.Navigate(GameStart_js);
3.2 關閉Js錯誤提示
3.3 模擬鼠標點擊(google搜索到的)
①首先調用外部API
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll", SetLastError = true)] static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd); [DllImport("user32.dll", CharSet = CharSet.Auto)] static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
②模擬鼠標點擊
int x = 100; // X coordinate of the click int y = 100; // Y coordinate of the click IntPtr handle = WbTmall.Handle; StringBuilder className = new StringBuilder(100); while (className.ToString() != "Internet Explorer_Server") // The class control for the browser { handle = GetWindow(handle, 5); // Get a handle to the child window GetClassName(handle, className, className.Capacity); } IntPtr lParam = (IntPtr)((y << 16) | x); // The coordinates IntPtr wParam = IntPtr.Zero; // Additional parameters for the click (e.g. Ctrl) const uint downCode = 0x201; // Left click down code const uint upCode = 0x202; // Left click up code SendMessage(handle, downCode, wParam, lParam); // Mouse button down SendMessage(handle, upCode, wParam, lParam); // Mouse button up
4. 備注
4.1 開發(fā)環(huán)境
系統(tǒng):Win8.1
VS版本:VS2010
.Net版本:4.0
4.2 未解決地方
①進行操作時,內存占用會達到100M左右。
②并且在運行2小時后,有明顯的卡頓現象。
③CPU占用達到8%左右。
不知是代碼的原因,還是抽獎頁面是HTML5的canvas原因。
④抽中紅包的話,會卡在"抽中紅包"界面,點下"查看金額"就好了(抱歉,因為沒做抽中紅包的判斷),然后再點下【親品牌】按鈕就又可以玩了。。
5. 下載地址:http://xiazai.jb51.net/201610/yuanma/winformchoujiang(jb51.net).rar
6.后記
抱歉各位,11月8號這個活動結束了,軟件不能用了。之前沒注意到活動結束日期。
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
利用微軟com組件mstscax.dll實現window7遠程桌面功能
利用微軟提供的com組件mstscax.dll實現類似window遠程桌面功能,大家參考使用吧2013-12-12C# 串口接收數據中serialPort.close()死鎖的實例
下面小編就為大家分享一篇C# 串口接收數據中serialPort.close()死鎖的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2017-11-11