Printing to Network Printer - no dialoge box
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Printing to Network Printer - no dialoge box
Hello, I making an app with the goal to print multiple templates in livecode. I made one with macro program before where it could print to designated network label printer (thru app) without installing it and dialog boxes.
Some that code was as so:
SelectedPrinter = idkwvmwprn003\HL65
Run, print.exe /D:\\%SelectedPrinter% "%LocalUser%\Output.txt",,Hide
Can I simulate this in livecode as I can't rely on users installing the designated printers prior to app use? I would like to get away putting in an text file and move to where the print the card or whatever you recommend.
Thanks for any help.
Some that code was as so:
SelectedPrinter = idkwvmwprn003\HL65
Run, print.exe /D:\\%SelectedPrinter% "%LocalUser%\Output.txt",,Hide
Can I simulate this in livecode as I can't rely on users installing the designated printers prior to app use? I would like to get away putting in an text file and move to where the print the card or whatever you recommend.
Thanks for any help.
Re: Printing to Network Printer - no dialoge box
Hello, any idea on this one?
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Printing to Network Printer - no dialoge box
See the open printing command in the Dictionary, which includes an option for showing the print job dialog.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Printing to Network Printer - no dialoge box
Thank you FourthWorld. I wanted to push to the printer without opening the dialogue box actually, like I could in hotkey basically.
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Printing to Network Printer - no dialoge box
Hmmm.., The print command should normally send to the currently-selected printer without a dialog unless the dialog option is included in the open printing statement.
Is it possible the system did not register that a printer has already been selected, or that it may have changed?
Might be worth a bug report to see how the team views this. Unless the OS now prohibits silent printing, we should expect control over whether the dialog is shown or not.
Is it possible the system did not register that a printer has already been selected, or that it may have changed?
Might be worth a bug report to see how the team views this. Unless the OS now prohibits silent printing, we should expect control over whether the dialog is shown or not.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Printing to Network Printer - no dialoge box
Ok, I tested the print command for my network printer with the following, but it always select my local printer. Any trick to this? Perhaps I am using wrong command to set printer? Something to note, I do not want the end user to install the printer. Similar to how hotkey could print to any printer on network.
Thanks
Code: Select all
on mouseUp
set the printerName to "idkwvmwprn003\HL65"
print card 1
end mouseUp
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Printing to Network Printer - no dialoge box
How is Hotkey configured?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Printing to Network Printer - no dialoge box
The code is in first post, not any additional configuration code. Is there a way to specify the server address to the network printer in LiveCode?
Re: Printing to Network Printer - no dialoge box
Hello, if anyone knows how to route to a network printer I took another look and found the full address of network printer is as so:
I was really hoping to get this working today if possible, any help would be appreciated. thanks.
Code: Select all
idkwvmwprn003.WROK.NET\HL65
Re: Printing to Network Printer - no dialoge box
I don't know, and can't test, but maybe add double backslashes before the printer name, so you are calling it by unc path?
Re: Printing to Network Printer - no dialoge box
Thank you SparkOut for your post. I tried the below with no success. It seems to always go to my default printer I noticed.
Code: Select all
on mouseUp
set the printerName to "idkwvmwprn003\\HL65"
print card 1
end mouseUp
Code: Select all
on mouseUp
set the printerName to "idkwvmwprn003.WROK.NET\\HL65"
print card 1
end mouseUp
Re: Printing to Network Printer - no dialoge box
I meant \\ before the hostname for the printer, thus:
set the printerName to "\\idkwvmwprn003\HL65"
set the printerName to "\\idkwvmwprn003\HL65"
Re: Printing to Network Printer - no dialoge box
I can't test properly but there is some magic that can be done with LiveCode using vbscript, so you may be able to test and tweak and adjust the scripts below to achieve something like what you need.
Say you have a button with the following script
The buttons should have custom properties containing the following vbscripts as their values:
cGetDefaultPrinter property should contain
cSetNetworkPrinter property should contain
Say you have a button with the following script
Code: Select all
on mouseUp
--first let's find what printer is currently set as default so that we can
--override the default and then put it back again afterwards
put the cGetDefaultPrinter of me into tVBScript
do tVBScript as "vbscript"
put the result into tResult
--answer "The current default printer is" && tResult
set the cStoredDefaultPrinter of me to tResult
--now we have saved the current default printer, let's override it with the networked one
--we get the VBScript which contains placeholder
put the cSetNetworkPrinter of me into tVBScript
--this is the hardcoded UNC path to the chosen printer
put "\\idkwvmwprn003\HL65" into tPrinterName
--replace the placeholder with the correct printer name
replace "<~%printernameGoesHere%~>" with tPrinterName in tVBScript
do tVBScript as "vbscript"
put the result into tResult
if tResult is not empty then
answer "Something went wrong:" && tResult
--you should handle errors more gracefully than this
exit to top
end if
--try your printing
print card 1
--now we can set the original printer back as default
put the cSetNetworkPrinter of me into tVBScript
--we got the script with placeholder back
put the cStoredDefaultPrinter of me into tPrinterName
--replace the placeholder with the correct printer name stored from before
replace "<~%printernameGoesHere%~>" with tPrinterName in tVBScript
do tVBScript as "vbscript"
put the result into tResult
if tResult is not empty then
answer "Something went wrong:" && tResult
--you should handle errors more gracefully than this
end if
end mouseUp
cGetDefaultPrinter property should contain
Code: Select all
Set oShell = CreateObject("WScript.Shell")
strValue = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
strPrinter = oShell.RegRead(strValue)
strPrinter = Split(strPrinter, ",")(0)
result = strPrinter
Code: Select all
Option Explicit
On Error Resume Next
Dim objNetwork, strUNCPrinter,strError,result
strUNCPrinter = "<~%printernameGoesHere%~>"
Set objNetwork = CreateObject("WScript.Network")
Set objAdd = objNetwork.AddWindowsPrinterConnection(strUNCPrinter)
If Not objAdd Then
strError = "Error connecting printer"
Else
objNetwork.SetDefaultPrinter strUNCPrinter
strError = ""
End If
objNetwork = Nothing
objAdd = Nothing
result = strError
Re: Printing to Network Printer - no dialoge box
Thank you SparkOut. My results of using \\ in front did not work, and Livecode still seem to only want to send to the default installed printer.
I saw your second post here, I will test with this now. Thanks again.
I saw your second post here, I will test with this now. Thanks again.
Re: Printing to Network Printer - no dialoge box
Hello SparkOut, I setup the button as described and it does put my default printer in the cStoredDefaultPrinter custom property. Unfortunately it gives me error "Something went wrong: Error connecting printer" fyi. Wanted to let you know.
I also wanted to make sure i was doing it correctly. When you state something like this
strUNCPrinter = "<~%printernameGoesHere%~>"
you want something to this effect:
strUNCPrinter = "<~%HL65%~>"
Thx
I also wanted to make sure i was doing it correctly. When you state something like this
strUNCPrinter = "<~%printernameGoesHere%~>"
you want something to this effect:
strUNCPrinter = "<~%HL65%~>"
Thx