New Beginner

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu May 01, 2008 5:22 pm

Ok... Once more going against the flow, here is how I would handle this task. If you try this script, be sure to test it before you go at it full force. You HAVE to change the source and target directories and you probably need to change the title bar and border thickness values. These are all at the top of the script.

I set this up so that new file "a" will be the top left quadrant, new file "b" will be the top right quadrant, new file "c" will be the lower left quadrant and new file "d" will be the lower right quadrant.

Hope this helps,
Dick


Code: Select all


//These values need to be tested with your system
//Change them ass needed to make the resulting
//images correct
Let>TitleBarOffset=23
Let>BorderOffset=4

//You need to change this line to point to your source folder
Let>Image_Dir=C:\BMP_Directory\

//You need to change this line to point to your target folder
Let>400x400_dir=C:\BMP_Directory\400_x_400\

Let>image_dir={lower(%image_dir%)}
GetFileList>%Image_Dir%*.bmp,BMP_List,;
Let>BMP_List={lower(%BMP_List%)}
Stringreplace>BMP_List,%Image_Dir%,,BMP_List
Separate>BMP_List,;,BMP

Dialog>Dialog1
   Caption=BMP_image
   Width=850
   Height=850
   Top=CENTER
   Left=CENTER
   Image=C:\nosuchfile,0,0,800,800,nextfile
EndDialog>Dialog1

Show>dialog1
GetWindowPos>BMP_image,Xpos,Ypos
Add>Xpos,%BorderOffset%
Add>Ypos,%TitleBarOffset%

GetDialogAction>dialog1,res1
//Top left quad
Let>X_1_1=Xpos
Let>y_1_1=Ypos
Let>X_1_2=%Xpos%+400
Let>Y_1_2=%Ypos%+400

//Top right quad
Let>X_2_1=%Xpos%+400
Let>y_2_1=Ypos
Let>X_2_2=%Xpos%+800
Let>Y_2_2=%Ypos%+400

//Bottom left quad
Let>X_3_1=Xpos
Let>y_3_1=%Ypos%+400
Let>X_3_2=%Xpos%+400
Let>Y_3_2=%Ypos%+800

//Bottom right quad
Let>X_4_1=%Xpos%+400
Let>y_4_1=%Ypos%+400
Let>X_4_2=%Xpos%+800
Let>Y_4_2=%Ypos%+800

VBSTART
VBEND
VBEval>timer,starttime
Let>kk=0
Repeat>kk
  Add>kk,1
  Let>value=BMP_%kk%
  Let>dialog1.nextfile=%Image_Dir%%value%
  StringReplace>%value%,.bmp,,newname
  ResetDialogAction>dialog1
  ScreenCapture>X_1_1,Y_1_1,X_1_2,Y_1_2,%400x400_dir%%newname%a.bmp
  ScreenCapture>X_2_1,Y_2_1,X_2_2,Y_2_2,%400x400_dir%%newname%b.bmp
  ScreenCapture>X_3_1,Y_3_1,X_3_2,Y_3_2,%400x400_dir%%newname%c.bmp
  ScreenCapture>X_4_1,Y_4_1,X_4_2,Y_4_2,%400x400_dir%%newname%d.bmp
Until>kk,BMP_count
VBEval>timer,endtime
Let>TotalTime=%endtime%-%starttime%
CloseDialog>dialog1

MDL>Complete%CRLF%%CRLF%The task took %TotalTime% seconds

sabre-150
Newbie
Posts: 18
Joined: Thu May 01, 2008 1:32 pm
Contact:

Post by sabre-150 » Thu May 01, 2008 5:38 pm

JRL,

Thank you for the above script, I will try a few lines at a time, I do have some questions already but will leave these for the time being and see if I can work some of the problems.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Thu May 01, 2008 5:51 pm

sabre-150 wrote:Not having much success at the moment, must be something simple that I'm doing wrong, would it be possible for someone to create and post a simple script with what I'm trying to do as above at least this will be a starting point and hopefully will start to get an understanding of it all.
It's much better if you post what you have written that isn't working, and then we can help you fix it.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Thu May 01, 2008 5:52 pm

Nice one Dick. You are truly the King of Dialogs :)

sabre-150
Newbie
Posts: 18
Joined: Thu May 01, 2008 1:32 pm
Contact:

