Windows Screensaver

Discuss your new mods and themes here

Moderator: Defcon moderators

User avatar
Treefrog
level1
level1
Posts: 16
Joined: Fri Aug 27, 2010 9:17 pm
Location: Hull, UK

Windows Screensaver

Postby Treefrog » Sun Mar 06, 2011 3:45 am

So after seeing lots of comments and a few people practically saying its impossible, I decided to give it a go, and well I have a result, its extremely unuser friendly, apart from that, it works for me, so I'm fine with it.

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!
brickostone
level0
Posts: 2
Joined: Sun Mar 06, 2011 9:51 pm
Location: United States
Contact:

Titanic work!

Postby brickostone » Sun Mar 06, 2011 9:53 pm

Oh man, you probably did a tremendous work on this.
Could you please explain to me where should i put this code too?!
User avatar
Treefrog
level1
level1
Posts: 16
Joined: Fri Aug 27, 2010 9:17 pm
Location: Hull, UK

Re: Titanic work!

Postby Treefrog » Sun Mar 06, 2011 10:54 pm

brickostone wrote:Oh man, you probably did a tremendous work on this.
Could you please explain to me where should i put this code too?!


All you have to do is download a compiler, such as the one I used, known as Code Blocks, then just copy and paste it into a new project file, and compile it from there.

It should then run straight off.

Code Blocks Download Page http://www.codeblocks.org/downloads/26

Once its been installed, go to File > New > New Project > Console Application > Next > C++ > Then create a project name > Next till finish.

Copy and paste the code over the main.cpp, then hit F9 to compile and run.
brickostone
level0
Posts: 2
Joined: Sun Mar 06, 2011 9:51 pm
Location: United States
Contact:

Postby brickostone » Mon Mar 07, 2011 3:09 am

oh man thank you for your explanation, but i am too of a noob for thi stuff.
Once i put the code in the Main.cpp and press f9 it tells me this "Defcom - Debug" uses an invalid compiler. Probably the toolchain path within the compiler options is not setup correctly?! Skipping..."
Nothing to be done.
well then i also think it might be because i am running XP?!?
or i also think it is because i didnt meet soe of the requirements that you wrote earliel your first post!!
but anyway i will save the code in case it will work one day! thanks you for that!

Return to “Mod Projects”

Who is online

Users browsing this forum: No registered users and 24 guests