• 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

    • 3.19.1 is out $ iperf3.exe -v iperf 3.19.1 (cJSON 1.7.15) CYGWIN_NT-10.0-19045 i9-win 3.6.4-1.x86_64 2025-07-15 07:55 UTC x86_64 Optional features available: CPU affinity setting, authentication, support IPv4 don't fragment, POSIX threads CRC32: BB95604E MD5: 201792CDD56975A3C68A7FE9F99D7B80 SHA-1: 92D6579AF3C917923B41BEC81C5BC80F6E4B4A9A SHA-256: 9A84118CD8EABB14A0FDA4FFA782DD5668E4461031D8AB119480BF9B09E3DC04 https://files.budman.pw/iperf3.19.1_64.zip $ iperf3.exe -c 192.168.10.10 Connecting to host 192.168.10.10, port 5201 [  5] local 192.168.10.9 port 19206 connected to 192.168.10.10 port 5201 [ ID] Interval           Transfer     Bitrate [  5]   0.00-1.00   sec   428 MBytes  3.58 Gbits/sec [  5]   1.00-2.01   sec   427 MBytes  3.55 Gbits/sec [  5]   2.01-3.01   sec   421 MBytes  3.55 Gbits/sec [  5]   3.01-4.01   sec   426 MBytes  3.55 Gbits/sec [  5]   4.01-5.00   sec   419 MBytes  3.55 Gbits/sec [  5]   5.00-6.01   sec   426 MBytes  3.55 Gbits/sec [  5]   6.01-7.01   sec   427 MBytes  3.55 Gbits/sec [  5]   7.01-8.01   sec   421 MBytes  3.55 Gbits/sec [  5]   8.01-9.00   sec   420 MBytes  3.55 Gbits/sec [  5]   9.00-10.01  sec   426 MBytes  3.54 Gbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval           Transfer     Bitrate [  5]   0.00-10.01  sec  4.14 GBytes  3.55 Gbits/sec                  sender [  5]   0.00-10.02  sec  4.14 GBytes  3.55 Gbits/sec                  receiver iperf Done. Release notes: Security fixes seems like only updates. https://github.com/esnet/iperf/blob/master/RELNOTES.md    
    • Microsoft Edge 138.0.3351.109 by Razvan Serea Microsoft Edge is a super fast and secure web browser from Microsoft. It works on almost any device, including PCs, iPhones and Androids. It keeps you safe online, protects your privacy, and lets you browse the web quickly. You can even use it on all your devices and keep your browsing history and favorites synced up. Built on the same technology as Chrome, Microsoft Edge has additional built-in features like Startup boost and Sleeping tabs, which boost your browsing experience with world class performance and speed that are optimized to work best with Windows. Microsoft Edge security and privacy features such as Microsoft Defender SmartScreen, Password Monitor, InPrivate search, and Kids Mode help keep you and your loved ones protected and secure online. Microsoft Edge has features to keep both you and your family protected. Enable content filters and access activity reports with your Microsoft Family Safety account and experience a kid-friendly web with Kids Mode. The new Microsoft Edge is now compatible with your favorite extensions, so it’s easy to personalize your browsing experience. Microsoft Edge 138.0.3351.109 changelog: Fixed various bugs, feature updates, and performance issues for Stable Channel. Stable channel security updates are listed here. Feature updates Edge contextual capabilities in Business Chat work tab. Microsoft Copilot in Edge now supports page summarization and contextual queries to the Work tab for Microsoft 365 Copilot Business Chat. With this feature, users can ask Copilot contextual queries such as “summarize this page.” This feature also includes contextual prompt suggestions to help users ask relevant questions about open pages in Edge. Page summarization and contextual prompt suggestions is accessible for users when using Copilot through the Edge side pane. A Microsoft 365 Copilot license is required to use this feature. Administrators can control the availability using the EdgeEntraCopilotPageContext policy. Download: Microsoft Edge (64-bit) | 178.0 MB (Freeware) Download: Microsoft Edge (32-bit) | 161.0 MB View: Microsoft Edge Website | Release History Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • The publishing backend for game developers is 10x worse
    • Weekend PC Game Deals: Sim fests, bundled Sniper Elite, a tower defense freebie, and more by Pulasthi Ariyasinghe Weekend PC Game Deals is where the hottest gaming deals from all over the internet are gathered into one place every week for your consumption. So kick back, relax, and hold on to your wallets. Over in the bundle space, Humble introduced the Sniper Elite Classics Collection for those wanting some stealth shooter experiences. The bundle begins with Sniper Elite 3, its season pass, Sniper Elite V2 Remastered, as well as the original Sniper Elite for $6. Moving up a tier for the $10 offer gets you Sniper Elite 4: Deluxe Edition. Lastly, paying $14 gets you Sniper Elite 5 to complete the bundle. The bundle has a couple of weeks left on its counter before expiring. The Epic Games Store's latest freebie for the masses is a copy of Legion TD 2 this week. This is a hit tower defense game that first debuted as a Warcraft 3 mod rivaling the likes of DotA. The gameplay revolves around defending your king from waves of enemy attacks. For this, you can build an army using the over 100 unique fighters available, each landing with their own bonuses and quirks. Over 12 million possible combinations are there for making armies as well. The Legion TD 2 giveaway will last until July 31, which is also when Pilgrims and Keylocker will become freebies. Big Deals The latest discounts on offer arrive from the latest simfest that's running, a few publisher specials, a Germany-made games collection, and more. Here's our handpicked big deals list for the weekend: Kingdom Come: Deliverance II – $41.99 on Steam Warhammer 40,000: Space Marine 2 – $32.99 on Steam DayZ – $24.99 on Steam OCTOPATH TRAVELER – $23.99 on Steam OCTOPATH TRAVELER II – $23.99 on Steam Frostpunk 2 – $23.36 on Gamebillet Per Aspera – $20.99 on Steam Hunt: Showdown 1896 – $19.99 on Steam V Rising – $17.49 on Steam Bus Simulator 21 Next Stop – $17.49 on Steam Star Trucker – $16.24 on Steam Dead Island 2 – $14.99 on Steam Crusader Kings III – $14.99 on Steam Dead Island 2 – $14.99 on Steam Loco Motive – $14.39 on Steam Tropico 6 – $13.99 on Steam Laysara: Summit Kingdom – $13.99 on Steam Shadows of Doubt – $13.74 on Steam Firefighting Simulator - The Squad – $12.49 on Steam Eastward – $12.49 on Steam Wargroove 2 – $11.99 on Steam Wildfrost – $11.99 on Steam Assassin's Creed Odyssey – $11.99 on Steam Warhammer 40,000: Boltgun – $10.99 on Steam Let's School – $9.99 on Steam Little Nightmares II – $9.89 on Steam CODE VEIN – $8.99 on Steam TerraScape – $8.99 on Steam Dorfromantik – $8.39 on Steam Monster Sanctuary – $7.49 on Steam The Outer Worlds – $7.49 on Steam Cloudpunk – $6.99 on Steam The Dark Pictures Anthology: Man of Medan – $6.59 on Steam TerraTech – $6.24 on Steam Descenders – $6.24 on Steam Starbound – $5.99 on Steam Wargroove – $5.99 on Steam My Time at Portia – $5.99 on Steam Saints Row IV: Re-Elected – $4.99 on Steam Axiom Verge – $4.99 on Steam Manifold Garden – $4.99 on Steam Model Builder: Complete Edition – $4.99 on Steam Stronghold: Definitive Edition – $4.94 on Steam Pathway – $4.79 on Steam Amnesia: Rebirth – $4.49 on Steam Iron Harvest – $4.49 on Steam INMOST – $4.49 on Steam Frostpunk – $4.49 on Steam FOR HONOR – $4.49 on Steam Arma 3 – $4.49 on Steam Chorus – $3.74 on Steam Plague Inc: Evolved – $3.74 on Steam Loop Hero – $3.74 on Steam 60 Seconds! Reatomized – $2.49 on Steam Goat Simulator – $1.99 on Steam UnderMine – $1.99 on Steam Legion TD 2 – $0 on Epic Store DRM-free Specials The GOG store's own DRM-free weekend deals are live too. Here are some highlights: Timberborn - $24.49 on GOG Citizen Sleeper 2: Starward Vector - $18.74 on GOG Fallout 4: Game of the Year Edition - $15.99 on GOG Shadow Empire - $15.99 on GOG The Talos Principle 2 - $14.99 on GOG Stellaris - $9.99 on GOG Neverwinter Nights: Enhanced Edition - $9.99 on GOG Opus Magnum - $9.99 on GOG Katana ZERO - $8.99 on GOG SPORE Collection - $7.49 on GOG Starbound - $5.99 on GOG Kingdom Come: Deliverance - $5.99 on GOG Crysis - $4.99 on GOG Chorus - $4.99 on GOG Pathway - $4.79 on GOG UnderRail - $4.49 on GOG CrossCode - $3.99 on GOG Blood Omen: Legacy of Kain - $3.49 on GOG Fallout 2 - $2.49 on GOG Medal of Honor: Pacific Assault - $2.49 on GOG Prince of Persia: The Sands of Time - $1.99 on GOG EVERSPACE - $0.99 on GOG Keep in mind that availability and pricing for some deals could vary depending on the region. That's it for our pick of this weekend's PC game deals, and hopefully, some of you have enough self-restraint not to keep adding to your ever-growing backlogs. As always, there are an enormous number of other deals ready and waiting all over the interwebs, as well as on services you may already subscribe to if you comb through them, so keep your eyes open for those, and have a great weekend.
    • before you sign up for Tea, apart from selfie and ID photos, you are required to submit your location and birth date. There are leaked driver licence too : https://x.com/ZTobias114838/status/1948781407859323395
  • Recent Achievements

    • Week One Done
      hhgygy earned a badge
      Week One Done
    • One Month Later
      hhgygy earned a badge
      One Month Later
    • One Year In
      NIKI77 earned a badge
      One Year In
    • Week One Done
      artistro08 earned a badge
      Week One Done
    • Dedicated
      Balaji Kumar earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      639
    2. 2
      ATLien_0
      237
    3. 3
      Xenon
      166
    4. 4
      neufuse
      144
    5. 5
      +FloatingFatMan
      122
  • Tell a friend

    Love Neowin? Tell a friend!