Posting to Twitter from the Command Line (And from Dash)

Twitter is a great tool for me and I like being able to post, but sometimes I wish it were more convenient to do so. Sure there are plenty of apps and widgets, but I wanted something that would let me post from a command line. Not an interactive app, just type and go. I didn’t see anything for it, so I ventured off on my own.

First, I saw that Twitteroo had a .NET library for Twitter. So I built my client with that. After a while I realized that Twitteroo does a lot more than I need, so with the aid of Reflector, I found just the lines that I needed, and copied and pasted into my own code.

Now I can type contwit “This is a status update” and “This is a status update” will show up on my Twitter account. So how did it know who I am? Well, if you just type contwit with no parameters, it asks you for a username and password. These are stored in an encrypted string in a configuration file in the same directory as the executable.

Now, that’s pretty cool and all, but it still didn’t make it much easier to use. Enter Dash. Dash is the App Launcher I use. I just type -<-> and a little window pops up. I can then type what I want to launch and it launches it. I don’t even have to type the whole command because it autocompletes. Visit the site. It works really well.

So with Dash, I end up typing -<->twthis is my status update and I am done. But my app is a console app and I hate having the console window pop up. Sure, I could write the app as a windowless Windows app, but I am lazy. So to cure this I use HStart from NTWind. This is a great tool that launches any command line app from a hidden window. The options are a bit confusing so here is my Dash command line:

Path: hstart 

Arguments: /NOCONSOLE “”C:Program FilescontwitContwit.exe” “*ALL*””

Note the double quotes, those are important.