# Newbie trying to learn batch files...



## phantom1975 (May 2, 2007)

I thought what I am trying to do is relatively easy, but I can't find a thing anywhere on the internet to help me out here.  I'm looking for an answer and possibly a forum that rocks the house like this one for my silly batch file.

Several times a day at work, my reps have to do a screen print.  So they hit their printscreen button, open WordPad, paste it, and print.  Should be easy enough to automate this.  Now I know that there are a billion freeware titles out there, but as usual, nothing can be installed on these computers.  I have been able to get far enough in a batch file to get WordPad open.  I don't know how to paste the contents of the clipboard into the new open document.  It would really be nice if the print window opened immediately after the paste.  So those of you that are familiar with this, please stop laughing at me and point me in the right direction.  I have nothing to offer buy some stale Skittles that are under my couch cushions and my undying affection.


----------



## Thorin (May 2, 2007)

You could try the following forum who have a MS DOS forum that may be able to help you :-

http://www.computerhope.com/forum/


----------



## litrelord (May 2, 2007)

As far as I know there isn’t a native way to emulate pressing print screen either with batch files or vbscript. I tried something similar before and had no luck. The only way I could see was to use VB but if you had that there wouldn’t be a problem.

Maybe you could get it down to two buttons? Print screen then a further button to print it out.


Do you use word?

If so you could try using an auto_open macro in that to either handle an argument that you provide on the command line (if you can do that with word – I don’t know) or alternatively create a dummy file that word uses as a flag to show that there’s a picture in the clipboard. So:

-Press print screen
-Call a batch file/vbs file that you have a shortcut to on the start menu with a keyboard shortcut assigned
-Scipt/Batch creates dummy file in set location (e.g. empty text file called “screen-grab.txt”)
-Word auto-open macro looks in specified location for that file
-Word can then paste from the clipboard and print (adjusting margins if necessary)
-Word deletes the dummy text file and closes itself

You’d probably want a folder for each user or save it somewhere on their local drive to save confusion/overwriting.

That’s the only way I can think of doing it although I’m sure someone with a bit more nouse will come along and correct me.

Hope this helps

Nick


----------



## Thorin (May 3, 2007)

The following link will list the DOS batch commands, have a look at the GRAPHICS command, this one provides a way to print contents of a graphics screen display.

http://www.csulb.edu/~murdock/dosindex.html


----------



## Greg Truby (May 3, 2007)

> ...Several times a day at work, my reps have to do a screen print.  So they hit their printscreen button, open WordPad, paste it, and print...
> ~Phantom1975



OK - I'll bite since I'm curious.  What's going on that a MrExcel MVP can't figure sumpin' better'n automating a process that, at least on the surface, seems wicked inefficient?


----------



## iknowu99 (May 10, 2007)

Isn't there a "SendKeys" command?


----------



## litrelord (May 14, 2007)

> Isn't there a "SendKeys" command?



There is but it doesn't work. Or possibly it just doesn't work outside of the application that uses it. 

Unless someone can prove me wrong which would be nice.

Nick


----------



## phantom1975 (May 14, 2007)

> > ...Several times a day at work, my reps have to do a screen print.  So they hit their printscreen button, open WordPad, paste it, and print...
> > ~Phantom1975
> 
> 
> ...



I just KNEW someone would ask.  There are approx. 120 workstations that have very limited software on them and they cannot download any software.  A Word or Excel macro would do the job just perfectly, but aren't available.  So I have to stick with what comes stocked with Windows.

I am trying to do this for two reasons.  First, I will pull out whatever remaining hair I have if I have one more person tell me they just don't understand how to do the screen print.  The second is that I never got around to learning DOS and I figure that I could come up with some practical uses for batch files if I knew how to write them.

Besides, I have to find a new forum to be the newbie that asks too many questions.


----------



## phantom1975 (May 14, 2007)

> > Isn't there a "SendKeys" command?
> 
> 
> 
> ...



Every search that I have done indicates that you have to use a special program to use SendKeys.


----------



## Greg Truby (May 14, 2007)

Billy,

