Jump to content
Karat.

Loadbitmap not working?

Recommended Posts

So I got some code, I want to find if I have an image on my taskbar. I cropped the image out from print screen and saved it as a .bmp file. I placed the bmp in a folder called "EVE" which was inside my script folder. So two questions- why the compiler error, and am I properly locating the .bmp file?

 

The Loadbitmap function I found was in this guide: SCAR Divi CDE Manual

I know it's the old manual but I didn't see the new one. All the best guys.

 

program FindEveTaskbarBMP;

var 
 bmpEveTaskbar: Integer;
begin

//WriteLn('Ello');
bmpEveTaskbar := LoadBitmap(.\EVE\EVE_Taskbar.bmp):Integer;
end.

 

The error is as follows:

Compiler Error: Line 8 - Unknown identifier 'LoadBitmap'

Link to comment
Share on other sites

Awesome, got one other small tidbit. I'm trying to find this bitmap on my screen... so I looked into using the FindBitmap function. I don't understand what the XS, YS, XE, YE bounds are for (I kind of assumed they were for the bounds of which to look for the bmp), but I still got

this error.

 

Access violation at address 00E43B92 in module scar.exe Read of address 00000000

 

For this code:

 

program FindEveTaskbarBMP;

var 
 bmpEveTaskbar: TSCARBitmap;  
 xBmp, yBmp: Integer;   
 mXS,mYS,mXE,mYE: Integer;
// sBmp: String;
begin
mXS := 0;
mYS := 0;
mXE := 1365;
mYE := 767;
//WriteLn('Ello');
bmpEveTaskbar := TSCARBitmap.Create('');
bmpEveTaskbar.LoadFromBmp('.\EVE\EVE_Taskbar.bmp');
//sBmp := BitmapToString(bmpEveTaskbar);
//Writeln(sBmp);
if FindBitmap(xBmp,yBmp,bmpEveTaskbar,mXS,mYS,mXE,mYE) then
 begin
   WriteLn('Image found!');
   MoveMouse(xBmp,yBmp); 
 end
else 
 begin
   WriteLn('Image not found ');
 end;
end.

 

Note I attempted to write the bmp to string as well, but my biggest concern was getting FindBitmap to find the bmp on my desktop.

I have the Script folder, with the script files (including this file) with a folder called EVE in the script file and then the bmp within. I saw another post using this function an it appears as I used the dimensions right (my laptop is 1365x767)

Link to comment
Share on other sites

The old documentation said using a . would check the path from where the current file was located at. I fixed the path to derive from my C:\ and it all worked out. Thanks guys
If you want to use path based on script file path, then just remove the dot only. :)

It works without any dots these days.

 

EDIT: You may have to remove ".\" to get it working from current path where script is located at, I think. If that doesn't work, then add "ScriptPath +" before the path (make sure ".\" is deleted befpre you use this function)

-Jani

Edited by Janilabo
Link to comment
Share on other sites

The old documentation said using a . would check the path from where the current file was located at. I fixed the path to derive from my C:\ and it all worked out. Thanks guys

 

The old documentation is no longer valid, hence there's new documentation. You should specify an absolute path. As Janilabo pointed out, you can use ScriptPath, which always includes the trailing backslash, to specify a path in the script's folder.

Link to comment
Share on other sites

Okay, so I edited accordingly, I turned off my F.lux (which alters my screens color output for eye relief) and I still can't get this function to find my bitmap. My Eve taskbar is located at the bottom of my screen, it's there as a 32x32 .bmp file. I screenshot my desktop and pasted it into Adobe CS5 Fireworks and cropped it down to 32x32. Is the resolution the problem? My screen resolution is 1366x768 but Scar's lower left hand coordinate system only goes to 1365x767 (I don't think it matters, as there is space between the Eve Taskbar and the bottom of my computer).

 

I also used the red blimp marker on the Scar program (an 11x8 image (see the red thing next to the 'Function List')) to no avail. What am I doing wrong?

 

program FindEveTaskbarBMP;

var 
 bmpEveTaskbar: TSCARBitmap;  
 xBmp, yBmp: Integer;   
 mXS,mYS,mXE,mYE: Integer;

begin
mXS := 0;
mYS := 0;
mXE := 1366;
mYE := 768;
bmpEveTaskbar := TSCARBitmap.Create('');
bmpEveTaskbar.LoadFromBmp(ScriptPath + '\EVE\EVE_Taskbar.bmp');

if FindBitmap(xBmp,yBmp,bmpEveTaskbar,mXS,mYS,mXE,mYE) then
 begin
   WriteLn('Image found!');
   MoveMouse(xBmp,yBmp); 
 end
else 
 begin        
   MoveMouse(xBmp,yBmp); 
   WriteLn('Image not found ');
 end;
end.

 

I assume mXS by mYS and mXE by mYE specifies the "box" to check for the .bmp in. I always get image not found and the mouse moves to (0,0).

Link to comment
Share on other sites

Path is still incorrect, ScriptPath adds in '\' so your code adds in now '\\'.

 

Try this:

 

program FindEveTaskbarBMP;

var 
 bmpEveTaskbar: TSCARBitmap;  
 xBmp, yBmp: Integer;   
 mXS,mYS,mXE,mYE: Integer;

begin
mXS := 0;
mYS := 0;
mXE := 1366;
mYE := 768;
bmpEveTaskbar := TSCARBitmap.Create('');
bmpEveTaskbar.LoadFromBmp(ScriptPath + 'EVE\EVE_Taskbar.bmp');

