stuj1026 Posted September 30, 2005 Posted September 30, 2005 Hi All looking for a definative answer to this one. I have 2 printers and am trying to have my scripts remember which printer i want to goto. Seems filemaker cannot retain the printer choice within my scripts no matter what i do! Is this a bug? Stu
dkemme Posted October 1, 2005 Posted October 1, 2005 (edited) Check out this discussion, I have an example database on my 8/31 post to show one solution. http://fmforums.com/forum/showtopic.php?tid/140842/ Edited October 1, 2005 by Guest
SlimJim Posted October 1, 2005 Posted October 1, 2005 I think the solutions here are Mac specific (if I am wrong please correct me) whereas Stu is using Windows XP. The answer is that FMP cannot change or retain the printer setting within a script. To get around this you have to use an operating system script. In MacOS Applescript is a method, in Windows there are choices. If you are familiar with VBScript (which I am not) then I would guess that you can use that to change the printer. Personally I use AutoItv3, and its ability to send characters to a dialog box, to select printer etc. I am attaching an annotated AutoIt script. This method is only suitable on one computer. If you are going to use this on multiple computers the you would probably have to provide a script for each one to take account of local printer names. Printscript.zip
dkemme Posted October 1, 2005 Posted October 1, 2005 Another option to a script for each machine is to have a table with a record for each machine that stores the printer information. Then have the script use that record's feilds to set to needed printers.
SlimJim Posted October 1, 2005 Posted October 1, 2005 Yes that's an excellent idea. I pass the printer names and other settings via a script parameter which can be calculated and a table would allow the FMP scripts to be machine independent - just one setting to specify the machine.
stuj1026 Posted October 2, 2005 Author Posted October 2, 2005 Thats really a great idea but i don't follow.. could you giv me an example. I have 2 reports that have to be printed from table "a" 1 has to goto my laserjet and 1 has to goto my inkjet. without moving 1 of those reports to a different table how do i choose my printer. I could really use the details of this.. Thanks for your help Stu
SlimJim Posted October 2, 2005 Posted October 2, 2005 Stu I am attaching an fp7 file together with a compiled autoit script to demonstrate the use of autoit to change printers. When you unzip the file I would suggest moving Printscript.exe to the root of a hard disk and you will then need to change the driveletter in the Send Event step in the filemaker "Print" script (currently E as in E:Printscript.exe)to match your drive letter. The rest of the file is simply a page of instructions to print off in one of two named printers. ChangePrinterTest.zip
Furball Posted October 19, 2005 Posted October 19, 2005 I had done that part, but your AU3 script ifs perfect. It works great every time. Attached is a small file that has a config script that sets up the printers for your script. It works on XP with FM8A. Is there a way to hide the printer dialog from the user while the printer is changing? ChgPtrs.ZIP
SlimJim Posted October 19, 2005 Posted October 19, 2005 That's very neat. With regard to your questio about the printer dialog box - I don't know. The method I'm using with AutoIt needs the dialog box on the screen but there may be other methods which do not. I have made a few minor alterations to my original Printscript.au3 which basically are that before Sending data I activate the print Dialog window. I found this to be necessary when running more than one program. If I make the other program window active in the middle of the script then the Sends go to that window - with somewhat unpredictable results. Attached: updated versions PrintScript.zip
Furball Posted October 19, 2005 Posted October 19, 2005 I'm re doint my script also. Right now it only displays the first letter of the printer name, which works fine with yuor script, but not for users. I'll have the new one report the name, then have the Send Event step get only Left,1 for your AutoIt script step. Thanks for your help. This works better than the plug in's I've tried, and avoids the issue of limited permissions on the users computers (they can't change registry settings, so many of the plug ins won' work)
SlimJim Posted October 20, 2005 Posted October 20, 2005 You can send the full name to the print dialog if you wish. You do have to be careful with spaces in the name because AutoIt uses space as a delimiter in the comman line options. I used the initial letters because it was easier fr me to put parameters into print scripts in FMP using only one letter.
Furball Posted October 20, 2005 Posted October 20, 2005 It was easy to get readable names and then get the first, or first two letters of the printers, just to keep things simple. Another idea for you, I modified the PrintScript.au3 to work with the print setup box. That way I can return the application back to the default printer at the end of a session without printing. FM8 will hold the printer unlike 7, and that works better for my purposes. I can also set the printer at the beginning of a script that prints multiple layouts, and then Print (no dialog) for the rest. I'm mainly creating PDF's (sales reports) and emailing them, or emailing sales orders, so I can default to 1 copy. Thanks for all of your help, and ideas. My problem is solved.
Furball Posted October 20, 2005 Posted October 20, 2005 Well, I guess I didn't figure it out. Can you help with a Print Setup script (autoit) that will wait for the print setup window, then change the printer? I wrote the script, but it works with only one parameter.
SlimJim Posted October 20, 2005 Posted October 20, 2005 I am enclosing a script and the compiled script, which should do the job. I haven't tested this one throughly but is is basically the same as the PrintScript with changes to account for the different dialog box and a single parameter. PrintSetup.zip
Furball Posted October 20, 2005 Posted October 20, 2005 Thanks, I greatly appreciate it. I've been trying plug-ins for several months, and none worked as well as your solution.
Furball Posted October 21, 2005 Posted October 21, 2005 You seem to know AutoIt really well, and this is not a true filemaker question, but perhaps you can help. I'm setting up my FM DB to use a credit card swipe for input. It is a keyboard emulation. I have the script all written and called by a AutoHotKey script, but I'm having a timing problem. The Mag Stripe reader sends the macro code (F10 key), then the card info to the macro. The macro sends the Ctrl-S keystroke to FM which calls the script, but there are some characters lost due to timing. I need to build in a pause so that the script is called, .5 sec pause, then send the data. Any Ideas?
SlimJim Posted October 21, 2005 Posted October 21, 2005 I'm not familiar with AutoHotKey but I believe it is a derivative of AutoIt. There is a command in AutoIt which pauses - Sleep(500) would pause a script for 500 millisecond giving you your .5 second pause. If you were to insert this after sending the Ctrl-S to FMP that should give the FMP script time to start up.
Furball Posted October 21, 2005 Posted October 21, 2005 It uses the same commands as AutoIt, and there are several sleep type commands. I tried Sleep, but I fear that I need to build the sleep into the card scanner output. Once the card is scanned, it sends the HotKey and then the data immediately. The result is that I lose about the first three characters of the data, while FMP is starting the script. Thanks again
SlimJim Posted October 22, 2005 Posted October 22, 2005 The only thing that comes to mind is to get the AutoHotKey script to gather the data and put it on the clipboard, sleep and then get it back off the clipboard and send it to FMP. I have to say I have not done this but I know the ClipPut and ClipGet commands are in place in AutoIt.
Recommended Posts
This topic is 6964 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now