Add options to program's right-click menu - vb.net

I have a small program that reads a CSV file and outputs it in a different format.
Sometimes I want a different output format so currently I just have another version of the program compiled with slightly different code (it has no GUI, you just click on the exe and it does its job).
Is there a way I can add an option to the context menu of this program to use the different output option, perhaps by running it with a command-line argument?
I mean when right-clicking on the exe file itself, so before it is actually running.
Anything I can find when searching for answers is about editing the shell, via the registry or some other way, however I only want the option to show for this program, not every file in Windows.
Code for the command line that I would be using:
If Environment.GetCommandLineArgs.Count <> 1 Then
If Environment.GetCommandLineArgs(1) = "/output2" Then
'do stuff
End If
End If

Related

How do I open a file with a specific application rather than its default application?

I am trying to open files using a specified executable; just like as if you were to right mouse click on a file then scroll to "Open with"
I tried what kaymaf said and reviewed the docs, but I cannot seem to get this to work.
Dim FI As New FileInfo(GetFileNameFromListViewItem(ListViewCollection.SelectedItems(0)))
Dim GetExif As Process = System.Diagnostics.Process.Start("C:\Users\*username*\Downloads\exiftool.exe", FI.FullName)
This just ends up open the executable and rather than opening the file with the executable.
You would like to open a file with your program using the Windows context menu; and do you want to get an entry in that menu? If that is not correct, the answer can be deleted.
I found this in a German forum, and they refer to this site:
This is the translated text:
One possibility would be that you register your file extension and your program in the system to open this file extension. As soon as the system knows everything, you only need to right-click on the file(s) and in the context menu, in addition to the standard entries, another menu item for opening these files is displayed. If you select this menu item, your program will start automatically if it has not yet started, and you can read out / determine the path to this file or several files in your program and process it accordingly. How it all works is described here: ookii.org/Blog/opening_files_via_idroptarget_in_net
On this page there is also a sample for download (start text files with your own program via an additional entry in the context menu / display paths to the files). It is not a VB, but it should be translatable without any problems. Corresponding information on the page and the comments should be observed.

VSTO: Specify Word Document During Debugging Development

