Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Visual Basic Programming › [Request] Checking a windows state.[Solved]

Question[Request] Checking a windows state.[Solved]

Posts 1–8 of 8 · Page 1 of 1
CoderNever
CoderNever
[Request] Checking a windows state.[Solved]
I want to check a process out side of visual basic's window state such as Minimized , Maximized , etc.
#1 · 16y ago
zmansquared
zmansquared
Hang on, i am lost. can you re-phrase for me?
#2 · 16y ago
CoderNever
CoderNever
say I am making a combat arms spammer , that I only want to work when combat arms is opened to its maximized state.
#3 · 16y ago
zmansquared
zmansquared
O, this beats me. wait for nextgen1 he will know the answer. he has never not
#4 · 16y ago
NextGen1
NextGen1
The code is rather extensive and requires handle , api, etc.

You use P/Invoke Window Placement

MSDN Library offers the code

Quote Originally Posted by msdn
Imports System.Runtime.InteropServices
Imports System.Environment
Imports System.IO
Imports System.ComponentModel

Public Class Form1

Private WithEvents b As New Button

Sub New()
InitializeComponent()
Process.Start(Path.Combine(GetFolderPath(SpecialFo lder.System), "notepad"))
Me.Controls.Add(b)
End Sub

Private Sub b_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles b.Click
' FindWindow is going to find the first instance...
Me.Text = "Notepad is " & NativeMethods.GetWindowState("Untitled - NotePad").ToString
End Sub

End Class


Public Class NativeMethods

<Flags()> _
Private Enum PlacementFlags As UInteger
WPF_SETMINPOSITION = 1
WPF_RESTORETOMAXIMIZED = 2
WPF_ASYNCWINDOWPLACEMENT = 4
End Enum

Private Enum ShowState As UInteger
SW_HIDE = 0 '
SW_SHOWNORMAL = 1 '
SW_SHOWMINIMIZED = 2 '
SW_SHOWMAXIMIZED = 3 '
SW_MAXIMIZE = 3 '
SW_SHOWNOACTIVATE = 4 '
SW_SHOW = 5 '
SW_MINIMIZE = 6 '
SW_SHOWMINNOACTIVE = 7 '
SW_SHOWNA = 8 '
SW_RESTORE = 9 '
End Enum

' friendly ones, just for the common ones...
Public Enum WindowState
Normal
Maximized
Minimized
End Enum

<DllImport("user32.dll")> _
Private Shared Function GetWindowPlacement( _
ByVal hWnd As IntPtr, _
ByRef windowPlacement As WindowPlacement) As Boolean
End Function

<DllImport("user32.dll", EntryPoint:="FindWindowA", CharSet:=CharSet.Ansi)> _
Public Shared Function FindWindow( _
ByVal className As String, _
ByVal WindowName As String) As IntPtr
End Function

Private Structure WindowPlacement
Public Length As UInteger
Public Flags As PlacementFlags
Public ShowCmd As ShowState
Public MinPosition As Point
Public MaxPosition As Point
Public NormalPosition As Rectangle
End Structure

Private Structure NativePoint
Public X As Integer
Public Y As Integer
End Structure

Private Structure NativeRectangle
Public X As Integer
Public Y As Integer
Public Width As Integer
Public Height As Integer
End Structure

Public Shared Function GetWindowState(ByVal WindowCaption As String) As WindowState
' So get the window handle with findwindow. I'm using the caption...
Dim hwnd As IntPtr = FindWindow(Nothing, WindowCaption)
If hwnd = IntPtr.Zero Then Throw New Exception("Window not found")
' Create the structure we pass to the api function.
Dim wp As New WindowPlacement
' Set its size parameter
wp.Length = Convert.ToUInt32(Marshal.SizeOf(GetType(WindowPlac ement)))
' Send it off
If GetWindowPlacement(hwnd, wp) = False Then Throw New Win32Exception
' It has other useful information...
Select Case wp.ShowCmd
Case ShowState.SW_SHOWMAXIMIZED
Return WindowState.Maximized
Case ShowState.SW_SHOWMINIMIZED
Return WindowState.Minimized
Case ShowState.SW_SHOWNORMAL
Return WindowState.Normal
Case Else
' this is just a demo...
Throw New Exception("wasn't a friendly one, windows state is: " & wp.ShowCmd.ToString)
End Select
Return CType(wp.ShowCmd, WindowState)
End Function

End Class
#5 · 16y ago
zmansquared
zmansquared
Wow, see never. i told you nextgen would know. he is just a freakin beast at VB
#6 · 16y ago
NO
NOOB
Quote Originally Posted by Coder Never View Post
I want to check a process out side of visual basic's window state such as Minimized , Maximized , etc.
Not as in depth as NextGen1's code but:

Code:
Private Function GetActiveWindowTitle() As String
        Dim MyStr As String
        MyStr = New String(Chr(0), 100)
        GetWindowText(GetForegroundWindow, MyStr, 100)
        MyStr = MyStr.Substring(0, InStr(MyStr, Chr(0)) - 1)
        Return MyStr
    End Function
Use:
Code:
If GetActiveWindowTitle() = "Untitled - Notepad" Then
            'Whatever you want to get done. Auto spam?
        End If
This will make your spammer only work when Combat Arms is the active window. If Combat Arms is maximized, but not Active (or foreground) then the spammer will not work either. So this code works as well.
#7 · 16y ago
Invidus
Invidus
naww stick to NextGen's code. And /bump.
#8 · 16y ago
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

  • Help, Check If windows is shutting down!By Zoom in Visual Basic Programming
    6Last post 16y ago
  • Check if windows shutdown/restartBy Zoom in Visual Basic Programming
    11Last post 16y ago
  • REQUEST check that pleaseBy amahones in All Points Bulletin Reloaded Hacks
    2Last post 15y ago
  • Window mod[Solved]By amitbachar12 in Combat Arms EU Discussions
    10Last post 16y ago

Tags for this Thread

None