BOOL CMsgSender::LDblClick(int x, int y) const { if (m_hTarget == NULL) return FALSE; LeftClick(x, y); LeftClick(x, y); return TRUE; }
bool CMouseControl::LeftDblClick () { if (CheckClickArea ()) { LeftClick (); LeftClick (); return true; } return false; }
bool CCylinderEditCommand::PreTranslateMessage(MSG* pMsg) { try { /*if (pMsg->message==WM_KEYUP|| pMsg->message==WM_CHAR) return false;*/ if (pMsg->message==WM_KEYUP||pMsg->message==WM_KEYDOWN || pMsg->message==WM_CHAR) { if (pMsg->wParam==VK_RETURN) { OnEnter(); return true; } if (pMsg->wParam==VK_ESCAPE) { m_app->StopCommander(); return true; } if (m_r_panel) { m_r_panel->GetWindow()->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam); } if (m_other_params_dlg) { m_other_params_dlg->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam); return false; } if (pMsg->message==WM_KEYDOWN) return false; else return true; } else { if (pMsg->hwnd == m_app->GetViewPort()->GetWindow()->m_hWnd) { switch(pMsg->message) { case WM_MOUSEMOVE: MouseMove(pMsg->wParam,GET_X_LPARAM(pMsg->lParam),GET_Y_LPARAM(pMsg->lParam)); return true; case WM_LBUTTONUP: LeftClick(pMsg->wParam,GET_X_LPARAM(pMsg->lParam),GET_Y_LPARAM(pMsg->lParam)); return true; default: return false; } } } } catch(...){ } return false; }
void C_Game::TimerManagement() { Picking(); if(_boolBreakAnim) { if(_timerBreakAnim.GetElapsedTime() > 0.20f) { if(_frameBreakAnim == CUBE_BREAK_ANIM9) LeftClick(); else _frameBreakAnim++; _timerBreakAnim.Reset(); } } CallPhysicsFunctions(); }
void MoveMouseAndClick(HWND hwnd, int x, int y) { int ix = ::GetSystemMetrics(SM_CXSCREEN); int iy = ::GetSystemMetrics(SM_CYSCREEN); POINT pt = {x,y}; INPUT Input = {0}; int destX, destY; ::ClientToScreen(hwnd, &pt); destX = pt.x; destY = pt.y; Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE; Input.mi.dx = destX*65535/ix; Input.mi.dy = destY*65535/iy; ::SendInput(1, &Input, sizeof(INPUT)); LeftClick(); }
int _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR lpCmdLine, int cmdShow) { LeftClick(); return 0; }
BOOL CALLBACK EV_DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { EV_shared=hwndDlg; EV_list_hwnd=GetDlgItem(hwndDlg, IDC_LIST); } return TRUE; case WM_CLOSE: { EndDialog(hwndDlg, 0); } return TRUE; case WM_BROWSE: { SendMessageA(EV_list_hwnd, LB_RESETCONTENT, 0, 0); strcpy(EV_szFileName, (const char*)wParam); strcpy(EV_program_dir, EV_szFileName); int i=strlen(EV_program_dir); while(EV_program_dir[i]!='\\') i--; EV_program_dir[i]=0; CreateThread(0, 0, EV_DebugThread, 0, 0, 0); } return TRUE; case WM_DROPFILES: { SendMessageA(EV_list_hwnd, LB_RESETCONTENT, 0, 0); DragQueryFileA((HDROP)wParam, 0, EV_szFileName, MAX_PATH); strcpy(EV_program_dir, EV_szFileName); int i=strlen(EV_program_dir); while(EV_program_dir[i]!='\\') i--; EV_program_dir[i]=0; CreateThread(0, 0, EV_DebugThread, 0, 0, 0); } return TRUE; case WM_CONTEXTMENU: { if(GetDlgCtrlID((HWND)wParam)==IDC_LIST) { LeftClick(); LeftClick(); } } return TRUE; case WM_HELP: { char id[10]=""; sprintf(id, "%d", IDS_HELPEVLOG); SetEnvironmentVariableA("HELPID", id); SetEnvironmentVariableA("HELPTITLE", "EVLog Help"); DialogBox(hInst, MAKEINTRESOURCE(DLG_HELP), hwndDlg, DlgHelp); } return TRUE; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_LIST: { switch(HIWORD(wParam)) { case LBN_DBLCLK: { int cursel=SendMessageA(EV_list_hwnd, LB_GETCURSEL, 0, 0); int count=SendMessageA(EV_list_hwnd, LB_GETCOUNT, 0, 0); if(!count) return TRUE; char line_text[1024]=""; char var_name[512]=""; char var_value[512]=""; SendMessageA(EV_list_hwnd, LB_GETTEXT, cursel, (LPARAM)line_text); int len=strlen(line_text); for(int i=0,j=0,k=0,l=0; i<len; i++) { if(line_text[i]=='=') { i++; j=1; } if(!j) k+=sprintf(var_name+k, "%c", line_text[i]); else l+=sprintf(var_value+l, "%c", line_text[i]); } HMENU myMenu=0; myMenu=CreatePopupMenu(); AppendMenu(myMenu, MF_STRING, 1, "Copy Variable &Name"); if(strcmp(var_value, "(0)")) AppendMenu(myMenu, MF_STRING, 2, "Copy Variable &Value"); AppendMenu(myMenu, MF_STRING, 3, "Copy &Line"); POINT cursorPos; GetCursorPos(&cursorPos); SetForegroundWindow(hwndDlg); UINT MenuItemClicked=TrackPopupMenu(myMenu, TPM_RETURNCMD|TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0); SendMessage(hwndDlg, WM_NULL, 0, 0); switch(MenuItemClicked) { case 1: CopyToClipboard(var_name); break; case 2: CopyToClipboard(var_value); break; case 3: CopyToClipboard(line_text); break; } } return TRUE; } } return TRUE; case IDC_BTN_DUMP: { char massive_string[32768]="", single_string[255]="Coded by Mr. eXoDia // T.P.o.D.T 2012\r\n\r\n"; int total=SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCOUNT, 0, 0); for(int i=0; i!=total; i++) { SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETTEXT, (WPARAM)i, (LPARAM)single_string); sprintf(massive_string, "%s%s\r\n", massive_string, single_string); } char log_filename[MAX_PATH]=""; log_filename[0]=0; OPENFILENAME ofstruct; memset(&ofstruct, 0, sizeof(ofstruct)); ofstruct.lStructSize=sizeof(ofstruct); ofstruct.hwndOwner=hwndDlg; ofstruct.hInstance=hInst; ofstruct.lpstrFilter="Log files (*.log)\0*.log\0\0"; ofstruct.lpstrFile=log_filename; ofstruct.nMaxFile=MAX_PATH; ofstruct.lpstrInitialDir=EV_program_dir; ofstruct.lpstrTitle="Save file"; ofstruct.lpstrDefExt="log"; ofstruct.Flags=OFN_EXTENSIONDIFFERENT|OFN_HIDEREADONLY|OFN_NONETWORKBUTTON|OFN_OVERWRITEPROMPT; GetSaveFileName(&ofstruct); if(!log_filename[0]) return TRUE; HANDLE hFile=CreateFileA(log_filename, GENERIC_ALL, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if(hFile==INVALID_HANDLE_VALUE) { MessageBoxA(hwndDlg, "Could not create the file, maybe it's in use...", "Error!", MB_ICONERROR); return TRUE; } DWORD written=0; if(!WriteFile(hFile, massive_string, strlen(massive_string), &written, 0)) { CloseHandle(hFile); MessageBoxA(hwndDlg, "Could not write to the file, maybe it's in use...", "Error!", MB_ICONERROR); return TRUE; } CloseHandle(hFile); } return TRUE; } } return TRUE; } return FALSE; }
void CMouseControl::LeftDblClick () { LeftClick (); sleep_milliseconds(m_sendActionWait); LeftClick (); }
bool CylinderCommand::PreTranslateMessage(MSG* pMsg) { try { /*if (pMsg->message==WM_KEYUP|| pMsg->message==WM_CHAR) return false;*/ if (pMsg->message==WM_KEYUP||pMsg->message==WM_KEYDOWN || pMsg->message==WM_CHAR) { if (pMsg->wParam==VK_RETURN) { OnEnter(); return true; } if (pMsg->wParam==VK_ESCAPE) { m_app->StopCommander(); return true; } switch(m_step) { case 0: if (m_get_first_point_panel) m_get_first_point_panel->GetWindow()->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam); break; case 1: if (m_get_second_point_panel) m_get_second_point_panel->GetWindow()->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam); break; case 2: if (m_get_r_panel) m_get_r_panel->GetWindow()->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam); break; default: return false; } if (pMsg->message==WM_KEYDOWN) return false; else return true; } else { if (pMsg->hwnd == m_app->GetViewPort()->GetWindow()->m_hWnd) { switch(pMsg->message) { case WM_MOUSEMOVE: MouseMove(pMsg->wParam,GET_X_LPARAM(pMsg->lParam),GET_Y_LPARAM(pMsg->lParam)); return true; case WM_LBUTTONDOWN: LeftClick(pMsg->wParam,GET_X_LPARAM(pMsg->lParam),GET_Y_LPARAM(pMsg->lParam)); return true; default: return false; } } } } catch(...){ } return false; }
void camera_feed() { VideoCapture cap(0); if (cap.isOpened()) { int distance[3], MUL = 1, dif = 0; char key; bool first_run = false, is_size_checked = false, moved = false, shoot = false; unsigned long max_contours_amount = 0; Point drawing_point, cursor, additional_point; vector<vector<Point>> contours, main_points; vector<Point> pen1, pen2, pens; vector<Vec4i> hierarchy; Mat frame, real_pic, drawing_frame, maze; Scalar low_boundry(45, 107, 52), high_boundry(86, 227, 160), color(100, 100, 100); //namedWindow("drawing_frame", 1); //namedWindow("frame", 1); cap >> frame; cursor = Point(20, 20); maze = imread("maze1.jpg"); maze = maze / WHITE; maze = maze * WHITE; bitwise_not(maze, maze); RECT rect = { 0 }; // gaming stuff! HWND window = FindWindow("Chicken Invaders 5", "Chicken Invaders 5"); Sleep(2000); if (window) { GetClientRect(window, &rect); SetForegroundWindow(window); SetActiveWindow(window); SetFocus(window); } while (true) { shoot = false; cap >> frame; real_pic = frame.clone(); while (main_points.size() != 0) { main_points.pop_back(); } if (!first_run) { drawing_frame = real_pic.clone(); resize(drawing_frame, drawing_frame, Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) - 50)); resize(maze, maze, Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) - 50)); first_run = true; } flip(real_pic, real_pic, 1); cvtColor(frame, frame, COLOR_BGR2HSV); inRange(frame, low_boundry, high_boundry, frame); flip(frame, frame, 1); contours.clear(); resize(frame, frame, Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN))); findContours(frame, contours, hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_NONE); is_size_checked = false; if (contours.size() != 0) { for (vector<vector<Point>>::iterator it = contours.begin(); it != contours.end(); it++) { if (it->size() > max_contours_amount * 0.7) { main_points.push_back(*it); max_contours_amount = it->size(); is_size_checked = true; } } } if (is_size_checked) { moved = false; drawing_point = stabilized_point(main_points[0]); if (main_points.size() == 2) { if (stabilized_point(main_points[0]).x < stabilized_point(main_points[1]).x) { drawing_point = stabilized_point(main_points[1]); } shoot = true; } drawing_point.x += (drawing_point.x - drawing_frame.size().width / 2) / 10; drawing_point.y += (drawing_point.y - drawing_frame.size().height / 2) / 10; while (drawing_point.x > maze.size().width) { drawing_point.x--; } while (drawing_point.x < 0) { drawing_point.x++; } while (drawing_point.y > maze.size().height) { drawing_point.y--; } while (drawing_point.y < 0) { drawing_point.y++; } distance[0] = drawing_point.x - cursor.x; distance[1] = drawing_point.y - cursor.y; while (distance[0] != 0 && distance[1] != 0) { if (maze.at<Vec3b>(Point(cursor.x + distance[0] / 15, cursor.y))[0] != WHITE) { cursor.x += distance[0] / 15; distance[0] /= 15; moved = true; } if (maze.at<Vec3b>(Point(cursor.x, cursor.y + distance[1] / 15))[0] != WHITE) { cursor.y += distance[1] / 15; distance[1] /= 15; moved = true; } if (!moved) { putText(drawing_frame, "Struck a wall!", Point(0, 40), FONT_HERSHEY_COMPLEX_SMALL, 1, Scalar(WHITE, WHITE, BLACK, 1), 1, CV_AA); distance[0] = 0; distance[1] = 0; } } SetCursorPos(drawing_point.x, drawing_point.y); // gaming stuff! circle(drawing_frame, cursor, 13, Scalar(WHITE, BLACK, WHITE), 2); circle(drawing_frame, drawing_point, 13, Scalar(WHITE, BLACK, WHITE), -1); //circle(drawing_frame, stabilized_point(pen1), 13, Scalar(WHITE, WHITE, BLACK), -1); } else { putText(drawing_frame, "Lost drawing object!", Point(0, 20), FONT_HERSHEY_COMPLEX_SMALL, 1, Scalar(WHITE, WHITE, BLACK, 1), 1, CV_AA); circle(drawing_frame, cursor, 13, Scalar(WHITE, WHITE, BLACK), 3); } if (shoot) { LeftClick(drawing_point.x, drawing_point.y); } key = waitKey(10); drawing_frame = maze + drawing_frame; bitwise_not(drawing_frame, drawing_frame); //imshow("drawing_frame", drawing_frame); //imshow("frame", frame); frame = BLACK; drawing_frame = BLACK; real_pic = BLACK; } }
int main() { /** En el main lo que se ejecuta es la secuencia de pasos para hacer un dibujo en paint * La demostracion de ejecucion de este dibujo esta en:https://www.youtube.com/watch?v=Gg7trLQ0Ndg **/ int i=0,j,h,g; int flag_quit=GetKeyState(VK_ESCAPE); int offset=0; Sleep(2000); //Esperar 2 segundos antes de empezar print_coords(); SetCursorPos(coords[0][i],coords[1][i]); i++; print_coords(); for(g=0; g<3; g++) { SetCursorPos(coords[0][i],coords[1][i]); Sleep(d); LeftClick(); i++; print_coords(); for(h=0; h<3; h++) { SetCursorPos(coords[0][i],coords[1][i]); SetLeftClick(); print_coords(); for(j=coords[1][i]; j<coords[1][i+1]; j++) { SetCursorPos(coords[0][i]+offset,j+offset); Sleep(d); } i++; SetCursorPos(coords[0][i],coords[1][i]); for(j=coords[0][i]; j<coords[0][i+1]; j++) { SetCursorPos(j+offset,coords[1][i]+offset); Sleep(d); } i++; SetCursorPos(coords[0][i],coords[1][i]); UnSetLeftClick(); SetLeftClick(); for(j=coords[1][i]; j>coords[1][i+1]; j--) { SetCursorPos(coords[0][i]+offset,j+offset); Sleep(d); } i++; SetCursorPos(coords[0][i],coords[1][i]); for(j=coords[0][i]; j>coords[0][i+1]; j--) { SetCursorPos(j+offset,coords[1][i]+offset); Sleep(d); } UnSetLeftClick(); print_coords(); i++; SetCursorPos(coords[0][i],coords[1][i]); print_coords(); i++; print_coords(); SetCursorPos(coords[0][i],coords[1][i]); i++; LeftClick(); print_coords(); if(flag_quit!=GetKeyState(VK_ESCAPE))return 0; //Si se aprieta ESC salir*/ } i=1; offset+=125; } return 1; }