Getting Current Song Data From Windows Media Player 12 - vb.net

I have been searching all over for an answer to this, and I'm figuring there is no way to do it, but I thought I'd ask.
I'm looking to make a VB.net app that gets and displays the artist and title of a song playing in Windows Media Player. I'm not looking to embed the player in my app, just pull data from the already existing window.
Most of the stuff I find on how to do this is old or related to embedding WMP. I'm looking to do it in with MWP12. I've also seen references to using AxWindowsMediaPlayer.currentMedia Property, but that doesn't seem to work anymore. I used to be able to pull the data from the Registry, but it seems Microsoft took that away.
I've tried sooooo much other code, but this is currently what I have. I'm at my wits end.
Imports WMPLib
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim wmp As WindowsMediaPlayer = New WindowsMediaPlayer
Dim playlist As IWMPPlaylist = wmp.currentMedia.???????(????).Item(?)
Label1.Text = playlist.getItemInfo("Title")
End Sub
End Class
No idea where to go here, but thanks for any help.

Related

VB Forms don't recognize each other in the same project

Hi everyone I need some help,
I am having a weird situation every time I try to call a window form I get this error
BC30469 Reference to a non-shared member requires an object reference.
I was originally working on Visual Studio 2010 when the first time contouring this problem so I thought that I may accidentally deleted or edited some code in the declaration of the form witch caused the problem so I closed the solution and created a new one to make sure that the problem is limited the solution not to VS. then I add window form "Form2" then created/added a button1 on Form1 to call Form2.Show()
simple code that should work fine but when I tape Form2.Show() it give that ERROR and red mark Form2
so I uninstalled VS2010 then Reset Windows 10 with option to wipe out all data on windows partition (I now that was extreme but I suspected that maybe the system was infected with some virus "prior action") so after that I checked the system with HitmanPro and found nothing then I installed VS2019 Community and get The some problem I searched on the web but did not found any similar case so here I am hoping that someone will resolve the mystery.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Form2.Show()
End Sub
End Class
Form2 is empty form I didn't make any change on it
Before this problem showing up everything work fine now even old project have the same issue
Thanks
Edit: Add project as simple
https://mega.nz/file/FgoXkCwA#ootxYrXGnR6sQR_Pifjvz617-r_Az1ozXWB49oGxqKU
the project dose not contain any executable file
I usually do something like this when calling a subform:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' using a Using block:
Using form2 as New Form2
form2.ShowDialog(Me)
form2.Close()
End Using
' using a With block
With New Form2
.ShowDialog(Me)
.Close()
End With
End Sub
ShowDialog(Me) keeps the subform open until a DialogResult is provided by the user (OK or Cancel usually).

Starting processes error in vb.net

Sorry if this question is 'newbie'
So I have a code that opens some programs that were added to a listbox. These programs range from games to other applications I've made using VB.net to webpages.
I have a problem when I try to start some games. Say I have a button and the code is like this:
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim sDirectory1 = "C:\Games\Company of Heroes 2 Master Collection\RelicCoH2.exe"
Process.Start(sDirectory1)
End Sub
The game is Company of Heroes 2, but it gives me the error 'Cannot find items file' outside of VB. And a few other games have similar errors too, but I can run them myself by directly starting the .exe. Do some programs need more permissions? I've tried running as admin to no avail. Over applications will work, such as applications I've made myself and games with launchers. Thanks.

open pdf from Menu List in Visual Basic

