SRL Archive - Help

Taking a picture and saving it


zluo

2012-06-16 02:33:57

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

2012-06-16 02:42:40

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');

zluo

2012-06-16 04:12:05

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

Abu

2012-06-16 05:23:41

Check this thread to help fix errors like that:
http://villavu.com/forum/showthread.php?t=82793

zluo

2012-06-16 05:48:19

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

2012-06-16 05:52:05

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

2012-06-16 05:54:42

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.

zluo

2012-06-16 18:21:47

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

2012-06-16 18:26:00

Get Gyazo, or use swiftkit, it has a good screenshot function and lots of other useful tools.

zluo

2012-06-16 18:27:25

From: FifthDimension
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

2012-06-16 18:42:45

From: zluo
procedure MakeScreenShot(fileName, 'C:\Simba':String);  // [B]this should JUST be C:\simba\'whatever follows'[/B]
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

2012-06-16 18:56:03

From: Sokkr7
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;