Ooops
November 24, 2020, 06:56:38 AM

Author Topic: [bb] Print an image by Kuron [ 1+ years ago ]  (Read 753 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Print an image by Kuron [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : Print an image
Author : Kuron
Posted : 1+ years ago

Description : If you just need to print a simple image that will fit on a normal sized piece of paper, you do not need to use a DLL or API calls.

MS Paint allows command line options. You can run MS Paint from the command line with the Print switch and it will print the image directly to the default printer without opening MS Paint.

You need to grab the directory for MS Paint (system/system32, etc) and grab the directory that the image you want to print is in and the file name, then add the "/p" switch.


Code :
Code: BlitzBasic
  1. ExecFile ("c:windowssystem32mspaint.exe c:      ik.bmp /p")


Comments :


Pedro(Posted 1+ years ago)

 shorter !
Code: [Select]
ExecFile "c: ik.bmp"
Automatically windows find the program linked to bmp extansion and open it => it is like a double click on the file.Works with all the files ...


Mystik(Posted 1+ years ago)

 <div class="quote">  shorter !ExecFile "c:   ik.bmp" Automatically windows find the program linked to bmp extansion and open it => it is like a double click on the file.Works with all the files ... </div>The first example prints the picture by opening mspaint in the background. Your shorter one just loads the picture into whatever program is currently associated with .bmpSteve.


zcbeaton(Posted 1+ years ago)

 Clever. I'd never have suspected it.But, Pedro, yeah, that only opens the file, it doesn't actually print it.


xlsior(Posted 1+ years ago)

 Major problem: Many, MANY systems don't store mspaint.exe in the c:windowssystem32 folder.Probably about a 3rd of the windows installs out there are in c:winnt , for starters.In addition windows doesn't even need to be installed on C:, it can be any driver letter...You can do some damage control, and increase the chances of it being correct by calling it like this:
Code: [Select]
ExecFile (GetEnv$("windir")+"system32mspaint.exe c: ik.bmp /p")You really ought to make sure that the mspaint.exe program even exists though, because it won't always be present either.


OJay(Posted 1+ years ago)

 or even simpler:
Code: [Select]
ExecFile ("mspaint.exe c: ik.bmp /p"))


Kuron(Posted 1+ years ago)

 <div class="quote"> Major problem: Many, MANY systems don't store mspaint.exe in the c:windowssystem32 folder. </div>Duh, thats why I said:
Code: [Select]
You need to grab the directory for MS Paint (system/system32, etc) and grab the directory that the image you want to print is in and the file name, then add the "/p" switch.Because MS Paint is not always in the same location and is not always installed.  Use error checking when you grab the location for MS Paint.  If MS Paint doesn't exist, then don't print the image ;c)


Bobysait(Posted 1+ years ago)

 maybe a simple function like
Code: [Select]

Function MSPaint_Print(file$)
App_Dir$=SystemProperty("systemdir")+"mspaint.exe"
If FileType(app_dir)=1
ExecFile( App_Dir+file+"/p")
Return True
Else
Return False
EndIf
End
could solve the problem.


ThePict(Posted 1+ years ago)

 Would the same thing work with Notepad for printing text or ASCII files?


ShadowTurtle(Posted 1+ years ago)

 you can save the text as bitmap and run the MSPaint_Print function :)


Serpent(Posted 1+ years ago)

 zombie thread :PI'm not sure if something like notepad would accept the '/p' switch in its command-line arguments and actually print a text file...


_PJ_(Posted 1+ years ago)

 Notepad doesn't print here on XP when I use the /p switch. [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal