Ver Mensaje Individual
  #9 (permalink)  
Antiguo 18/01/2014, 11:40
fooztt
 
Fecha de Ingreso: enero-2014
Mensajes: 6
Antigüedad: 10 años, 3 meses
Puntos: 0
Respuesta: Un problemita alguien? soy novato

Cita:
Iniciado por carbon Ver Mensaje
Ya entendí, tu quieres desactivarlo / activarlo con F4.

Código C++:
Ver original
  1. #include <windows.h>
  2. #include <cstdlib>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. bool bEnabled = true;
  8.  
  9. DWORD WINAPI KeyboardManager(LPVOID lpvParam)
  10. {
  11.     while (1)
  12.     {
  13.         if (GetAsyncKeyState(VK_F4))
  14.             bEnabled = !bEnabled;
  15.  
  16.         Sleep(300);
  17.     }
  18.  
  19.     return 0;
  20. }
  21.  
  22. int main(int argc, char* argv[]) {
  23.     int delay = 0;
  24.     int positions = 0;
  25.     POINT cursorPos[256];
  26.     HANDLE hThread;
  27.     SetConsoleTitleA("Andromeda 0.1");
  28.     cout << "Bienvenido a Andromeda 0.1\n";
  29.     cout << "Tiempo que se tomara los clicks (en milisegundos): ";
  30.     cin >> delay;
  31.     cout << "1. Para agregar posicion presione F1\n";
  32.     cout << "2. Presione F3 para empezar\n";
  33.  
  34.     for(;; Sleep(200)) {
  35.         if(GetAsyncKeyState(VK_F1)) {
  36.             GetCursorPos(&cursorPos[positions]);
  37.             cout << "Posicion actual " << positions + 1 << ": " << cursorPos[positions].x << ' ' << cursorPos[positions].y << '\n';
  38.             positions += 1;
  39.         }
  40.         if(GetAsyncKeyState(VK_F3)) {
  41.             if(positions == 0) {
  42.                 GetCursorPos(&cursorPos[positions]);
  43.                 positions = 1;
  44.             }
  45.             break;
  46.         }
  47.     }
  48.  
  49.     cout << "Andromeda iniciado\n";
  50.     cout << "Presione F4 para activar/desactivar\n";
  51.     cout << "F5 para salir." << endl;
  52.  
  53.     CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)KeyboardManager, &hThread, 0, NULL);
  54.  
  55.     int pos = 0;
  56.     for(;;Sleep(delay)) {
  57.         if (GetAsyncKeyState(VK_F5))
  58.             break;
  59.         if (bEnabled)
  60.         {
  61.             SetCursorPos(cursorPos[pos % positions].x, cursorPos[pos % positions].y);
  62.             mouse_event(MOUSEEVENTF_LEFTDOWN, cursorPos[pos % positions].x, cursorPos[pos % positions].y, 0, 0);
  63.             mouse_event(MOUSEEVENTF_LEFTUP, cursorPos[pos % positions].x, cursorPos[pos % positions].y, 0, 0);
  64.             pos++;
  65.         }
  66.     }
  67.  
  68.     CloseHandle(hThread);
  69.  
  70.     cout << "Gracias por utilizar Andromeda 0.1\n";
  71.     Sleep(1000);
  72.     return 0;
  73. }

Ahora se cierra con F5.

Mínimo porque tengo que presionar 3 veces para apagar? osea 2 veces porque con F4 se prende pero para detener tengo que presionar F4, 2 veces para apagar quiero que se apague de una vez. XD de que vuelva a presionar F4 pero gracias. de todos modos gracias.