1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
Option Explicit On
Imports System.Threading
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Threading.Tasks
Public Class Form1
<DllImport("user32.dll")>
Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Boolean
End Function 'pour positionner la fenêtre de pywin64.exe
<DllImport("user32.dll")>
Shared Function SetWindowText(ByVal hwnd As IntPtr, ByVal windowName As String) As Boolean
End Function 'pour changer le titre de la fenêtre de pywin64.exe
Public pInfoPy As New ProcessStartInfo()
Public pywin1 As Process
Public pywin2 As Process
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
pInfoPy.FileName = "C:\Windows\System32\cmd.exe"
pywin1 = Process.Start(pInfoPy) 'lance le process pywin1
Thread.Sleep(100) 'tempo 100 ms
SetWindowPos(pywin1.MainWindowHandle, IntPtr.Zero, 600, 0, 600, 1000, 0) 'Positionne et dimensionne la fenêtre du process actif
End Sub
Public Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
pInfoPy.FileName = "C:\Windows\System32\notepad.exe"
pywin2 = Process.Start(pInfoPy) 'lance le process pywin2
Thread.Sleep(100) 'tempo 100 ms
SetWindowPos(pywin2.MainWindowHandle, IntPtr.Zero, 1250, 0, 650, 1000, 0) 'Positionne et dimensionne la fenêtre du process actif
End Sub
Public Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If pywin1 Is Nothing And pywin2 Is Nothing Then Exit Sub
If pywin1 Is Nothing Then pywin2.Kill() : Exit Sub
If pywin2 Is Nothing Then pywin1.Kill() : Exit Sub
If pywin1.HasExited() Then Else pywin1.Kill()
If pywin2.HasExited() Then Exit Sub Else pywin2.Kill()
End Sub
End Class |
Partager