if FindBitmap(xBmp,yBmp,bmpEveTaskbar,mXS,mYS,mXE,mYE) then
 begin
   WriteLn('Image found!');
   MoveMouse(xBmp,yBmp); 
 end
else 
 begin        
   MoveMouse(xBmp,yBmp); 
   WriteLn('Image not found ');
 end;
end.

Link to comment
Share on other sites

What is the bitmap? Are you trying to use code 0 as transparent code perhaps (it used to be automatically transparent in past), nowadays, you will have to set yourself the transparent code.

 

Example:

 

program FindEveTaskbarBMP;

var 
 bmpEveTaskbar: TSCARBitmap;  
 xBmp, yBmp: Integer;   
 mXS,mYS,mXE,mYE: Integer;

begin
mXS := 0;
mYS := 0;
mXE := 1366;
mYE := 768;
bmpEveTaskbar := TSCARBitmap.Create('');
bmpEveTaskbar.LoadFromBmp(ScriptPath + 'EVE\EVE_Taskbar.bmp');
bmpEveTaskbar.TranspColor := 0; // Replace 0 with your code... 0-16777215. -1 = no transparent color code (it's -1 by default for every TSCARBitmap)

if FindBitmap(xBmp,yBmp,bmpEveTaskbar,mXS,mYS,mXE,mYE) then
 begin
   WriteLn('Image found!');
   MoveMouse(xBmp,yBmp); 
 end
else 
 begin        
   MoveMouse(xBmp,yBmp); 
   WriteLn('Image not found ');
 end;
end.

 

- - - Updated - - -

 

Karat.,

 

Try running this script with your client (EVE Online?):

 

var
 bmp: TSCARBitmap;

begin
 GetClient.Activate;
 Wait(500);
 bmp := GetClient.Capture;
 bmp.SaveToBMP(ScreenPath + 'client_image.bmp');
 bmp.Free;
end.

 

It saves screenshot of your client to Screenshots Folder of SCAR Divi (SCAR Divi => Tools => Explore => Screenshots Folder), as "client_image.bmp".

See if SCAR can correctly save screenshot of your client..

Link to comment
Share on other sites

I'm using windows 7.

 

An Eve icon is located on my taskbar (along with scar, ccleaner, eclipse, and SRware Iron). I wanted to be able to locate the coordinates of the Eve image. I have a 30x30 image (cropped it down) to include the completely non-transparent icon of Eve that is on my taskbar.

 

I had F.lux installed on my computer, I uninstalled it and nothing changed. I also have Start Killer (it removes the windows icon) but I couldn't see how that could affect Scar. Also, I've tried using the red 'blimp' in the Function list in scar, but that also has not worked for me.

 

The code you supplied to take a screen shot works, and it even works when I use the FindBitmap function on the just taken screen shot. But if I screen shot the desktop myself and crop out the image I want in fireworks (and save as a .bmp file) it won't register what-so-ever. Should I try some sort of tolerance-findBitmap function?

 

Recent Code: (Note, I placed filed in both Screenpath and Scriptpath to see if it made a difference, it didn't)

 

program FindEveTaskbarBMP;

var 
 bmpEveTaskbar: TSCARBitmap;  
 bmp: TSCARBitmap;
 xBmp, yBmp: Integer;   
 mXS,mYS,mXE,mYE: Integer;
// sBmp: String;
begin
mXS := 0;
mYS := 0;
mXE := 1366;
mYE := 768;

 GetClient.Activate;
 Wait(500);
 bmp := GetClient.Capture;
 bmp.SaveToBMP(ScreenPath + 'client_image.bmp');
 bmp.Free;
//WriteLn('Ello');
bmpEveTaskbar := TSCARBitmap.Create('');
//bmpEveTaskbar.LoadFromBmp(ScriptPath + 'EVE\EVE_Taskbar2.bmp'); //Does NOT find image.
//bmpEveTaskbar.LoadFromBmp(ScreenPath + 'client_image.bmp');  //DOES find image.                          
//bmpEveTaskbar.LoadFromBmp(ScreenPath + 'Eve_Taskbar2.bmp');    //Does NOT find 
bmpEveTaskbar.LoadFromBmp(ScreenPath + 'Blimp.bmp');    //Does NOT find 
Wait(300);
bmpEveTaskbar.TranspColor := 0;  // Did not make a difference in noticing the taken screen shot.

if FindBitmap(xBmp,yBmp,bmpEveTaskbar,mXS,mYS,mXE,mYE) then
 begin
   WriteLn('Image found!');
   MoveMouse(xBmp,yBmp); 
 end
else 
 begin        
   MoveMouse(xBmp,yBmp); 
   WriteLn('Image not found ');
 end;
end.


Link to comment
Share on other sites

Bump for 6 days later. Is fireworks the problem? Can someone do this with paint? DO I need to "activate" the scar window in order to register the read blimp? Is there any way I can screen shot the screen, and then attempt to find the smaller bitmap with the larger bitmap with it still outputting the proper x & y values?

Link to comment
Share on other sites

I do not believe Windows cares if you push a link with double backslash or not. (Don't have windows to test with atm)...

 

So you say you tested with: C:\Dir_to_scar\scripts\EVE\EVE_Taskbar.bmp ??

 

Note that it's case sensitive. So if your image is EG: EVE_Taskbar.BMP, or eve_taskbar.bmp... etc, you need to write it that way as well.

Link to comment
Share on other sites

Note that it's case sensitive. So if your image is EG: EVE_Taskbar.BMP, or eve_taskbar.bmp... etc, you need to write it that way as well.

 

The compiler returns an error if the path isn't correct, so that isn't the problem.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...