Reputation: 95
I am trying to open 2 files using a batch file.
created a loop to paste( alternately )something in that file.
i.e
1) Paste some thing in file 1.
2) Paste some thing in file 2.
3) Paste something in file 1.
4) Paste something in file 2
..and so on
problem is that how can I focus back on file 1 after I have done writing in file 2 ?
Note: I am using nircmd.exe utility.
Code sample in my batch file:
**
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
)
**
Any help will be greatly appreciated.
Thanks in advance.
Upvotes: 0
Views: 4435
Reputation: 31
For NirCMD I found that nircmd win activate stitle "App Name"
on Win10 was the ticket over focus
and settopmost
.
Upvotes: 2
Reputation: 30123
I don't see a problem in getting focus on a window, but in keeping it on as in Windows focus could become changed by any of (much) (unforeseen) (asynchronous) events...
Next approach could help to write a text ahead of a .txt
file content:
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"
The .xxx
file extension could be replaced by any possibly unused extension, for instance .xyz
Upvotes: 0