timecall

This is a discussion on timecall within the Windows Programming forums, part of the Platform Specific Boards category; hey.. I got some problems with timeCall or whatever its called.. could anyone help me out here? when i press ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    6

    timecall

    hey.. I got some problems with timeCall or whatever its called.. could anyone help me out here? when i press f12 nothing is happening; although i have the code if(getasynckeystate(vk_f12)) etc... i sux at timecalls so im not sure if im doing something wrong or what

    Code:
    #include <windows.h>
    
    #include "resource.h" 
    
    DWORD pid; 
    HWND hwndWindow; 
    DWORD bytes; 
    HANDLE hand = NULL;
    
    const char g_szClassName[] = "myWindowClass";
    
    void Initialize(HWND hwnd,WPARAM wParam, LPARAM lParam) {
    	hwndWindow = FindWindow("TibiaClient",0);
    	if(hwndWindow) {
            GetWindowThreadProcessId(hwndWindow, &pid);
            hand = OpenProcess(PROCESS_ALL_ACCESS,0,pid);
    
           
         
    		SetTimer(hwnd, 1, 100, NULL);
    	} else {
    		MessageBox(0, "Please start Tibia first!", "Error", MB_ICONERROR | MB_OK);
    		DestroyWindow(hwnd);
    	}
    }
    
    void timerCall()
    {
         if(GetAsyncKeyState(VK_F12))
         {
            MessageBox(0, "Working", "Its working omfg", MB_ICONEXCLAMATION | MB_OK);
         }
    }
    BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
    	switch(Message)
    	{
    		case WM_COMMAND:
    			switch(LOWORD(wParam))
    			{
    				case IDOK:
    					EndDialog(hwnd, IDOK);
    				break;
    				case IDCANCEL:
    					EndDialog(hwnd, IDCANCEL);
    				break;
    			}
            break;
    		default:
    			return FALSE;
    	}
    	return TRUE;
    }
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
    	switch(Message)
    	{
    		case WM_COMMAND:
    			switch(LOWORD(wParam))
    			{
    				case ID_FILE_EXIT:
    					PostMessage(hwnd, WM_CLOSE, 0, 0);
    				break;
    				case ID_HELP_ABOUT:
    				{
    					int ret = DialogBox(GetModuleHandle(NULL), 
    						MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
    					if(ret == IDOK){
    						MessageBox(hwnd, "Dialog exited with IDOK.", "Notice",
    							MB_OK | MB_ICONINFORMATION);
    					}
    					else if(ret == IDCANCEL){
    						MessageBox(hwnd, "Dialog exited with IDCANCEL.", "Notice",
    							MB_OK | MB_ICONINFORMATION);
    					}
    					else if(ret == -1){
    						MessageBox(hwnd, "Dialog failed!", "Error",
    							MB_OK | MB_ICONINFORMATION);
    					}
    				}
    				break;
    			}
    		break;
    		case WM_CLOSE:
    			DestroyWindow(hwnd);
    		break;
    		case WM_DESTROY:
    			PostQuitMessage(0);
    		break;
    		case WM_TIMER:
    			timerCall();
    			
    			return TRUE;
    		break;
    		case WM_INITDIALOG:
                 Initialize(hwnd, wParam, lParam);
                 
                 return TRUE;
            break;
    		default:
    			return DefWindowProc(hwnd, Message, wParam, lParam);
    	}
    	return 0;
    }
    
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    	LPSTR lpCmdLine, int nCmdShow)
    {
    	WNDCLASSEX wc;
    	HWND hwnd;
    	MSG Msg;
    
    	wc.cbSize		 = sizeof(WNDCLASSEX);
    	wc.style		 = 0;
    	wc.lpfnWndProc	 = WndProc;
    	wc.cbClsExtra	 = 0;
    	wc.cbWndExtra	 = 0;
    	wc.hInstance	 = hInstance;
    	wc.hIcon		 = LoadIcon(NULL, IDI_APPLICATION);
    	wc.hCursor		 = LoadCursor(NULL, IDC_ARROW);
    	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    	wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MYMENU);
    	wc.lpszClassName = g_szClassName;
    	wc.hIconSm		 = LoadIcon(NULL, IDI_APPLICATION);
    
    	if(!RegisterClassEx(&wc))
    	{
    		MessageBox(NULL, "Window Registration Failed!", "Error!",
    			MB_ICONEXCLAMATION | MB_OK);
    		return 0;
    	}
    
    	hwnd = CreateWindowEx(
    		WS_EX_CLIENTEDGE,
    		g_szClassName,
    		"The title of my window",
    		WS_OVERLAPPEDWINDOW,
    		CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
    		NULL, NULL, hInstance, NULL);
    
    	if(hwnd == NULL)
    	{
    		MessageBox(NULL, "Window Creation Failed!", "Error!",
    			MB_ICONEXCLAMATION | MB_OK);
    		return 0;
    	}
    
    	ShowWindow(hwnd, nCmdShow);
    	UpdateWindow(hwnd);
    
    	while(GetMessage(&Msg, NULL, 0, 0) > 0)
    	{
    		TranslateMessage(&Msg);
    		DispatchMessage(&Msg);
    	}
    	return Msg.wParam;
    }
    thanks

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    1. WM_INITDIALOG is sent to dialog boxes. For windows which aren't dialog boxes, use the WM_CREATE message.
    2. F12 is reserved for use by the debugger. Use another key.
    3. Instead of GetAsyncKeyState you may consider using WM_KEYDOWN or RegisterHotKey.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21