If the machines have WScript or CScript (and I will be shocked if they don't).  Then I would think you could adapt the sample script here.

I'm afraid I haven't the time do try it myself (though I'm itchin' to).  But I think the main challenge will lie in getting a handle on the window you want to printscreen and doing a SENDKEYS that does the printscreen of the desired application.  I don't know if SCRIPT offers direct access to the clipboard or if you'd have to try a SendKeys "^V" or something.

Best of luck,


----------



## iknowu99 (May 14, 2007)

I have a rough idea of how sendkeys works perhaps this can act as a guide:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1587306&SiteID=1


----------



## litrelord (May 14, 2007)

To be honest the {PRTSC} command with sendkeys never worked for me. 

Hopefully you'll have more luck but as an example, typing 

sendkeys "{PRTSC}", true

into the immediate window in the VBE and pressing enter doesn't copy anything to the clipboard which is what I'd expect if it was emulating pressing the Print screen button.

Nick


----------



## Greg Truby (May 14, 2007)

> To be honest the {PRTSC} command with sendkeys never worked for me.
> 
> Hopefully you'll have more luck but as an example, typing
> 
> ...



I just popped into the VBE and tried it in one line subroutine and no luck either.  Don't have time to test in SCRIPTing.  But not looking very promising, is it?


----------



## litrelord (May 14, 2007)

No, didn't work in vbscript either when I tried. You should be able to do it with an API call, I saw a site for it that was showing you how to do that in VB so I assume that's transferrable to VBA. 

Unfortunately you cant use API calls in VB script otherwise that solution would have worked and I can't remember the page where I found it to check it in VBA. I'm assuming that it's not an office product this is being called from anyway otherwise batch files wouldn't be necessary.

Annoying not having a solution to this one.


----------



## Ivan F Moala (May 14, 2007)

> I thought what I am trying to do is relatively easy, but I can't find a thing anywhere on the internet to help me out here.  I'm looking for an answer and possibly a forum that rocks the house like this one for my silly batch file.
> 
> Several times a day at work, my reps have to do a screen print.  So they hit their printscreen button, open WordPad, paste it, and print.  Should be easy enough to automate this.  Now I know that there are a billion freeware titles out there, but as usual, nothing can be installed on these computers.  I have been able to get far enough in a batch file to get WordPad open.  I don't know how to paste the contents of the clipboard into the new open document.  It would really be nice if the print window opened immediately after the paste.  So those of you that are familiar with this, please stop laughing at me and point me in the right direction.  I have nothing to offer buy some stale Skittles that are under my couch cushions and my undying affection.



Billy, what applications do your workers have avail. to them ??
MS OFFICE ??
What is the Application that they open
What scripting code do you currently have ?


----------



## Zack Barresse (May 15, 2007)

Hi Billy, cute kid!

Anything wrong with running a VBS file?  You could even set it up to run like a batch file with windows scheduler.  This might help..

http://tinyurl.com/3djwn2

Note to run VBS files you must have Windows Scripting Host installed (generally installed with all Windows, 2000 and up, not sure about 98 or NT, also works with Windows Server 2003).


----------



## litrelord (May 15, 2007)

> Anything wrong with running a VBS file?



But how do you do the screen print with a vbs file?


----------



## Greg Truby (May 15, 2007)

> But how do you do the screen print with a vbs file?
> ~Nick



Thanks, Nick.  I thought I was the only dummy in the group.  That URL Zack X-refs uses Excel.; which Billy says ain't in the toolbox.  But I think we're probably at an impasse until Billy shows up and answers Ivan's questions.  

BTW, Ivan, thanks for stoppin' by.  I think that if these machines had any Office Apps, Billy would be looking to use VBA.  Since he's using something as rudimentary as WordPad, I'm guessing there are no Office apps on them.  No clue what's that app that's actually the active window during the PrintScreening, though.


----------



## Zack Barresse (May 15, 2007)

Hmm, I guess that begs the question: Is Office installed on these machines?  What is their OS?  Do they have admin privileges?


----------



## Ivan F Moala (May 15, 2007)

Thanks Greg, I guess we need to wait for Billy.

Billy - Do you have IE


----------



## phantom1975 (May 16, 2007)

Wowza!  No Office applications at all!  In fact, they have to use Webmail because the IT department doesn't want anything on their PCs.  I've got to use crappy stinkin' Lotus Notes!!  Windows apps is it.  Notepad or Wordpad.  I suppose they could use Paint to paste the image, but I don't think I can get anywhere any faster with Paint than I can with Wordpad.  I've already created a beautiful Word document that does the job nicely.  But since Notepad opens the file, the macro does zilch.

It wouldn't be such a big deal, but since turnover is high and computer compentancy is low, I've got to come up with a one-button solution.

On a side note:



*Chuck Norris does not sleep. He waits.


Chuck Norris once visited the Virgin Islands. They are now The Islands.


Chuck Norris does not hunt because the word hunting implies the probability of failure. Chuck Norris goes killing.


Chuck Norris' tears cure cancer. Too bad he has never cried.


When the Boogeyman goes to sleep every night he checks his closet for Chuck Norris.


Chuck Norris counted to infinity - twice.


Chuck Noris puts the "laughter" in "manslaughter".*


----------



## iknowu99 (May 18, 2007)

the jokes are funny! how about what happened to the solution?!


----------



## Oaktree (May 18, 2007)

Hiya, Phantom. 

You might appreciate these Chuck Norris threads:

http://www.mrexcel.com/board2/viewtopic.php?t=189040

http://www.mrexcel.com/board2/viewtopic.php?t=199768


----------



## phantom1975 (May 20, 2007)

> the jokes are funny! how about what happened to the solution?!



I made a Word document that does what I need perfectly.  Until I get everyone using it, I will just have to make a nice little instruction manual with lots of pictures in it.


----------



## phantom1975 (May 20, 2007)

> Hiya, Phantom.
> 
> You might appreciate these Chuck Norris threads:
> 
> ...



Holy crap!  That second link about Aladin is priceless.  I'm racking my brain with ways to keep that thread going.


----------



## Hatcheda (May 25, 2007)

FYI I have read somewhere, microsoft help, I believe, that you can not sendkeys for printscreen.  -Possibly a hardware interupt like ctrl+alt+delete?


----------

