Results 1 to 3 of 3
  1. #1
    jaydeeph's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    85
    Reputation
    10
    Thanks
    382
    My Mood
    Cheeky

    FindWindow + GetForegroundWindow comparing VB.NET

    Wusup AVA coders/players,

    So I'm trying to see if AVA window is active or not. But for some reason it's not working. I cannot detect exactly what I'm doing wrong.

    Import DLL I am using: There are different ways but I'm using this.
    Code:
    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
        Private Shared Function FindWindow( _
            ByVal lpClassName As String, _
            ByVal lpWindowName As String) As IntPtr
        End Function
    
        <DllImport("user32.dll", SetLastError:=True)> _
        Private Shared Function GetForegroundWindow() As IntPtr
        End Function
    
        <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
        Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, _
            ByVal childAfter As IntPtr, _
            ByVal lclassName As String, _
            ByVal windowTitle As String) As IntPtr
        End Function
    ^ I know I don't need the child window, but I just have it there.

    This is what I'm trying to do after:
    Code:
    Dim Trigger As Boolean = GetAsyncKeyState(Keys.LButton)
    Dim avaWndw As IntPtr = FindWindow("AVAWindowClass", "Alliance of Valiant Arms")
    Dim FGW As IntPtr = GetForegroundWindow()
    
    If avaWndw = FGW Then
        If Trigger = True Then
            'Macro code here.
        End If
    End If
    Inside the the double If statements, I have my macro code's. Now When AVA is running the macro wont be triggered. However if I comment out the first if statement, then the macro works perfectly fine. Is the way I'm importing the DLL wrong? Or what am I doing wrong?

  2. #2
    R3DDOT's Avatar
    Join Date
    Dec 2013
    Gender
    male
    Location
    C://Windows/system32
    Posts
    347
    Reputation
    38
    Thanks
    2,366
    My Mood
    Cheerful
    Quote Originally Posted by jaydeeph View Post
    Wusup AVA coders/players,

    So I'm trying to see if AVA window is active or not. But for some reason it's not working. I cannot detect exactly what I'm doing wrong.

    Import DLL I am using: There are different ways but I'm using this.
    Code:
    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
        Private Shared Function FindWindow( _
            ByVal lpClassName As String, _
            ByVal lpWindowName As String) As IntPtr
        End Function
    
        <DllImport("user32.dll", SetLastError:=True)> _
        Private Shared Function GetForegroundWindow() As IntPtr
        End Function
    
        <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
        Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, _
            ByVal childAfter As IntPtr, _
            ByVal lclassName As String, _
            ByVal windowTitle As String) As IntPtr
        End Function
    ^ I know I don't need the child window, but I just have it there.

    This is what I'm trying to do after:
    Code:
    Dim Trigger As Boolean = GetAsyncKeyState(Keys.LButton)
    Dim avaWndw As IntPtr = FindWindow("AVAWindowClass", "Alliance of Valiant Arms")
    Dim FGW As IntPtr = GetForegroundWindow()
    
    If avaWndw = FGW Then
        If Trigger = True Then
            'Macro code here.
        End If
    End If
    Inside the the double If statements, I have my macro code's. Now When AVA is running the macro wont be triggered. However if I comment out the first if statement, then the macro works perfectly fine. Is the way I'm importing the DLL wrong? Or what am I doing wrong?
    No, all imports are okay. The problem is the window's class name. When using FindWindow(), you need to input the name of the window class for whatever window you want, since in this case it's AVA, the its' name is "LaunchUnrealUWindowsClient" (You find the class's name using Spy++).

  3. The Following User Says Thank You to R3DDOT For This Useful Post:

    jaydeeph (05-17-2014)

  4. #3
    jaydeeph's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    85
    Reputation
    10
    Thanks
    382
    My Mood
    Cheeky
    Quote Originally Posted by R3DDOT View Post

    No, all imports are okay. The problem is the window's class name. When using FindWindow(), you need to input the name of the window class for whatever window you want, since in this case it's AVA, the its' name is "LaunchUnrealUWindowsClient" (You find the class's name using Spy++).
    Thanks @R3DDOT. I see where I was going wrong. And thanks for the Spy++ didn't know about that feature .

    Edit: Thanks a lot my friend. Found it and working .
    Edit 2: I didn't realise you gave me its' name already. Until I went into Spy++ and then I realised you gave it to me. Haha :P
    Last edited by jaydeeph; 05-17-2014 at 05:34 AM. Reason: Extra thanking.

Similar Threads

  1. .NET section?
    By smacksnox in forum Programming
    Replies: 4
    Last Post: 08-27-2006, 12:14 AM
  2. HackShardGaming.net says Fuck MPGH
    By sf0d in forum General
    Replies: 32
    Last Post: 07-26-2006, 09:05 PM
  3. [Help] Atom API with Visual Basic 6.0 or .NET
    By Bull3t in forum Visual Basic Programming
    Replies: 5
    Last Post: 07-23-2006, 09:21 AM
  4. Me r MAD.. GONNA DDOS WarRock.net :)
    By System79 in forum WarRock - International Hacks
    Replies: 14
    Last Post: 06-19-2006, 05:06 PM
  5. Gangsterhood.net
    By supatanka in forum Hack Requests
    Replies: 0
    Last Post: 01-22-2006, 01:42 PM