• 0

How to make an open windows list VB 2010 express


Question

Hello all

Basically this has stumped us. We are making a program that depends on being able to choose which window of all open windows is the one to use. However, we cant find which command to use to get the windows to make the list. The window will most likely be firefox. This is 2010 express so there isn't .net commands.

Any ideas here whould be most appreciated.

Thanks

14 answers to this question

Recommended Posts

  • 0

If it will always be firefox you can use System.Diagnostics.Process.GetProcessByName. If the user must choose then I recommend you reference managed winapi and use code such as (C# but very similar and still .NET, should give you the idea. This example fills a treeview named treeView1)

foreach (SystemWindow m in SystemWindow.AllToplevelWindows.Where<SystemWindow>;
                ((SystemWindow g) =&gt; {
            if (g.Visible) treeView1.Nodes.Add(g.Title + "[" + g.HWnd.ToString() + "]").Tag = g.HWnd; return false;
                })) { }

  • 0
  On 01/12/2010 at 22:09, omnicoder said:

If it will always be firefox you can use System.Diagnostics.Process.GetProcessByName. If the user must choose then I recommend you reference managed winapi and use code such as (C# but very similar and still .NET, should give you the idea. This example fills a treeview named treeView1)

foreach (SystemWindow m in SystemWindow.AllToplevelWindows.Where<SystemWindow>;
                ((SystemWindow g) =&gt; {
            if (g.Visible) treeView1.Nodes.Add(g.Title + "[" + g.HWnd.ToString() + "]").Tag = g.HWnd; return false;
                })) { }

Thanks, but as we don't have .net extensions it won't run. We need a solution for VB 2010 express without using .net

  • 0

All express versions of any of the .NET languages fully support '.net extensions' so I'm not sure what you think is missing. Everything in omnicoders response is possible with VB.NET 2010 Express .

  • 0

Unless he was referring to my use of Where<T>, which I don't think is avaliable in .NET2.0 (in which case he should upgrade to 3.5/4.0) but that would be trivial to convert into a loop for use in 2.0 anyway.

VB 2010 uses .net exclusively, there is no way around that.

  • 0
  On 02/12/2010 at 00:27, Getwin said:

Thanks, but as we don't have .net extensions it won't run. We need a solution for VB 2010 express without using .net

You must have the .NET Framework to use any software written in VB or C#. The "old" style of VB doesn't exist anymore.

  • 0

Hi and thank you to everybody esp. Omnicoder

However, we still cannot use that code. It doesnt compile because the functions are unrecognised by the interpreter.

What we want to do is display a dialogbox to the user, which lists all open windows on the computer, so that he can select one to use. Our code will then interact with that window. That is the objective.

We have tried many samples of code we have found from online tutorials, but none of them will work in our computer because all of them use .net functions. We have the Visual Basic 2010 Express application, which errors over anything with .net code. It will not run it or compile it. This is the free application from MS which specifically has all .net functionality removed.

We need code to do this without using .net extensions. We know it is possible because we have seen someone's application do exactly this kind of window on this computer.

Maybe his code was not vb ? It could have been C#.

Any ideas would be appreciated.

Thanx

  • 0

As I said, if you don't want to use the .NET Framework you'll have to either buy a copy of Visual Basic 6 if you can find it. Visual Basic and C# have been .NET for almost ten years now.

Visual Studio Express doesn't have any .NET stuff removed: it is .NET. smile.gif

The framework is included with all modern versions of Windows. Out of curiosity, why don't you want to use it?

Just to be clear, this is the Visual Studio Express family. Is that what you are using?

  • 0

Module Module1

	Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As IntPtr) As Boolean
	Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As IntPtr) As Boolean

	Sub Main()
 	For Each p As Process In Process.GetProcesses
 	If Not IsWindowVisible(p.MainWindowHandle) Then Continue For
 	Console.WriteLine(p.ProcessName) ' Just an example - You would want to add this to your program's window list.
 	BringWindowToTop(p.MainWindowHandle) ' This will bring the process's window to the top.
 	Next
	End Sub

End Module

Try that. It complies and runs fine in VBE2010. There doesn't seem to be any around using at least one or two P/Invoke commands.

Obviously you won't want to use it "as-is" since it simply loops through all the non-hidden process windows and brings them to the front, but you get the idea. :)

  • 0

thank you Grey Wolf for your code,

but it produces nothing on our computer.

we have modifed the code to make it display what it finds and it still finds nothing.

Module Module1

Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As IntPtr) As Boolean

Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As IntPtr) As Boolean

Sub Main()

For Each p As Process In Process.GetProcesses

MsgBox(p)

'If Not IsWindowVisible(p.MainWindowHandle) Then Continue For

'Console.WriteLine(p.ProcessName) ' Just an example - You would want to add this to your program's window list.

'BringWindowToTop(p.MainWindowHandle) ' This will bring the process's window to the top.

Next

End Sub

End Module

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Main()

End Sub

End Class

the interpreter likes it, runs it but there is no result. just an empty window.

we cannot figure out what is wrong here. Technically the code is correct. but it doesnt work on our system.

Any ideas ?

  • 0

Public Class Form1

	Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As IntPtr) As Boolean
	Public Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As IntPtr) As Boolean
	Dim visibleWindows As New List(Of Process)
	Dim list As New ListBox

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 	Me.Controls.Add(list)
 	list.Dock = DockStyle.Fill
 	AddHandler list.DoubleClick, AddressOf List_DoubleClick

 	For Each p As Process In Process.GetProcesses
 	If Not IsWindowVisible(p.MainWindowHandle) Then Continue For
 	list.Items.Add(p.MainWindowTitle)
 	visibleWindows.Add(p)
 	Next
	End Sub

	Private Sub List_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
 	BringWindowToTop(visibleWindows(list.SelectedIndex).MainWindowHandle)
	End Sub
