Just learn MFC in accordance with the instruction of the book wrote a program that can automatically refresh the web page
void CKeyBoardDlgDlg: : OnBtnStart () { //TODO: Add your the control notification handler code here Cstrings strBtn; Int nInterval=0; GetDlgItemText (IDC_EDIT_CAPTION m_StrCaption); NInterval=GetDlgItemInt (IDC_EDIT_INTERVAL, FALSE, TRUE); If (m_StrCaption=="" | | nInterval==0) { return; } M_Start. GetWindowText (strBtn); {if (strBtn=="start") SetTimer (1, nInterval * 10000, NULL); M_Start. SetWindowText (" stop "); GetDlgItem (IDC_EDIT_CAPTION) - & gt; The EnableWindow (FALSE); GetDlgItem (IDC_EDIT_INTERVAL) - & gt; The EnableWindow (FALSE); } The else { KillTimer (1); M_Start. SetWindowText (" start "); GetDlgItem (IDC_EDIT_CAPTION) - & gt; The EnableWindow (TRUE); GetDlgItem (IDC_EDIT_INTERVAL) - & gt; The EnableWindow (TRUE); } } Void CKeyBoardDlgDlg: : OnTimer (UINT nIDEvent) { HWND HWND=: : FindWindow (NULL, m_StrCaption GetBuffer (0)); : : PostMessage (hWnd, WM_KEYDOWN, VK_F5, 1); Sleep (50); : : PostMessage (hWnd, WM_KEYUP VK_F5, 1); CDialog: : OnTimer (nIDEvent); } But no response after the program is run, turn to...
CodePudding user response:
Wish someone would see...
CodePudding user response:
HWND
hWnd =: : FindWindow (NULL, m_StrCaption GetBuffer (0));
Debugging to see if the return value is empty
CodePudding user response:
First of all, the if (strBtn=="start") {
SetTimer (1, nInterval * 10000, NULL); There is a nInterval * 1000 not 10000 is 1000 milliseconds, a second is 10000 milliseconds for 10 seconds
CodePudding user response:
reference qq_29522823 reply: 3/f first if (strBtn=="start") { SetTimer (1, nInterval * 10000, NULL); There is a nInterval * 1000 not 10000 is 1000 milliseconds, a second 10000 milliseconds is 10 seconds And check the HWND HWND=: : FindWindow (NULL, m_StrCaption GetBuffer (0)); Handle for null and m_StrCaption. GetBuffer (0) and whether the browser title CodePudding user response:
Try using Keybd_event function CodePudding user response:
Less corresponding message map, CodePudding user response:
refer to 6th floor zhao4zhong1 response: less corresponding message map, Miss zhao is ubiquitous , I run this code, no problem, there is 10000 milliseconds timer time to 1000 and then m_StrCaption. GetBuffer (0) returns a handle to the content and the window title is consistent to obtain CodePudding user response:
Use keybd_event or SendInput CodePudding user response:
Post for the first time there are so many bosses to help, thank you teacher CodePudding user response:
Whether to open the keyboard editing features CodePudding user response:
refer to the original poster qq_39573785 response: just learn MFC in accordance with the instruction of the book wrote a program that can automatically refresh the web page void CKeyBoardDlgDlg: : OnBtnStart () { //TODO: Add your the control notification handler code here Cstrings strBtn; Int nInterval=0; GetDlgItemText (IDC_EDIT_CAPTION m_StrCaption); NInterval=GetDlgItemInt (IDC_EDIT_INTERVAL, FALSE, TRUE); If (m_StrCaption=="" | | nInterval==0) { return; } M_Start. GetWindowText (strBtn); {if (strBtn=="start") SetTimer (1, nInterval * 10000, NULL); M_Start. SetWindowText (" stop "); GetDlgItem (IDC_EDIT_CAPTION) - & gt; The EnableWindow (FALSE); GetDlgItem (IDC_EDIT_INTERVAL) - & gt; The EnableWindow (FALSE); } The else { KillTimer (1); M_Start. SetWindowText (" start "); GetDlgItem (IDC_EDIT_CAPTION) - & gt; The EnableWindow (TRUE); GetDlgItem (IDC_EDIT_INTERVAL) - & gt; The EnableWindow (TRUE); } } Void CKeyBoardDlgDlg: : OnTimer (UINT nIDEvent) { HWND HWND=: : FindWindow (NULL, m_StrCaption GetBuffer (0)); : : PostMessage (hWnd, WM_KEYDOWN, VK_F5, 1); Sleep (50); : : PostMessage (hWnd, WM_KEYUP VK_F5, 1); CDialog: : OnTimer (nIDEvent); } But no response after the program is run, turn to... HWND HWND=: : FindWindow (NULL, m_StrCaption GetBuffer (0)); When there is a registered name of the class is available, if the source program didn't register the name of the class, it won't, you can have a try with IE browser, Or search for program search, find out the browser handles, CodePudding user response:
refer to 7th floor qq_29522823 response: Quote: refer to the sixth floor zhao4zhong1 response: Corresponding message map, less nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull