All Things WinBatch > WinBatch

Strange action with scripts opening/pasting image files

(1/3) > >>

Garry:
I'm having some strange actions with scripts opening/pasting image files.

The winbatch script basically runs paint with a selected file and uses sekeys to automatically paste another image onto the existing image.

The first time the script runs there is a few second delay before the image is pasted.
The second time it has no delay and pastes immediately. Then it will paste it with no delay for subsequent runs.

As soon as a different  file is selected to paste the image to it has the delay the first time but not in subsequent runs.

It's driving me nuts. I can preform the same functions manually once the image is up and there's no delay pasting an image on top but the script using the sekeys to do it causes the delay for the first run.

Anyone had this problem?

I've made sure the paths for the image files are set properly and there's no delay with the script bringing up the original image to be pasted to.

I'm extremely confused. I tried putting extra time delays between the sekey sends but it makes no difference, it just adds more delay.
Of course I have to use a bit of delay after the sekey line where the image filename is sent to be opened to paste so the name has time to be sent.

Strange part is there is no delay the second time the script is run until a different original image is chosen. Then there is a delay in the first run again.

td:
This is just a guess and you didn't indicate which version of Windows you are using but there are several bugs in the Windows 10/11 graphic shell that can cause random delays when accessing files.  Windows Defender can also cause strange delays when an application first starts accessing files. These Windows bugs have been widely reported but never addressed by MSFT.

kdmoyers:
Garry,

I know this pain. Timing sendkeys feels like an invisible crazy monkey is screwing with you.  You try to code around it, add padding and conditions, but the problems just move around.  Infuriating.

I don't know anything about your specific situation (automating paint), but if it were me, I'd look into moving as many program functions as possible away from the automate-3rd-program-via-keystrokes method.  Even when I have had partial success, the pain just doesn't stop.

So, over the years, I've learned to look pretty hard for more direct ways to solve the problem. 
It's not less trouble, just less insanity inducing.

Have you looked into using ImageMagick?  https://imagemagick.org/script/command-line-processing.php
I've had good success with executing command lines to do what I need.

Also, other folks have used ImageMagick via OLE
https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/ImageMagick+!!~ImageMagickObject~COM~Object~~!!.txt

Good luck!!

just my $0.02
-Kirby

JTaylor:
Don't know if you it will do what you need but the Omnibus Extender will overlay images.  Look for the imOverlay() function under the Images section.
   
    http://www.jtdata.com/anonymous/wbomnibus.zip


Jim

Garry:
I'm using windows 10 64 bit. I use ESET  for security and windows defender is not running.

I have similar problems with opening the first couple of file in Piximillion Image converter which I use a winbatch script using sendkeys to convert a list of PCX files into one PDF file.

It looks like it's not opening any files but after 3 or more files they all show up at one time, so some strange thing is causing a delay.

From the replies so far I'm thinking it may be a MS bug

(I mentioned sekeys in my initial post which is an Autocad key mapping program, I meant to say sendkeys)

The MSpaint program isn't just being used for automated pasting in the script. The script has 8 different functions all of which work very fast with no problems such as cropping, auto resizing  or adding various labels. First it puts up an "Always on top" Winbatch box with 8 buttons for doing various things. It also saves the file with a Finished button or exits with no save with an Exit button so there's really no other software small and fast enough for doing all the things I want. Gimp is much too slow and clumsy but a great editor for more complex editing.

It's just the first time I paste an image that's delayed. If I paste it first time manually it's immediate. I can paste the same image or other images using the script buttons after and they go in immediately. All the other script functions execute immediately first time or subsequent times. It's more of an annoyance than a problem but I'd like to find out what's causing it so I can make it work better.

Navigation

[0] Message Index

[#] Next page

Go to full version