从TXT文件中读取并将击键发送到另一个应用程序 [英] Read from a TXT file and send a keystroke to another application

查看:121
本文介绍了从TXT文件中读取并将击键发送到另一个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我该如何制作一个不断读取文件夹的程序,以查看其中是否存在* .txt文件,如果有该文件,它将读取该文件并将其信息通过击键发送到另一个窗口,它们将擦除该文件并重新启动尝试阅读的过程...

Thks

Hi,
How can i make a program that is constantly reading a folder to see if there is a *.txt file there, and if there is it will read it and send the info there in keystrokes to another window, they it erases the file and restarts the process of trying to read...

Thks

推荐答案

嗯,您在执行此任务时遇到了主要问题.

1-如果您的其他任务在写入文件时尝试读取该文件怎么办?多久写一次?
2-如何确保在读取和删除文件之间没有任何文件写入文件?

忽略这些问题,以及将击键发送到不在您的应用程序中的另一个窗口(但是您可以通过发送窗口WM消息来完成)的令人难以置信的hack,您只需在服务中设置文件监视程序即可监视地点.它不一定是一项服务,但听起来像您想要的那样.
Well, you have major issues with this task.

1 - what if your other task tries to read the file when it''s being written ? How often will it be written ?
2 - how do you make sure nothing is written to the file between you reading it and you deleting it ?

Ignoring these issues, and the incredible hack that is sending keystrokes to another window that''s not in your app ( but you can do it by sending the window WM messages ), you just set up a file watcher in a service that watches that location. It doesn''t have to be a service, but it sounds like you''d want it to be.


这篇关于从TXT文件中读取并将击键发送到另一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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