Advertisement
ledlight

Windows notepad position and size.

Apr 25th, 2025
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VisualBasic 1.48 KB | Software | 0 0
  1. Imports System.Runtime.InteropServices
  2.  
  3. Module Module1
  4.     <DllImport("user32.dll")>
  5.     Public Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
  6.     End Function
  7.  
  8.     <DllImport("user32.dll")>
  9.     Public Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr,
  10.                                  ByVal X As Integer, ByVal Y As Integer,
  11.                                  ByVal cx As Integer, ByVal cy As Integer,
  12.                                  ByVal uFlags As UInteger) As Boolean
  13.     End Function
  14.  
  15.     Sub Main()
  16.         ' AOT ohne JIT Prüfung
  17.        If Type.GetType("System.Runtime.JitInfo") Is Nothing Then
  18.             Console.WriteLine("Läuft ohne JIT.")
  19.         Else
  20.             Console.WriteLine("JIT wird verwendet.")
  21.         End If
  22.  
  23.         ' Notepad starten
  24.        Dim process As New Process()
  25.         process.StartInfo.FileName = "notepad.exe"
  26.         process.Start()
  27.         Threading.Thread.Sleep(2000) ' Wartezeit für vollständiges Laden
  28.  
  29.         ' Fenster-Handle abrufen
  30.        Dim hWnd As IntPtr = FindWindow("Notepad", Nothing)
  31.         If hWnd = IntPtr.Zero Then
  32.             Console.WriteLine("Notepad-Fenster nicht gefunden.")
  33.             Return
  34.         End If
  35.  
  36.         ' Fenster auf Position (X=200, Y=200) setzen mit Größe 800x600
  37.        SetWindowPos(hWnd, IntPtr.Zero, 917, 200, 913, 600, 0)
  38.         Console.WriteLine("Notepad-Fenster wurde erfolgreich verschoben.")
  39.     End Sub
  40. End Module
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement