?? hl_ipdlg.cpp
字號:
// hl_ipDlg.cpp : implementation file
//
#include "stdafx.h"
#include <winsock2.h>
#include <ras.h>
#include "hl_ip.h"
#include "hl_ipDlg.h"
#include "xmlhttp.h"
#include "kb_data.h"
#include <Wininet.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
void SetKBEvent(BYTE vk_val, BOOL f_down)
{
for(int i=0; i<sizeof(g_kb_datas)/sizeof(KB_DATA); i++)
{
if(g_kb_datas[i].vk_val ==vk_val)
{
// 0x1D: control, 0x2A: shift
keybd_event(g_kb_datas[i].vk_val, g_kb_datas[i].scancode, f_down?KEYEVENTF_EXTENDEDKEY:KEYEVENTF_KEYUP, 0);
break;
}
}
}
void SetMouseDown(int x, int y)
{
SetCursorPos(x, y);
mouse_event(MOUSEEVENTF_LEFTDOWN/*|MOUSEEVENTF_ABSOLUTE*/, 0, 0, NULL, NULL);
mouse_event(MOUSEEVENTF_LEFTUP/*|MOUSEEVENTF_ABSOLUTE*/, 0, 0, NULL, NULL);
}
void SetMouseUp(int x, int y)
{
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHl_ipDlg dialog
CHl_ipDlg::CHl_ipDlg(CWnd* pParent /*=NULL*/)
: CDialog(CHl_ipDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CHl_ipDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CHl_ipDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CHl_ipDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CHl_ipDlg, CDialog)
//{{AFX_MSG_MAP(CHl_ipDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_TIMER()
ON_WM_CLOSE()
ON_MESSAGE(WM_APP+1, OnApp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHl_ipDlg message handlers
BOOL CHl_ipDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
NOTIFYICONDATA nid;
ZeroMemory((void*)(&nid), sizeof(nid));
nid.cbSize = sizeof(nid);
nid.hWnd = m_hWnd;
nid.uCallbackMessage = WM_APP+1;
nid.hIcon = m_hIcon;
nid.uID = 1;
strcpy(nid.szTip, "自動投票系統..");
nid.uFlags = NIF_ICON | NIF_TIP | (WM_APP+1);
Shell_NotifyIcon(NIM_ADD, &nid);
//SetTimer(10, 5000, NULL);
//OnTimer(10);
SetDlgItemText(IDE_TITLE, "調查:您是韓劇迷嗎 您怎樣看待“韓流熱”_影音娛樂_新浪網");
return TRUE; // return TRUE unless you set the focus to a control
}
void CHl_ipDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else if(nID ==SC_MINIMIZE)
{
ShowWindow(SW_HIDE);
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CHl_ipDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CHl_ipDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
int CHl_ipDlg::enumIP()
{
AutoDial();
return 0;
}
void CHl_ipDlg::OnTimer(UINT nIDEvent)
{
static int count =0;
// TODO: Add your message handler code here and/or call default
enumIP();
if((count++ % 100) == 99)
ShowWindow(SW_HIDE);
//CDialog::OnTimer(nIDEvent);
}
void CHl_ipDlg::OnClose()
{
if(MessageBox("退出?", "pudn.com", MB_DEFBUTTON2|MB_YESNO) ==IDNO)
return;
NOTIFYICONDATA nid;
ZeroMemory((void*)(&nid), sizeof(nid));
nid.cbSize = sizeof(nid);
nid.hWnd = m_hWnd;
nid.uID = 1;
Shell_NotifyIcon(NIM_DELETE, &nid);
KillTimer(10);
Sleep(10000);
CDialog::EndDialog(0);
//CDialog::OnClose();
}
void CHl_ipDlg::OnCancel()
{
static int f_stop =1;
f_stop =!f_stop;
if(f_stop)
{
SetDlgItemText(IDCANCEL, "開始");
KillTimer(10);
}
else
{
SetDlgItemText(IDCANCEL, "停止");
SetTimer(10, 5000, NULL);
}
}
LRESULT CHl_ipDlg::OnApp(WPARAM wParam, LPARAM lParam)
{
switch(lParam)
{
case WM_RBUTTONUP:
case WM_LBUTTONUP:
if(IsWindowVisible())
ShowWindow(SW_HIDE);
else
{
ShowWindow(SW_SHOWNORMAL);
SetForegroundWindow();
}
break;
}
return 0;
}
int CHl_ipDlg::AutoDial()
{
static HRASCONN hRasConn=NULL;
SetDlgItemText(IDC_IP, "Hangup and Dial...");
// 重新撥號
if(hRasConn)
{
RasHangUp(hRasConn);
hRasConn =NULL;
}
RASDIALPARAMS rdParams;
DWORD dwRet;
BOOL f_get_password;
memset(&rdParams, 0, sizeof(rdParams));
rdParams.dwSize=sizeof(RASDIALPARAMS);
strcpy(rdParams.szEntryName,"adsl");
if(RasGetEntryDialParams(NULL, &rdParams, &f_get_password) !=0)
{
SetDlgItemText(IDC_IP, "Dial Failed, get entry adsl failed!");
return -1;
}
if(f_get_password ==false)
{
SetDlgItemText(IDC_IP, "Dial Failed: get password failed!");
return -1;
}
if((dwRet=RasDial(NULL,NULL,&rdParams,0L, NULL, &hRasConn)) !=0)
{
SetDlgItemText(IDC_IP, "Dial Failed!");
return -1;
}
char tstr[40], temp[200];
wsprintf(temp, "Dial OK! %s", _strtime(tstr));
SetDlgItemText(IDC_IP, temp);
// 刪除cookie
//remove("Q:\\Documents and Settings\\Administrator.PUDN\\Cookies\\administrator@news.survey.sina.com[1].txt");
//remove("Q:\\Documents and Settings\\Administrator.PUDN\\Cookies\\administrator@sina.com[1].txt");
//remove("Q:\\Documents and Settings\\Administrator.PUDN\\Cookies\\administrator@38.adsina.allyes[2].txt");
DeleteUrlCacheEntry("Cookie:administrator@news.survey.sina.com.cn/");
// 刷新IE
char s_title[500];
GetDlgItemText(IDE_TITLE, s_title, sizeof(s_title));
HWND hWnd=::FindWindow("IEFrame", NULL);//"調查:您是韓劇迷嗎 您怎樣看待“韓流熱”_影音娛樂_新浪網 - --歡迎訪問 http://www.programsalon.com/");
if(hWnd)
{
char title[500];
HWND hWndNext;
int iii =0;
for(hWndNext =hWnd;hWndNext !=NULL;)
{
::GetWindowText(hWndNext, title, sizeof(title));
if(strncmp(title, s_title, strlen(s_title)) ==0)
break;
hWndNext =::GetWindow(hWndNext, GW_HWNDNEXT);
if(hWndNext ==hWnd)
{
hWndNext =NULL;
break;
}
}
if(hWndNext ==NULL)
return -1;
else
hWnd =hWndNext;
HWND hWndOldFG=::GetForegroundWindow();
::SetForegroundWindow(hWnd);
RECT rc;
POINT pt;
::GetWindowRect(hWnd, &rc);
GetCursorPos(&pt);
SetMouseDown(rc.left+15, rc.top+108);
Sleep(200);
::SetForegroundWindow(hWndOldFG);
SetCursorPos(pt.x, pt.y);
/*HWND hWnd2 =::FindWindow("#32770", "Microsoft Internet Explorer");
if(hWnd2)
::SendMessage(hWnd2, WM_COMMAND, 4, 0L);
SetKBEvent(VK_F5, TRUE);
Sleep(1000);
hWnd2 =::FindWindow("#32770", "Microsoft Internet Explorer");
if(hWnd2)
::SendMessage(hWnd2, WM_COMMAND, 4, 0L);
wsprintf(temp, "Send OK! HWND=0x%x, %s", hWnd, _strtime(tstr));
SetDlgItemText(IDC_IP, temp);*/
}
else
SetDlgItemText(IDC_IP, "沒有發現IE");
KillTimer(10);
SetTimer(10, 2000, NULL);
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -