Check External Application is Minimize or Show
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Check External Application is Minimize or Show

  1. #1
    Join Date
    Jan 2009
    Posts
    160

    Check External Application is Minimize or Show

    I have the following codes:

    Code:
    
    Public Class uiKeyLogger
        <Flags()> _
    Private Enum SHOW_WINDOW As Integer
            SW_HIDE = 0
            SW_SHOWNORMAL = 1
            SW_NORMAL = 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
            SW_SHOWDEFAULT = 10
            SW_FORCEMINIMIZE = 11
            SW_MAX = 11
        End Enum
    
        Dim result As Integer
        Dim boolExist As Boolean = False
        Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
        Private Declare Function ShowWindow Lib "user32.dll" ( _
    ByVal hWnd As IntPtr, _
    ByVal nCmdShow As SHOW_WINDOW _
    ) As Boolean
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            For i = 1 To 255
                result = 0
                result = GetAsyncKeyState(i) 'gets the key state
    
                If result = -32767 Then 'if a known key is pressed, it will be displayed in the textbox1
                    If Chr(i) = "t" Then
                        For Each p As Process In Process.GetProcessesByName("CashReceipt")
                            ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_RESTORE)
                            boolExist = True
                        Next p
    
                        If boolExist = False Then
                            Process.Start("C:\Users\cmchong\Desktop\TFS_CASH_RECEIPT\CashReceipt.exe")
                        End If
    
                        boolExist = False
                    End If
                End If
            Next i
    
        End Sub
    
        Private Sub uiKeyLogger_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            btnStart_Click(sender, New EventArgs())
        End Sub
    
        Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
            ShowInTaskbar = False
            Timer1.Enabled = True
            Me.Hide()
        End Sub
    
        Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
            End
        End Sub
    End Class

    Unfortunately, this codes will always restore the external application. How can I amend the codes if the external application was restore, it will be minimize or if the application was minimized, then it will be restored.

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: Check External Application is Minimize or Show

    We can't help with KEYLOGGERS, according to the AUP (bottom of every page)
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center