VB 2010 Express ... Target

10/16/2013 16:27 modameryou#1
Yoo..

aloha guys..


that's my first topic here ....

i wish u answer me fast

well.. i'm trying to make auto keyboard clicker

that's the code
Code:
Public Class Form1



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        SendKeys.Send("{F5}")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Stop()

    End Sub
End Class
it works perfectly i set the timer to 1000 ms ( 1 sec )

it presses F5 every 1 sec

Here goes the question

CAN I MAKE A TARGET ( PRESS F5 IN a specific PROCESS) :D

sorry for ma bad english
10/16/2013 16:58 qkuh#2
Look for SendMessage/PostMessage
10/16/2013 17:22 modameryou#3
i will try u help me if u can too
10/16/2013 22:34 berkay2578#4
Code:
    Imports System.Runtime.InteropServices
    (...)
    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Private Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean
    End Function

    Private Sub SendF5(ByVal ProcessName As String)
        Dim processes As Process() = Process.GetProcessesByName(ProcessName)
        Dim proc As Process = processes(0)
        PostMessage(proc.MainWindowHandle, &H100, &H74, 0)
    End Sub
This will work in most cases.
10/17/2013 06:57 modameryou#5
i only can put it in the public class

so it runs itself when i open the program ?

BTW this didn't work

and

(...) what these for ??

it said error and i removed them

and it asked me to move Imports System.Runtime.InteropServices

to the general

Here's how i did it

Code:
Imports System.Runtime.InteropServices

Public Class Form1
    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Private Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean
    End Function
    Private Sub SendF5(ByVal ProcessName As String)
        Dim processes As Process() = Process.GetProcessesByName(S4Client.exe)
        Dim proc As Process = processes(0)
        PostMessage(proc.MainWindowHandle, &H100, &H74, 0)
    End Sub
End Class
10/17/2013 08:16 berkay2578#6
Let's say your target process' name is "iTarget.exe". Create a timer and use SendF5("iTarget")
10/17/2013 18:19 modameryou#7
Testing

Still didn't work

Code:
Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start()
    End Sub


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Stop()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

       [B][I][U] WHAT SHOULD I WRITE HERE ! ! ! ! ! ! ! ! ! ![/U][/I][/B]
    End Sub



End Class

My client name is " S4Client.exe "
10/17/2013 18:44 berkay2578#8
You don't event know how to declare an integer in VB, do you?

sigh.. just put SendF5("S4Client")
10/17/2013 21:34 davydavekk#9
Don't c&p code, learn VB.
10/18/2013 01:04 modameryou#10
lol i tried this

i'm not that pro

but i tried to put SendF5("S4Client")

it doesn't work
10/18/2013 04:06 davydavekk#11
Quote:
Originally Posted by modameryou View Post
Code:
Imports System.Runtime.InteropServices

Public Class Form1
    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Private Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean
    End Function
    Private Sub SendF5(ByVal ProcessName As String)
        Dim processes As Process() = Process.GetProcessesByName(S4Client.exe)
        Dim proc As Process = processes(0)
        PostMessage(proc.MainWindowHandle, &H100, &H74, 0)
    End Sub
End Class
It's not gonna work because the Process.GetProcessesByName() function takes a string argument. (you forgot the " ", it should be "S4Client")

Do you have a 32 or a 64bits version of Windows ? (you may need a unhider to "find" s4's process)

EDIT : Or you do
Code:
Process.GetProcessesbyName(ProcessName) 'and like that it  should work
10/18/2013 07:13 modameryou#12
Quote:
Originally Posted by davydavekk View Post
It's not gonna work because the Process.GetProcessesByName() function takes a string argument. (you forgot the " ", it should be "S4Client")

Do you have a 32 or a 64bits version of Windows ? (you may need a unhider to "find" s4's process)

EDIT : Or you do
Code:
Process.GetProcessesbyName(ProcessName) 'and like that it  should work
i got unhider..

and i will try

it didn't work
Code:
Imports System.Runtime.InteropServices

Public Class Form1


    Public Class Form1
        <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
        Private Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean
        End Function
        Private Sub SendF5(ByVal ProcessName As String)
            Dim processes As Process() = Process.GetProcessesByName("S4Client.exe")
            Dim proc As Process = processes(0)
            PostMessage(proc.MainWindowHandle, &H100, &H74, 0)
        End Sub
    End Class
    


End Class
I'm X32 bit ..
10/18/2013 09:46 berkay2578#13
Postmessage sends inputkeys. You have to use sendmessage if target exe catches it with "preview key down" event.
10/18/2013 21:04 davydavekk#14
Try without the ".exe"