Code: Select all
#include <windows.h>
int main()
{
ShellExecute( NULL, "open", "defcon.exe", NULL, "C:\\Program Files (x86)\\Defcon\\", SW_SHOW ); // Opens Defcon.exe from its location in C:
{
int x=1920; // X = Screen Width
int y=1080; // Y = Screen Hight
Sleep(6000); // Program waits for 6 Seconds
Loop: // Loops the Program
const int CURSOR_X = x*0.520833; // x-coordinate of mouse
const int CURSOR_Y = y*0.481481; // y-coordinate of mouse
SetCursorPos(CURSOR_X,CURSOR_Y); // Move cursor to set co-ordinates - Cursor on Rolling Demo
for (int n=0;n>0;n++) // Loop detects first run, if first long timer, not skip
{
Sleep(4000); // Program waits for 4 seconds
goto rdc; // Goes to Rolling Demo Section
}
rdc: // Rolling Demo Section
Sleep(25); // Program waits for 25 ms
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // Left Mouse button click - Clicks on Rolling Demo
Sleep(25); // Program waits for 25 ms
const int CURSOR_Xb = x*0.026041667; // x-coordinate of mouse
const int CURSOR_Yb = y*1; // y-coordinate of mouse
SetCursorPos(CURSOR_Xb,CURSOR_Yb); // Move cursor to set co-ordinates - 'hidden' bottom left
Sleep(360000); // Program waits for 6 minutes.
keybd_event(VK_ESCAPE,0x81,0 , 0); // Esc Press
keybd_event(VK_ESCAPE,0x81,KEYEVENTF_KEYUP,0); // Esc Release - Brings Up Menu
Sleep(50); // Progrm waits for 50 ms
const int CURSOR_Xc = x*0.520833; // x-coordinate of mouse
const int CURSOR_Yc = y*0.546296296; // y-coordinate of mouse
SetCursorPos(CURSOR_Xc,CURSOR_Yc); // Move cursor to set co-ordinates - Cursor On Leave Game
Sleep(25); // Program waits for 25 ms
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // Left Mouse button click - Click Leave Game
Sleep(25); // Program waits for 25 ms
const int CURSOR_Xd = x*0.479166667; // x-coordinate of mouse
const int CURSOR_Yd = y*0.527777778; // y-coordinate of mouse
SetCursorPos(CURSOR_Xd,CURSOR_Yd); // Move cursor to set co-ordinates - Cursor on Yes
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // Left Mouse button click - Click Yes
goto Loop; // Loop Rolling Demo
}}
Limitations
1 - Must be the CD version of Defcon, NOT the Steam version.
2 - No way to exit Defcon and the program, via a mouse move or button press i.e. User needs to quit both programs.
3 - Program must be installed in C:\Program Files (x86)\Defcon\ and the exe must be named defcon.exe. (This is editable with with a compiler)
4 - Screen resolution for this version is 1920 X 1080. (This is editable with a compiler)
5 - Sleep timers are based on my systems performance. (This is editable with a compiler)
6 - Cursor co-ordinates based on screen resolution. (This is editable with a compiler)
7 - Only tested on Windows 7 64-bit SP1, Core2Quad 2.66 Ghz, 4 GB RAM.
Code Alterations for Screen Resolutions
The code above (with edited x,y) works with :- 1920 X 1080, 1768 X 992, 1680 X 1050, 1600 X 1024, 1600 X 900, 1440 X 900, 1280 X 1024, 1280 X 960, 1152 X 864.
Altering CURSOR_Yc=0.56 (with edited x,y) :- 1366 X 768, 1360 X 768, 1280 X 800, 1280 X 768, 1280 X 720.
Altering CURSOR_Yc=0.56, CURSOR_Yd=0.56, CURSOR_Xd=0.47 (with edited x,y) :- 1176 X 664.
Altering CURSOR_Yc=0.56, CURSOR_Yd=0.54, CURSOR_Xd=0.47 (with edited x,y) :- 1024 X 768.
Altering CURSOR_Yc=0.58, CURSOR_Yd=0.54, CURSOR_Xd=0.47 (with edited x,y) :- 800 X 600, 720 X 576.
Altering CURSOR_Yc=0.6, CURSOR_Yd=0.58, CURSOR_Xd=0.45 (with edited x,y) :- 720 X 480, 640 X 480.
Closing Remarks
Feel free to alter, add and generally mess with the code, it'd be great to see a much more user friendly version of it some time down the line, but I just don't have the time or patience at the moment to spend any more time on it.
The program was built with Code Blocks 10.05.
Have fun!