专注于打开的应用程序窗口cmd nircmd

问题描述 投票:0回答:2

我试图使用批处理文件打开2个文件。

创建了一个循环来粘贴(交替)该文件中的内容。

1)在文件1中粘贴一些东西。

2)在文件2中粘贴一些东西。

3)在文件1中粘贴一些东西。

4)在文件2中粘贴一些东西

..等等

问题是我在文件2中写完后如何重点关注文件1?

注意:我使用的是nircmd.exe实用程序。

我的批处理文件中的代码示例:

**

START file1.txt
START file2.txt
FOR LOOP STARTS (
nircmd.exe win focus stitle "file1.txt"  ---> not working, is there something I  am missing?
nircmd.exe sedkeypress h e l l o
nircmd.exe win focus stitle "file2.txt"  ---> not working, something missing ?
nircmd.exe sedkeypress b y e
)

**

任何帮助将不胜感激。

提前致谢。

windows batch-file command-line cmd
2个回答
0
投票

我没有看到在窗口上获得焦点的问题,但是在Windows中保持开启焦点可能会被任何(很多)(无法预料)(异步)事件改变...

下一种方法可以帮助在.txt文件内容之前编写文本:

echo(h e l l o>"%temp%\temp.xxx"
:: echo( w o r l d>>"%temp%\temp.xxx"
copy nul + "%temp%\temp.xxx" + "file1.txt" "file1.txt"
erase /Q /F "%temp%\temp.xxx"

.xxx文件扩展名可以替换为任何可能未使用的扩展名,例如.xyz


0
投票

对于NirCMD,我发现Win10上的nircmd win activate stitle "App Name"focussettopmost的票。

© www.soinside.com 2019 - 2024. All rights reserved.