Post by sabre-150 » Thu May 01, 2008 7:10 pm

I now have edited the script to suit what I think is correct and when I run the script all that happens is one Window that is approx 800 x 800 pixels and there is the Macro Scheduler icon in the top left with the name BMP_Image.

Would this be possible to get real time help using windows live and of course post any results on the forum.

I use both ICQ and Windows Live.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu May 01, 2008 7:22 pm

One thought. Could you make sure the source and target paths are entered in lower case.

sabre-150
Newbie
Posts: 18
Joined: Thu May 01, 2008 1:32 pm
Contact:

Post by sabre-150 » Thu May 01, 2008 7:29 pm

Yes, all the source and target paths are in lower case, the only difference is the path directory name does have a space like in the example below.

c:\scenery directory\scenery maps\

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu May 01, 2008 7:39 pm

Just tested with spaces in the path name and it works fine for me.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu May 01, 2008 10:33 pm

Here's a version of the same thing as above with a little less error risk. You select the directories rather than type them in. You still need to work with the border offset values at the top of the script.

Code: Select all

//These values need to be tested with your system
//Change them as needed to make the resulting
//images correct
Let>TitleBarOffset=23
Let>BorderOffset=4


Let>INPUT_BROWSE=2
Input>Image_Dir,Select the directory containing SOURCE images
If>Image_Dir=,EOF
Let>Image_Dir=%Image_Dir%\
Input>400x400_dir,Select the TARGET directory
If>400x400_dir=,EOF
Let>400x400_dir=%400x400_dir%\


Let>image_dir={lower(%image_dir%)}
Let>400x400_dir={lower(%400x400_dir%)}
GetFileList>%Image_Dir%*.bmp,BMP_List,;
Let>BMP_List={lower(%BMP_List%)}
Stringreplace>BMP_List,%Image_Dir%,,BMP_List
Separate>BMP_List,;,BMP

Dialog>Dialog1
   Caption=BMP_image
   Width=850
   Height=850
   Top=CENTER
   Left=CENTER
   Image=C:\nosuchfile,0,0,800,800,nextfile
EndDialog>Dialog1

Show>dialog1
GetWindowPos>BMP_image,Xpos,Ypos
Add>Xpos,%BorderOffset%
Add>Ypos,%TitleBarOffset%

//Top left quad
Let>X_1_1=Xpos
Let>y_1_1=Ypos
Let>X_1_2=%Xpos%+400
Let>Y_1_2=%Ypos%+400

//Top right quad
Let>X_2_1=%Xpos%+400
Let>y_2_1=Ypos
Let>X_2_2=%Xpos%+800
Let>Y_2_2=%Ypos%+400

//Bottom left quad
Let>X_3_1=Xpos
Let>y_3_1=%Ypos%+400
Let>X_3_2=%Xpos%+400
Let>Y_3_2=%Ypos%+800

//Bottom right quad
Let>X_4_1=%Xpos%+400
Let>y_4_1=%Ypos%+400
Let>X_4_2=%Xpos%+800
Let>Y_4_2=%Ypos%+800

VBSTART
VBEND
VBEval>timer,starttime
Let>kk=0
Repeat>kk
  Add>kk,1
  GetDialogAction>dialog1,res1
  If>res1=2,EOF
  Let>value=BMP_%kk%
  Let>dialog1.nextfile=%Image_Dir%%value%
  StringReplace>%value%,.bmp,,newname
  ResetDialogAction>dialog1
  ScreenCapture>X_1_1,Y_1_1,X_1_2,Y_1_2,%400x400_dir%%newname%a.bmp
  ScreenCapture>X_2_1,Y_2_1,X_2_2,Y_2_2,%400x400_dir%%newname%b.bmp
  ScreenCapture>X_3_1,Y_3_1,X_3_2,Y_3_2,%400x400_dir%%newname%c.bmp
  ScreenCapture>X_4_1,Y_4_1,X_4_2,Y_4_2,%400x400_dir%%newname%d.bmp
Until>kk,BMP_count
VBEval>timer,endtime
Let>TotalTime=%endtime%-%starttime%
CloseDialog>dialog1

MDL>Complete%CRLF%%CRLF%The task took %TotalTime% seconds

