[VB.NET] Need a little help

06/26/2011 02:31 Murgen#1
I created a windows tool to minimize, maximize, hide, and show sro_client in vb.net. It works great, but how is a way to make it list the clients, and make it possible to rename them and chose them to hide, because mine only supports one client ^^

Code:
Imports System.Runtime.InteropServices 'Import #1
Imports System.Diagnostics 'Import #2
Public Class Form1
    Const SW_HIDE As Integer = 0 'Hide Widnow
    Const SW_RESTORE As Integer = 9 'Show Window
    Const SW_MINIMIZE As Integer = 6 'Minimize Window
    Const SW_MAXIMIZE As Integer = 3 'Maximize Window
    Dim hWnd As Integer 'Special command
    Dim p As Process() = Process.GetProcessesByName("sro_client") 'Process Name
    <DllImport("User32")> Private Shared Function ShowWindow(ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer 'dll Imports
    End Function

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        hWnd = p(0).MainWindowHandle.ToInt32 'Handle Window
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
         ShowWindow(hWnd, SW_HIDE) 'Hide Window Button
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ShowWindow(hWnd, SW_RESTORE) 'Show Window Button
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ShowWindow(hWnd, SW_MINIMIZE) 'Minimize Window Button
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        ShowWindow(hWnd, SW_MAXIMIZE) 'Maximize Window Button
    End Sub
End Class
06/26/2011 12:37 Kraizy​#2
Loop all processes and ask if ProcessName = "SRO_Client" and save MainWindowHandle.
06/26/2011 18:20 xXTraXx#3
BTW if you are using .NET (and not vb6) the handle is an IntPtr, not a integer ;). (I know if you use integer it will work too, but IntPtr is better ;))
06/26/2011 18:25 vorosmihaly#4
in c# I'd do this like this:
Quote:
Process[] AllProcesses = Process.GetProcesses();
List<Process> Sro_clients = new List<Process>();
foreach(Process process in AllProcesses)
{
if(process.Name == "SRO_Client")
{
Sro_clients.Add(process);
}
}
then you can work with that list..^^
good luck with your project! :)
06/26/2011 23:19 Murgen#5
Quote:
Originally Posted by vorosmihaly View Post
in c# I'd do this like this:


then you can work with that list..^^
good luck with your project! :)
I will convert that and see what I get.

Btw, your domain is suspended.
06/27/2011 13:26 chea77er#6
BTW: You can use
Code:
List<Process> sro_clients = new List<Process>();
sro_clients.AddRange(Process.getprocessesbyname("sro_client");
06/29/2011 23:45 ÑõÑ_Ŝŧóp#7
here you can do it with autoshit aka autoit :D!
Quote:
#include <GuiListBox.au3>

$win = WinList("[CLASS:CLIENT]")
For $i = 1 To $win[0][0]
_AddToList($win[$i][0])
Next

Func _AddToList($string)
_GUICtrlListBox_AddString($list,$string)
EndFunc
i hope i helped :)