In Visual Studio VSTO, how can I specify the document to open each time I run the project to debug it?
By default, it always opens a blank document and of course I want to test against features that would already be present in a document.
I tried as Cor_Blimey suggested but it opens only the specified when something changes (haven't figured what yet). In addition breakpoints don't work at least in VS2013 implementing the upper solution.
So what I did is to open the specific debugging/testing file each time the add-in is started up.
It works excellent, breakpoints are functional, no blank workbook is loaded and changes in a sheet a available in the next debugging session.
In order to avoid that the file is opened in the released add-in I put it in #if DEBUG.
More information about that method are here but it has as to be used with precaution as described here.
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
#if (DEBUG)
this.Application.Workbooks.Open("C:\\Users\\c563368\\Documents\\Visual Studio 2013\\Projects\\...\\debug.xls");
#endif
}
But there is one disadvantage, as long as you debugging environment (visual studio) is running, Office will always open the add-in build from the debug folder.
You can avoid this by running an the office application as external program, as described here.
You need to use the command line you can set to run on a successful build (there is no way to only get it to run on Debug (as in F11) and you cannot set it on a per Configuration basis. However, there is a good workaround to get it to only do things on the Debug configuration etc.
The basic behaviour is:
Open the solution. Open the project's properties. Go to Build Events. In Post-Build Event Command Line enter in the path to Word (e.g. "C:\Program Files (x86)\Microsoft Office\Office14\Winword") (or if it is in your %Path% then just Winword) and pass in the path to the document you want opened as an argument. This will open Word and the document on every successful build (you can set the trigger to being all builds, whether successful or otherwise etc)
What I prefer to do, however, is simply point it to a batch file, passing in the details about the build event as arguments to the batch file. Then, within the batch file, I run the logic to decide if it should launch Word, open a document etc.
For example, you can point it to
$(ProjectDir)buildScript.bat "$(ConfigurationName)"
Then within the batch file have something like
if %1=="Debug - Excel" "C:\Program Files (x86)\Microsoft Office\Office14\excel.exe" "%~dp0\testbook.xlsx"
This will run a batch file called buildScript in the project directory. The first argument (%1 to access in the batch file) will be the configuration. You can therefore set the batch file to launch Word and pass in the document as the argument if the config is e.g. "Debug" but not if it is "Release", thereby sidestepping the limitation within VS2012 Post-Build Event command line.
Edit:
A list of switches for Word can be found at http://support.microsoft.com/kb/210565
What you need to instruct Word to do will depend on the type of addin you are making:
If it is a standard COM addin then, so long as the DLL is registered and you have set the registry entries (or selected it in the Word addin settings) to open the addin then it should open when Word opens.
If it is an addin document, however, then the procedure is different -> try playing with the commnd switches to instruct Word to open the particular addin document.
I am more familiar with Excel COM addins, so you will have to experiment with the specificities of a Word addin. But the basic principles are to use the post-build event commnd line, coupled with the right switches and arguments to Winword.
Hope that helps.
The simpliest way to achive it is to replace .docx / .xlsx file in solution location

How to reload unreal development kit after script change

i am currently learning unreal scripting. i am creating them on visual studio then compile them in it. I have created a level with the actor i have created.
The problem i have is every time i make changes to the script I am closing the UDK and reopen the level to see the changes.
Is there a way of saying to UDK to reload?
If you make changes to the script, you need to close any instances of UDK.exe, whether game or editor.
Here is a workflow to speed up the whole process by using .bat files to run the game or editor.
Create a text file and rename it to run_game.bat. Inside the file put the following text, adjusting the path to match your project settings:
C:\UDK\Kel\Binaries\Win32\udk.exe Level01
Note that Level01 is the name of your level / map file. This .bat file will run your game within that level.
Next, create another .bat file called run_editor.bat and put this text inside:
C:\UDK\Kel\Binaries\Win32\udk.exe editor Level01
By adding the editor parameter, you're asking to run the editor directly with the desired level.
Copy the two .bat files in C:\Users[Your username] for fast access.
Open the command line by pressing Windows + R, then typing cmd and hitting Enter. Type either run_game or run_editor and hit Enter.
If you have uncompiled code, you'll be asked whether to compile it, so say yes. You will also see any errors or warnings that showed up during compile, which is useful. If everything went well after the compile, press the Up key or type in the name of the .bat you are trying to run, and hit Enter.
Using the above method is also faster because it doesn't require you to compile the scripts in Visual Studio.
Unfortunately, no. Changes to UnrealScript require recompiling the .u file, and the game/editor has to be closed so the file can be deleted and recreated.
I'm not sure from your question if you're saying you're reopening the UDK editor every time you want to see the change, or if you're just reopening the game. If you just want to modify the script, compile, and see the result (without modifying the level), you don't have to reopen the editor. You can just run UDK.exe, press the '~' key to bring up the console, and type open yourlevelname. Or you can create a shortcut that runs UDK.exe yourlevelname to start the game on that level. Of course if you want to spawn in and run around, you'll need to put a PlayerStart in your level.

VB.NET call desktop application from 2 shortcuts - supply different parameters

I have a desktop application which reads files from a specified folder, then deposits the files to a folder in a third party document management system based on criteria that the user provides.
My question is:
is it possible to somehow provide different parameters to the code, depending on which shortcut of the application the user clicked on to start it up?
You can add command line parameters to a shortcut icon. Here's how you can do it in Windows:
On the Start Menu, navigate to Notepad.
Right click on Notepad and choose Send To > Desktop (Create Shortcut)
Right click on the newly-created desktop icon and choose Properties
Add your command line parameters to the Target text box.
For example, if you want notepad to open up the hosts file, this would be the content of Target property:
%SystemRoot%\system32\notepad.exe "C:\WINDOWS\system32\drivers\etc\hosts"
You can put pretty much anything into the Target property of a shortcut that you would put into a command line.
Yes.
The easiest way would be to have the shortcut pass those parameters in via the command line.
You could also use conditional compilation variables, and have 2 different .exes. You should be able to find samples of both approaches (command line and conditional compilation variable) in help.

Extract the contents of cmd.exe IDE to a text file using autohotkey scripts

I am trying to extract the contents of cmd.exe IDE to a text file using autohotkey scripts ie one test.ahk and its written as shown below:
WinGetText, text, "C:\WINDOWS\system32\cmd.exe"
FileAppend, %text%, C:\ThreePartition\ACTUAL.txt
I am not able to extract the contents. Can anyone please suggest the correct way to do the extraction?
The text retrieved is generally the same as what Window Spy shows for that window.
The Window Spy shows no text elements for CMD windows - what you see is not necessarily what you can get :)
What you can do is to simulate the Select All and Paste commands, and then use the clipboard contents.
I don't believe you can extract the contents of a cmd window without somehow using DllCall to read the process memory directly.
If you just want the output of a CLI command such as Grep or AWK, using stdout via the run command should work. Honestly though, I stopped relying on AHK because this sort of thing is just too clunky.
http://www.autohotkey.com/docs/commands/Run.htm.
Edit for comments:
What you want is doable, but the solution depends entirely on how your IDE works. What behavior does it have that's unique to building a project? If it makes temp files, you can overload your "build" button with an AHK subroutine that watches for the existence of those files, and then checks the modified date of the output executable to see if the build succeeded. The same kind of solution works if the IDE changes its window title when building. Be clever. :)
Failing that, you might have to install a message hook.