Is it possible with a batch file to open a file then execute or "click" an option in the opened application "File" menu with just one .bat file?
So for example normally I would double-click the Firefox shortcut on my desktop then click on "File" > "New Tab".
Is it possible to do that with a single .bat file?
You can use the CursorPos.exe by #Aacini to move the cursor. Here is the download link: https://www.dostips.com/forum/viewtopic.php?t=3428. In the download page, you can only download the set of .exe files. Extract CursorPos.exe from them.
Usage:
CursorPos [[±]col [±]row]
If no parameter is given, return current cursor position as col+(row<<16) in ERRORLEVEL.
If any coordinate have sign, the position given is relative to the current one.
If cursor is moved, the Ascii code of the character at new position is returned in ERRORLEVEL.
And for mouse input you can use batbox.exe. Download link: https://batchprogrammers.blogspot.com/2016/06/batbox-awesome-batch-plugin-by.html?m=1. The full information is available there.
Related
When I make a context-menu item in the Registry to call a .bat-file which contains the following command, it doesn't list all the selected files in the outputted .txt-file:
echo "%~dpf1" >> "%~dp1filelist-selected.txt"
I now realize this is because because Windows opens the .bat-file once for each of the selected files, and if one process tries to run the .bat-file while another process is also running it, then only one of them can access the .txt at any given time, leading to one or more failing to output to the .txt-file.
Does anybody have an idea of how to get around this issue, to get the pathnames of each of the selected files into a single .txt-file?
I see there is a function in Windows called "Copy as path", where the pathnames of selected files are copied to the clipboard. This option is available as a context-menu item by right-clicking on a selected group of files while holding down the shift-key.
This menu item is described in on the following page: Show “Copy as Path” Always in Right-Click Menu Without Shift Key
Is there a way one might harness this functionality to make a context-menu command which copies the pathnames of the selected files, makes a .txt-file, and finally pastes the contents of the Clipboard into the file?
I hope somebody has the answer.
Thank you.
Your basic batch:
FOR %%x in (%*) do IF not %%x == "" (
ECHO "%%~dpfx" >> "%%~dpxfilelist-selected.txt"
)
I cannot open some text files with an embedded text editor depending on the extension in the file name.
For example, if I have Wavefront .obj file, KDevelop will open it with hex editor, in the Open With menu only hex editors are available.
There is File Type Options button in the file properties, but if I click to this button nothing happens and no output in stdout/stderr from KDevelop.
I am using Gentoo Linux distribution with KDevelop 5.5.2
Had same problem, and here's quick solution:
Click right on your file in file manager (in my kde it's default dolphin);
Select "Properties";
In opened window click "File type options";
In the next opened window select "Embedding" tab;
In services prefering order list select Okteta, and then remove it;
Click ok and it's done.
KDevelop after that, stops use hex editor and open files in embedded text viewer. Note, that this recipe would work only for one file type (or extension), that was selected in first step.
I made a batch file that receives one of its parameters from right-clicking on a file and sending it to my batch file.
The problem is that it crashes if the path has a space in it.
For example, a file in C:\temp\CarRide works, but a file in C:\temp\Car Ride doesn't work. The cmd window flashes and immediately closes.
I tried putting a pause as the first line in the batch file, and it didn't event get to that, so I'm pretty sure the problem is the way Send To handles the path.
Got any ideas?
Use quotes when there is a space in the Path C:\temp\CarRide vs. "C:\temp\Car Ride", otherwise the path is parsed as two arguments. In your case the first the right clicked file takes the first argument %1 so set input to "%1"
I have a single file that is zipped. I want to unzip this, but I don't have enough space on the computer. Is there a way to unzip it in parts? For example, first I'd want to unzip the first quarter (or x GB), then stop, look at the resulting file, delete it, and then unzip the next part. The parts do not have to fit together perfectly to form a new file.
I'm using Windows.
EDIT
The original pre-zipped file is only 1 file. This single file was zipped, and now I need to unzip it, but in parts.
Assuming it's a text file:
I'm not sure how to do this natively in Windows, but this is very easy to do under unix. You can download Cygwin which will give you access to the unix tools that can do this.
Then you can do:
/cygdrive/c/yourDisk/
$ zcat yourFile.zip | sed -n 1,1000p > file1.txt
This will give you the first thousand lines in a file in c:\yourDisk\file1.txt
Use your Windows Explorer to explore the zip file... it allows you to open subdirectories (folders) and for you to navigate anywhere within the zip as if it was a normal folder.
When you find something you want to view, either double click it, or drag it to another location in your drive. If you drag it, you will end up copying whatever you are dragging to a new location (say, your temporary work area). Note, copying is not the same as moving as the original compressed version will continue to exist within the zipped folder.
When you have finished with whatever you dragged out, you can delete it (the copy) and return to your original and pull out more data/files for inspection.
Look at my attached image... notice the directory path where I have the red arrow. It says I opened a file called myzipfile.zip (I did a right mouse button over the file and clicked Open With... and selected Windows Explorer).
Mean: I want to add a batch file to the right click property.
Action that this file needs to do is to go to a folder and look up the highlighted/selected text that I've selected when clicking on the batch file.
My question is how to get this highlighted text selected into a variable in the batch file?
Later on I can use this variable in the code to navigate to the folder and select the correct file.
I'll use following code then:
#echo off
start wgnplot.exe "c:\path to file to open\VARIABLE.pdf"