End Class

Try that. I coded the listbox control into the Form_Load so you don't have to create it on the designer. Double-clicking on a window title will bring that window to the front.

  • 0

Thanx guys

Omnicoder you were right about that string thing. It should be p.ProcessName. And it correctly shows processes.

And GreyWolf we tried that new bit of code and it works exactly like u said it should. It finds all windows and can bring forward the one chosen. That was a novel strategy to find all processes and ignore processes without windows. Clever :D

Thank you all very much.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • i'm just commenting because of this madness. you simply asked "what crowd" which i too am genuinely curious about, only to receive a response in the form of a link that directs to an analysis of the audited financial statements with the accompanying notes. then you say that the guy who wrote it is stupid, which whatever, that's not an argument being discussed atm, only to receive a response from Arceles saying "i don't deal with people whose first response is an ad homenim". jesus. this is like making a claim, and then saying "i don't deal with people who speak in a certain way or swear so i'm not gonna answer you hah!" (said in a nasaly voice, not trying to depict you Arceles). then focus on the argument instead of the explanation begins... "so what don't you like about the guy (lunduke)" followed by "he just likes to insult people" and the explanation for the "crowd" being referred to was never even established. so a request for an explanation about the crowd turned into an argument about "why do you think lunduke is an idiot". wowza.
    • Sony lays off 30% of staff from Days Gone developer Bend Studio by Pulasthi Ariyasinghe Another wave of layoffs has hit the game developer space, and this time, it's a first-party Sony studio that's been affected. Following a report by Bloomberg's Jason Schreier, Bend Studio has confirmed that it is letting go of "incredibly talented teammates" as it begins work on a new game project. "Today, we said goodbye to some incredibly talented teammates as we transition to our next project," said Bend Studio in a social media post today. "We're deeply thankful for their contributions as they've shaped who we are, and their impact will always be part of our story." Bend Studio is most well-known for its 2019-released open-world zombie adventure Days Gone, which even received a remaster just a few months ago. Prior to that, the studio had been responsible for the classic Syphon Filter series while also developing several PlayStation Portable and Vita games like Resistance: Retribution and Uncharted: Golden Abyss, respectively. "This is a difficult moment for our team, but we hold immense respect for everyone who got us here," the company added. "As we move forward, we remain committed to building the future of Bend Studio with creativity, passion, and innovation in the titles we craft." While Sony did not detail just how many staff have been affected by this latest decision, Jason Schreier revealed that 30% of the studio is being laid off. This amounts to around 40 people, according to the reporter. Earlier this year, Sony canceled two live service games that were in development at Bend Studio and Bluepoint Games. It was never revealed what this mystery game was supposed to be. "Bend and Bluepoint are highly accomplished teams who are valued members of the PlayStation Studios family," Sony said at the time. It's unclear if Bluepoint, which had been developing a God of War live service experience, will soon be hit by its own wave of layoffs too.
    • KataLib 4.5.3.0 by Razvan Serea KataLib is more than just a music player — it's a complete audio suite designed for music lovers and creators alike. It combines a powerful audio player, a flexible metadata editor, a capable audio converter, and a music library manager into one streamlined application. Core Features: Audio Player Enjoy seamless playback of virtually any audio format or even streaming video files. DJ Mode lets you mix tracks with manual or automatic crossfades. You can also load and save WinAmp-style playlists for quick access to your favorite sets. Audio Converter Convert between a wide range of audio formats effortlessly. Trim or normalize your output automatically, and even extract audio from streaming video sources. Ideal for preparing files for different devices or platforms. Metadata Editor View and edit ID3v2 tags and other metadata. Batch edit multiple files at once, and fetch missing information directly from the MusicBrainz database. You can also apply or update album art with ease. Music Library Manager Organize your entire audio collection, search across tracks instantly, and download cover images from the internet — or use your own custom artwork. KataLib makes it easy to keep your library tidy and enriched with useful info. Supported Formats: KataLib supports a wide range of both lossy and lossless audio formats: Input: OPUS, AAC, FLAC, M4A, MP3, MP4, MPC, APE, AIF, MKV, AVI, MOV, FLV, WEBM, Ogg Vorbis, WAV, WAVPack, WMA Output: OPUS, FLAC, M4A, MP3, Ogg Vorbis, WAV Under the hood, KataLib uses the trusted FFmpeg engine for audio conversion and media playback, ensuring compatibility with virtually all mainstream media formats. Download: KataLib 4.5.3.0 | 64.5 MB (Open Source) Links: KataLib Home Page | Github | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • I had this issue and it is a nova android conflict issue. Initially the only way to fix it was clicking the screen off and then back on. Figured out it was because of a task I set up in tasker to load certain apps when I connect to my car, so fixed it by adding a 'go home' task after the app loaded and rarely have the issue now
    • I wish one of the windows updates hadn't broken glass. Is there a workaround for that I'm not aware of?
  • Recent Achievements

    • Reacting Well
      rshit earned a badge
      Reacting Well
    • Reacting Well
      Alan- earned a badge
      Reacting Well
    • Week One Done
      IAMFLUXX earned a badge
      Week One Done
    • One Month Later
      Æhund earned a badge
      One Month Later
    • One Month Later
      CoolRaoul earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      542
    2. 2
      ATLien_0
      269
    3. 3
      +FloatingFatMan
      210
    4. 4
      +Edouard
      203
    5. 5
      snowy owl
      140
  • Tell a friend

    Love Neowin? Tell a friend!