打印机自动化问题 [英] Printer automation problem

查看:82
本文介绍了打印机自动化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过VB6将多个文档转换为pdf。文档由vb6从数据库创建并插入到我使用pdf打印机打印到文件夹的报告中。



当我打印文件时我想移动它并将其重命名为正确的文件名。完成了代码完成。



我有一个问题,文件没有打印得足够快,这意味着我试图移动一个尚不存在的文件。我试图睡觉我的程序,但这没有帮助,似乎打印是在与程序或其他东西相同的线程中完成的。



我已经出现了在我的头脑中有几个工作但他们都有自己的问题。一个是如果我以不同的方式命名文件,那么我可以打印一个文件,获取数据并开始打印下一个文件,然后移回第一个文件并进行移动和重命名。基本上一直跟踪一个打印作业。但这不是一个问题,因为一个问题是我无法发送一个我想要文件名的参数。我使用的Bullzip似乎将窗口名称作为文件名,例如从记事本打印创建一个名为notepad的文件 - openfile.pdf



我的文件被命名为MSDataReport。 PDF格式。我很好奇我是否可以通过使用windows api获取窗口来使这种方法可用?



到目前为止,最佳结果是添加了一个简单的msgbox弹出,然后使用定时自动点击器等待几秒钟,然后按确定。似乎消息框不会像睡眠一样阻止打印。这种方法存在风险,并且会在一段时间内锁定我的电脑,因此它也不是最佳状态,但至少它可以节省大量的手工劳动。



我对什么的想法可以做?要么改进我自己的解决方案或其他方法来解决这个问题?

I'm trying to convert several documents to pdf via VB6. The documents are created by vb6 from a database and inserted into a report which I print using a pdf printer to a folder.

When I print a file I wish to move it and rename it to the correct filename. Got the code done to do so.

I've got a problem where the file isn't "printed" quick enough meaning I try to move a file which doesn't yet exist. I tried to sleep my program but that doesn't help, it seems the printing is done in the same thread as the program or something.

I've come up with several work arounds in my head but they all got their own problem. One was if I named the file differently then I could print one file, get the data and start printing the next one and then move back to the first one and do a move and rename. Basically trailing one print job all the time. But that is a no go atm because one problem is that I cant send an argument with what I want the filename to be. Bullzip which I use seems to take a window name as the filename, eg printing from notepad creates a file called notepad - openfile.pdf

My files gets named as MSDataReport.pdf. I'm curious if I can make this approach usable by getting the window using windows api?

The "best" results so far have been by adding a plain msgbox which pops up and then use a timed auto clicker to wait a few seconds and then press ok. It seems that the messagebox doesn't prevent the printing the same way as sleep does. This approach is risky and will lock my computer for the duration so it's not optimal either but atleast it saves me from a lot of manual labor.

Any thoughts on what I can do? Either improve my own solutions or other ways to work around this?

推荐答案

OP同意等待流程完成 [ ^ ]满足要求。链接包含完整的代码段。



(我与该网站无关!)
OP has agreed that wait for process to finish[^] satisfies the requirement. Link contains full code snippet.

(I am not associated with the website!)


这篇关于打印机自动化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