Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [GDK] Screenshot code

Author
Message
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 1st Mar 2010 11:48 Edited at: 1st Mar 2010 11:49
Simple save screenshot to disk code, with file name checking.



marlou
15
Years of Service
User Offline
Joined: 17th Jan 2009
Location:
Posted: 2nd Mar 2010 06:18

Thats going to concantenate repeatedly for existing files.
The filename would become "my_screenshot_1.bmpmy_screenshot_2.bmp" if you get an existent "my_screenshot_1.bmp".
Its that what its supposed to name the file?

When a person has nothing but a dream, can he dare to dream.
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 2nd Mar 2010 11:46
Sorry, but strcpy overwrites the value of test_my_filename every while loop:

1st loop:

while ( dbFileExist ( test_my_filename ) ) //->test_my_filename VALUE = "my_screenshot.bmp"
{
strcpy(test_my_filename, my_filename); //->test_my_filename VALUE = "my_screenshot"

strcat(test_my_filename, "_"); //->test_my_filename VALUE = "my_screenshot_"
strcat(test_my_filename, dbStr( (int) picture_counter) ); //->test_my_filename VALUE = "my_screenshot_1"
strcat(test_my_filename, ".bmp"); //->test_my_filename VALUE = "my_screenshot_1.bmp"

picture_counter++; //=2
}


2nd loop:

while ( dbFileExist ( test_my_filename ) ) //test_my_filename VALUE = "my_screenshot_1.bmp"

{
strcpy(test_my_filename, my_filename); //test_my_filename VALUE = "my_screenshot" (OVERWRITTEN)

strcat(test_my_filename, "_"); //test_my_filename VALUE = "my_screenshot_"
strcat(test_my_filename, dbStr( (int) picture_counter) ); //test_my_filename VALUE = "my_screenshot_2"
strcat(test_my_filename, ".bmp"); //test_my_filename VALUE = "my_screenshot_2.bmp"

picture_counter++; //=3
}

...

and so on

marlou
15
Years of Service
User Offline
Joined: 17th Jan 2009
Location:
Posted: 2nd Mar 2010 12:24
okay..nice code btw...hehe..

When a person has nothing but a dream, can he dare to dream.
GreenDixy
15
Years of Service
User Offline
Joined: 24th Jul 2008
Location: Toronto
Posted: 3rd Mar 2010 17:14
Question. Why not do it this way have the code set so when you hit print screen it takes the screenshot

===================
No life, Lots of love, 2 Kids, God save me LOL

Login to post a reply

Server time is: 2024-04-16 09:21:36
Your offset time is: 2024-04-16 09:21:36