c# playing movie in windows media player "Not" embedded - c#

I have looked around, everything I find is talking about embedding it.
I do not want to embed it. I want to click a button and launch windows media player seperatly.
For example, I have a location saved in XML file. I have a right click to click Play. It pulls the location. like so.
int dd = dataGridView1.CurrentRow.Index;
string eLoc = dataGridView1.Rows[dd].Cells[4].Value.ToString();
if (eLoc == "")
{
MessageBox.Show("You have not saved a location for this movie","Movie Play",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
MessageBox.Show(eLoc);
ProcessStartInfo ps = new ProcessStartInfo("wmplayer.exe", eLoc.ToString());
Process.Start(ps);
}
As you can see, I have a pop up to view, what the string is.
It is this. I added %20 to replace spaces, thinking that was the problem but it isn't.
As you can see it pulls the full location. All I get back from windows media player is this.
Any ideas? To me it seems like this should be working..

I got it working now. It was the spaces causing the errors, I changed to this, and works perfect now.
ProcessStartInfo ps = new ProcessStartInfo("wmplayer.exe", "\""+eLoc+"\"");

It should be working, in fact on my computer and with a different path it does work, I suspect the file is damaged like jfs suggested.

Related

How can I sendKeys to the Windows Explorer with Selenium

A link on the page opens the file explorer of Windows.
Now I would like to send c:\temp\file1.txt to it.
Picture of Windows Explorer:
How can I do that?
What I tried is:
string BaseWindow = _webDriver.CurrentWindowHandle;
IJavaScriptExecutor jsExec = (IJavaScriptExecutor)_webDriver;
Thread.Sleep(1000);
jsExec.ExecuteScript("arguments[0].value = 'C:\\temp\\file1.txt'; ", BaseWindow);
which did not break the script actually but it didn't give the proper effect either.
Finally!! got it to work:
for all those people struggeling with the same thing... here is the solution:
you've got to switch to the active element then use sendkeys.
I got this:
System.Diagnostics.Process.Start("explorer.exe", "C:\\test.csv\"");
However that literally opens the Excel file. (which is also nice to know how to do that in automation by the way)
But I need to select a file in the Explorer (see 'pic of Windows Explorer')
I also tried this:
System.Diagnostics.Process.Start("explorer.exe /select", "C:\test.csv"");
Discovering this brought better results still not mission accomplished.
var FilePath = "'C:\\test.csv\'";
System.Diagnostics.Process.Start("Explorer.exe", #"/select,""" + FilePath + "\"");

How i get URL of steam apps in c#

I'm making a application for steam games. Because shortcuts steal zone from desktop ,so i make this project for this. I want add a "drop file here to add list" when he put to shortcut on program i need get the app id, then it will automatically add to list.I added the drop file script!! But i dont know how to get URL title from assembly..There is a screenshot. I want get url from shortcut like this.
SCREENSHOT 1
SCREENSHOT 2
!! I made the drop file script.. I just have problems at get url script.
Opening steam applications is very simple, if you know the location of your steam.exe.
System.Diagnostics.Process.Start(#"C:\Program Files (x86)\Steam\steam.exe","steam://rungameid/730");
In my case (i think its default as well) you can start an application just by giving the path of the steam.exe and passing the content of the shortcut as argument.
Edit:
If you want to get the argument value you can just read the File using
File.ReadAllLines(path);
And get the argument from the string, which will then look like this:
string[] lines = File.ReadAllLines(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Golf With Your Friends.url");
string argument = lines.ToList().FirstOrDefault(item => { return item.Contains("steam://"); }).Replace("URL=", "");
System.Diagnostics.Process.Start(#"C:\Program Files (x86)\Steam\steam.exe", argument);

How can I make a windows media player control's URL truly null?

I am trying to modify my track's metadata, but I can't because the file I try to edit is constantly in use. I believe this is because my axwindowsmediaplayer control is still reading from the file. I want it to stop reading from the file so I can edit it, but it seems I can't make its URL property equivalent to nothing- it wants to keep the same URL if I tell it to set the URL to null or " ". If I give it an invalid URL though, it errors. How can I make it so its URL is actually null or better yet, make it so it stops reading from my file altogether?
private void editTrackMetadataToolStripMenuItem_Click(object sender, EventArgs e)
{
Form metaform = new MetaData();
metaform.Show();
Properties.Settings.Default.StopMedia = true;
axWindowsMediaPlayer1.URL = null;//ahahahahahahaha
}
According to the documentation, it is possible to release the current resource with the close method.
Try
axWindowsMediaPlayer1.currentPlaylist.clear();
For folks who are still looking for answers:
close method does not work, it stops the player but you can still click the
play button to play the old one.
axWindowsMediaPlayer1.currentPlaylist.clear(); works as a charm.

Manipulating "filename" of file dialog opened using a "print to pdf" option

I have over a thousand e-mails that need to be converted to individual PDFs. The code I've written is able to process the faux-print job up to the "Save PDF As..." Dialog Box.
I need to manipulate the filename in that dialog to the original filename. I cannot find a way to post a string to the filename section of the dialogbox, since this is an unconventional method posting on a separate process.
How do I send this information to an active dialog window that is unrelated to the process the application is calling?
public static void Main(string[] args)
{
string folderIn = Path.GetDirectoryName(#"Z:\Files up to 3-6-13\");
string folderOut = Path.GetDirectoryName(#"c:\users\athomas\desktop\Output");
string[] fileList = Directory.GetFiles(folderIn);
foreach(var fileName in fileList)
{
Console.WriteLine(fileName);
Process p = new Process();
ProcessStartInfo info = new ProcessStartInfo(fileName);
info.Verb = "Print";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
// This is where I need to say something like
// SaveDialog.SaveAs(fileName.SafeFileName)
if(p.HasExited == false)
{
p.WaitForExit(1000);
}
}
Console.ReadLine();
}
You are asking basically about hacking around, which means there is no safe way to do that. The possible way may look like this:
1) You enumerate windowses shown on the screen, via EnumWindows
2) You use for every window GetWindowText to find a Title of the Dialog you are searching for.
3) Ocassionaly there may be more then one dialog, Murphy's law is always there, so may be even with the same title. You can reduce collision risk by
3.a Call GetWindowLong with HWND of "dialog" you found
3.b Call GetParent to get HWND of parent window, that you already know
If you can avoid or may not care about case of window style&title collision, just jump over point (3)
4) Once you found your dialog, run over its HWND EnumChildWindows to get all controls of it
5) Find the contrlol you interested in via some attribute (usually Class_ID)
6) Execute SetWindowtext to set the text you like.
As I said before, there are several places were this process can fail.
For example:
You may happen to have multiple dialogs on the screen in the same moment
You may download a new version of PDF processor, and in SaveAs dialog may have something changed, so your code will break.
But considering that you are hacking, you may assume your own risks.
An excellent tool, may be the best tool, for window investigation on Windows, is probably Spy ++, which is available within visual studio installation. Using it you can try to find some unique attributes of a textbox of that dialog where you want to put the text in. Having that in your hands you can reliably query dialog's children collection to find the textbox.
After you mentioned .msg, I did a Google Search on the .msg file format and I was surprised to find it was well documented. It is an OLESS file, and there are APIs for loading those. I even found a CodeProject C# sample that was able to load an email I just saved from Outlook 2013!
It will be a bit of work since you will have to write code to "render" message how you see fit. Ex: It gives you the body, the recipients, and the attachments. You would have to decide what to do with the attachments and code that up. Then find a PDF library. But at least it is a programmatic solution, rather than relying on hacking the UI.
Also: A Google search for .MSG to PDF returned loads of tools to do this. One is a forum post referring to an Adobe Product called "Acrobat PDFMaker" so maybe you don't even need to write code.
Sorry to post 2 answers. I have a solution to the exact problem of prompting for the file. These instructions vary slightly based on the version of Windows, but you will get the idea:
Add a new printer that uses PDF printer driver
When it asks for the "port" click "Add Port" then "Local Port"
Enter in a file name. Ex: "C:\Users\Myself\MyPdf.pdf"
Complete the printing wizard as usual.
I tested this with the XPS printer and it worked
When you print to this printer, it writes to that exact file: No prompting! You will have to monitor the file (I suggest FileSystemWatcher) or poll for when the file is closed or something like that. After that, you can move the file elsewhere.

How to play sound from cocos2d-xna personal folder

How can I play a sound from the
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal
folder?
I have tried:
string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Sounds/Twing.mp3");
CCSimpleAudioEngine.SharedEngine.PlayEffect(path);
But it doesn't work
you get an exception ?
i assume that the specified sound is loaded via the content pipleline,
so you would need to add that to your content project.
So if you see ContentPipeline, ContentLoader or something in the stack trace, this may be the correct answer.
I dit not find a way to directly pass the audio.
With images that is possible.

Categories

Resources