View Full Version : Taking a picture and saving it
is there a special function that makes simba take a printscreen of the client and save it to the desktop? need it so i can see what goes wrong in my script, thanks
Shatterhand
06-16-2012, 06:42 AM
I have this:
procedure MakeScreenShot(const FilePath : String);
var
fileName : String;
Year, Month, Day : Word;
i : Integer;
begin
if TakeScreenShots then
begin
if not DirectoryExists(ScreenShotsPath) then
CreateDirectory(ScreenShotsPath);
if not DirectoryExists(FilePath) then
CreateDirectory(FilePath);
DecodeDate(Date,Year,Month,Day);
i := 0;
repeat
i := i+1;
FileName := ToStr(Year) + '-' + ToStr(Month) + '-' + ToStr(Day) + ' (' + IntToStr(i) + ').jpg';
until not FileExists(FilePath + FileName)
SaveScreenShot(FilePath + FileName); //example: 2012-3-21 (1).jpg
end;
end;
EXAMPLE
MakeScreenShot('C:\Simba\Screenshots');
procedure MakeScreenShot('C:\Simba');
var
fileName : String;
Year, Month, Day : Word;
i : Integer;
begin
if TakeScreenShots then
begin
if not DirectoryExists(ScreenShotsPath) then
CreateDirectory(ScreenShotsPath);
if not DirectoryExists(FilePath) then
CreateDirectory(FilePath);
DecodeDate(Date,Year,Month,Day);
i := 0;
repeat
i := i+1;
FileName := ToStr(Year) + '-' + ToStr(Month) + '-' + ToStr(Day) + ' (' + IntToStr(i) + ').jpg';
until not FileExists(FilePath + FileName)
SaveScreenShot(FilePath + FileName); //example: 2012-3-21 (1).jpg
end;
end;
Thank for the help, but I keep getting an identifier error at the start of my script, whats wrong? sorry new to this stuff
Check this thread to help fix errors like that:
http://villavu.com/forum/showthread.php?t=82793
Im still quite lost, because it says identifier expected and on your thread (thanks for it) it says i need an even number of begins and ends, but i think i have already.
masterBB
06-16-2012, 09:52 AM
procedure MakeScreenShot(fileName, ScreenShotsPath:String);
var
Year, Month, Day : Word;
i : Integer;
begin
if TakeScreenShots then
begin
if not DirectoryExists(ScreenShotsPath) then
CreateDirectory(ScreenShotsPath);
DecodeDate(Date,Year,Month,Day);
i := 0;
repeat
i := i+1;
FileName := fileName + ToStr(Year) + '-' + ToStr(Month) + '-' + ToStr(Day) + ' (' + IntToStr(i) + ').jpg';
until not FileExists(FilePath + FileName)
SaveScreenShot(FilePath + FileName); //example: 2012-3-21 (1).jpg
end;
end;
CephaXz
06-16-2012, 09:54 AM
I just did this.
Procedure TakePhoto;
begin
TakeScreen('Terminated');
end;
And in my mainloop, I put
AddOnTerminate('TakePhoto');
So if your function or procedure terminate your script whenever things goes wrong, it will take a photo.
procedure MakeScreenShot(fileName, 'C:\Simba':String);
var
Year, Month, Day : Word;
i : Integer;
begin
if TakeScreenShots then
begin
if not DirectoryExists(ScreenShotsPath) then
CreateDirectory(ScreenShotsPath);
DecodeDate(Date,Year,Month,Day);
i := 0;
repeat
i := i+1;
FileName := fileName + ToStr(Year) + '-' + ToStr(Month) + '-' + ToStr(Day) + ' (' + IntToStr(i) + ').jpg';
until not FileExists(FilePath + FileName)
SaveScreenShot(FilePath + FileName); //example: 2012-3-21 (1).jpg
end;
end;
sorry for being stupid, but i seriously cant see whats wrong, thanks if you can help.
[Error] (2:36): Identifier expected at line 1 happens all the time
FifthDimension
06-16-2012, 10:26 PM
Get Gyazo, or use swiftkit, it has a good screenshot function and lots of other useful tools.
Get Gyazo, or use swiftkit, it has a good screenshot function and lots of other useful tools.
this for when my script messes up or terminates :P
(s)okkr7
06-16-2012, 10:42 PM
procedure MakeScreenShot(fileName, 'C:\Simba':String); // this should JUST be C:\simba\'whatever follows'
var
Year, Month, Day : Word;
i : Integer;
begin
if TakeScreenShots then
begin
if not DirectoryExists(ScreenShotsPath) then
CreateDirectory(ScreenShotsPath);
DecodeDate(Date,Year,Month,Day);
i := 0;
repeat
i := i+1;
FileName := fileName + ToStr(Year) + '-' + ToStr(Month) + '-' + ToStr(Day) + ' (' + IntToStr(i) + ').jpg';
until not FileExists(FilePath + FileName)
SaveScreenShot(FilePath + FileName); //example: 2012-3-21 (1).jpg
end;
end;
sorry for being stupid, but i seriously cant see whats wrong, thanks if you can help.
[Error] (2:36): Identifier expected at line 1 happens all the time
pretty sure that's all that's wrong..
putonajonny
06-16-2012, 10:56 PM
pretty sure that's all that's wrong..
This help?
procedure TakeScreenShot;
var
Year, Month, Day : Word;
i : Integer;
Path, Name : String;
begin
Path := AppPath + 'Screenshots\';
if(not DirectoryExists(Path))then
ForceDirectories(Path);
DecodeDate(Date,Year,Month,Day);
i := 0;
repeat
i := i+1;
Name := Name + ToStr(Year) + '-' + ToStr(Month) + '-' + ToStr(Day);
if(i = 0)then
Name := Name + '.jpg'
else
Name := Name + ' (' + IntToStr(i) + ').jpg';
until(not FileExists(Path + Name));
SaveScreenShot(Path + Name); //example: 2012-3-21 (1).jpg
end;
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.