本文實例為大家分享了搶紅包源碼,供大家參考,具體內容如下
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,觸發點擊"親品牌,贏紅包"
2.2.5 【開始游戲】按鈕
①在這之前,會顯示"游戲攻略"界面,需要手動點擊"不再提示"和"開始游戲"
②然后點擊【開始游戲】按鈕,會模擬鼠標點擊和"再來一次"。
3. 主要代碼
備注:wbTmall 為System.Windows.Forms.WebBrowser 控件。
3.1 操作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 clickint y = 100; // Y coordinate of the clickIntPtr 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 coordinatesIntPtr wParam = IntPtr.Zero; // Additional parameters for the click (e.g. Ctrl)const uint downCode = 0x201; // Left click down codeconst uint upCode = 0x202; // Left click up codeSendMessage(handle, downCode, wParam, lParam); // Mouse button downSendMessage(handle, upCode, wParam, lParam); // Mouse button up
4. 備注
4.1 開發環境
系統:Win8.1
VS版本:VS2010
.Net版本:4.0
4.2 未解決地方
①進行操作時,內存占用會達到100M左右。
②并且在運行2小時后,有明顯的卡頓現象。
③CPU占用達到8%左右。
不知是代碼的原因,還是抽獎頁面是HTML5的canvas原因。
④抽中紅包的話,會卡在"抽中紅包"界面,點下"查看金額"就好了(抱歉,因為沒做抽中紅包的判斷),然后再點下【親品牌】按鈕就又可以玩了。。
5. 下載地址:http://xiazai.VeVB.COm/201610/yuanma/winformchoujiang(VeVB.COm).rar
6.后記
抱歉各位,11月8號這個活動結束了,軟件不能用了。之前沒注意到活動結束日期。
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。
新聞熱點
疑難解答