I am a neophyte programmer who was right on the cusp of his answer over here at
Loading a pdf file in Visual Basic Windows form?
Unfortunately I couldn't find a way to get in touch with the person whom I thought gave the best answer, so forgive me if this answer is inapropes...
I would like to add .pdf files to my programme, so that the user can simply read directly upon clicking the menu item.
I have the files "Benutzerhandbuch Info 2 Projekt.pdf" and "Produktbeschreibung Info II Projekt.pdf" ready to go, but don't know where I should save them.
I've already got Adobe installed on my machine and in my toolbox.
GojiraDeMonstah answered with what I think is the best solution (??) but I couldn't ask any further q's as it is against policy and I don't have enough cred 'cause I'm new.
Q* - where should I save the file so that VB can see it?
Q* - once the programming is complete, I will then burn this to CD and give it to Prof as a kind of "Product", but if I link a pdf file saved on my computer, then how will my prof see the file?
Sorry if these questions sound really basic, but I don't even know what to search for besides what I have already done. I really do need a bit of hand-holding here. I wish I could upload pics, because it would make my question easier to understand. Thanks in advance for your help.
Insert a WebBrowser Control in your WinForm, then:
webBrowser1.Navigate("c:\test.pdf")
I ended up using the following:
Public Class Benutzerhandbuch
Private Sub Benutzerhandbuch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub AxWebBrowser1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxWebBrowser1.Enter
AxWebBrowser1.Navigate("C:\FilenamePath\Filename.pdf")
End Sub
End Class
Special thanks to all who contributed.
Logan

Make form always stick to desktop like Win 7 gadget (VB.net)

Ok, I'm aware there's a lots of topis about this, but I haven't found anything that works for me.
My program generates a small picture that i would like to keep in a WinForm that's always at the bottom, "with the desktop". Something like the gadgets in windows 7.
How do i tell my form to always stay here, and just can't be visible over any other form/window?
Should'nt this be doable like in the form_load function for this window?
Like this
Private Sub Sticky_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeepMeAtTheBottomUntillIAmClosed
End Sub
If you create a form that has no border and no controlbox, the user will not be able to resize or move it. Then add your own button to allow it to close, tell it where you want it to be and tada!
You can even add some mouse over functionality to make the tools appear when you are over the form.

WebBrowser control uses too much CPU and RAM

In my application I have only a webbrowser and a few timers, but if the webbrowser is loading, it uses 50% of the CPU and afer 5 minutes around of 120k RAM. What can I do?
My code:
Public Sub work()
WebBrowser1.Navigate("Site")
tim.Start()
End Sub
Public Sub work2()
WebBrowser1.Document.GetElementFromPoint(point).InvokeMember("click")
tim2.Start()
tim.Stop()
End Sub
Dim point As New Point(800, 30)
Dim WithEvents tim As New Timer
Dim WithEvents tim2 As New Timer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tim.Interval = 6000
tim2.Interval = 6000
work()
End Sub
Private Sub tim_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tim.Tick
work2()
End Sub
Private Sub tim2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tim2.Tick
work()
End Sub
Long, Time ago since this was asked, but as i write this i have been working on my own project to create a YouTube app from Vb.net and, for a few weeks i have been stuck on trying to figure out why the IE Wrapper Web Control was taking so much of my CPU when Processing and Playing Videos, and from a lack of finding any good help with my problem that solved anything, i eventually researched enough and found a solution to my problem which were the use of Feature Registry Entries that i added for my program to check and add as needed on startup of the program, and the two i found which were a lot of help were both FEATURE_BROWSER_EMULATION and FEATURE_GPU_RENDERING, By Default i believe and could be wrong, the vb.net wrapper uses IE7 but if you change it to the latest version for your program in there it will make it more secure and improve performance, than you can turn on the gpu rendering with a DWORD subkey of 1 with the name of your program and it will make the gpu handle some of the workload also greatly improving the speed. using these made the webcontrol go from utilizing around 70-80% CPU during videos down to low of 3% and high of 20% CPU utilization, good for future reference, also learn more about the registry features here https://msdn.microsoft.com/en-us/library/ee330733(v=vs.85).aspx
120k sounds very reasonable if there is some heavy web page loaded in the control. E.g. if you save the main page of microsoft.com from within IE in a mht format (complete archive), it is almost 1MB large. The processor usage will most probably depend on what the click handler does - is there any heavy script attached to the element?