Label>EOF

sabre-150
Newbie
Posts: 18
Joined: Thu May 01, 2008 1:32 pm
Contact:

Post by sabre-150 » Fri May 02, 2008 6:55 pm

Here are my results of what has happened so far.

The top script I had run and all that I see on my sesktop screen was a window that was approx 850 x 850 pixels in size and nothing else seems to have happened, the window that did appear was grey with nothing in it.

In my source directory there were the following files with numbers

Layer_D1.bmp
Layer_D2.bmp
Layer_D3.bmp
Layer_D4.bmp ........... to Layer_D157

Layer_P1.bmp
Layer_P2.bmp
Layer_P3.bmp
Layer_P4.bmp ........... to Layer_P157

A total of 314 bitmaps, would there be a problem as there is one file called
Layer_D1.bmp and another called Layer_P1.bmp the only difference here is the letter could this cause a problem, what I may have to do is just have one directory with bitmaps Layer_D1 yo Layer_D157 and another directory with bitmaps Layer_P1 to Layer_P157

What I did not check was the directory 400_x_400 that I had created earlier, inside this directory contained the following files.

There was a total of 28501 bitmap with each bitmap being 626kb in size and the size of each bitmap is 400 x 400 pixels as I would expect, making a total of just over 18GB of bitmap data, this I did not expect.

There was a total of 314 bitmaps in my source directory, times this by 4 which gives a total of 1256 these should be 400 x 400 pixels.

What I'm doing now is to delete the 400_x_400 directory then create another one this time being empty and will then use the script at the bottom of this post and will then check my results.

One thing I can't understand at the moment is why the window that did appear was blank with a grey colour.

Anyway this time I hope to get some better results and will post my findings here.

sabre-150
Newbie
Posts: 18
Joined: Thu May 01, 2008 1:32 pm
Contact:

Post by sabre-150 » Fri May 02, 2008 6:59 pm

//These values need to be tested with your system
//Change them as needed to make the resulting
//images correct
Let>TitleBarOffset=23
Let>BorderOffset=4


Let>INPUT_BROWSE=2
Input>Image_Dir,Select the directory containing SOURCE images
If>Image_Dir=,EOF
Let>Image_Dir=%Image_Dir%\
Input>400x400_dir,Select the TARGET directory
If>400x400_dir=,EOF
Let>400x400_dir=%400x400_dir%\


Everything in the above script so far works well, with no problems at all, I'm now adding a few more line of the script.

sabre-150
Newbie
Posts: 18
Joined: Thu May 01, 2008 1:32 pm
Contact:

Post by sabre-150 » Fri May 02, 2008 7:08 pm

My only other question that I have at the moment is, part of the script below:

Let>TitleBarOffset=23
Let>BorderOffset=4

What values would I need to change and and by how much, what is the max and min values, my desktop is set to 1600 x 1200 pixels if this helps in anyway.

Do these values need to be right for the rest of the script to work, just not sure what the correct values I should have and how to correct these.

sabre-150
Newbie
Posts: 18
Joined: Thu May 01, 2008 1:32 pm
Contact:

Post by sabre-150 » Fri May 02, 2008 7:29 pm

Image=C:\nosuchfile,0,0,800,800,nextfile

The script line above, what does this do and what will I need to change to suit my system?

I see in the above example it's looking at the C:\ drive

sabre-150
Newbie
Posts: 18
Joined: Thu May 01, 2008 1:32 pm
Contact:

Post by sabre-150 » Fri May 02, 2008 7:52 pm

Very good news, the script now works and creates the correct number of smaller bitmaps, the only difference is on some of the smaller bitamps you can see some of the blue title bar, will I need to adjust the values of the script below to stop the title bar appearing in some of the bitamps.

Let>TitleBarOffset=23
Let>BorderOffset=4

May I ask why does the some of the title bar appear in some of the bitmaps but not all of them.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri May 02, 2008 8:11 pm

If some the title bar appears in some of the images, then I might guess that the dialog got moved slightly during processing. Currently the dialog position is captured once at the start of the script, if the dialog is moved the screen captures will be capturing incorrectly. The script could be rewritten to check the dialog position each image but that would increase the total time to process. Far easier to simply keep away from the mouse and keyboard while the process is running.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts