Need help to create qs bot (C#)

06/24/2011 14:34 tronsy#1
the qs bot people gave me isnt that perfect i wanna try to do a better one but i counter a problem...
there is a command in C# Sendkeys class - Send or SendWait.
i tried use that but it only press the specific char only if im focused in the textbox someone know why? please...
is there any other command that press a keystroke?

i dont care if u will help me with other language
06/24/2011 19:48 [X]Diesel#2
1 . Whats a qs bot ? Edit : Now I know it !

2. I dont really understand your Problem send wait is the time before the programm sends the command ?
06/24/2011 20:59 tronsy#3
it suppose send a keystroke to the application it focused...
here is my code:
i did that only if FT_client is focused send a keystroke with the Senkeys method:


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Windows.Forms;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Diagnostics;
using System.Timers;
using System.Runtime.InteropServices;
using System.IO;
using System.Net;
using System.Net.Mail;
using Microsoft.Win32;

using System.Security.Principal;

namespace WindowsInput
{
class Program
{
public static Process[] ft = Process.GetProcessesByName("FT_Client");
public static bool check=false;
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("User32")]
private static extern int SetForegroundWindow(IntPtr hwnd);
[DllImport("User32")]
private static extern IntPtr GetForegroundWindow();

public static Boolean checkProcesses(Process[] z)
{

IntPtr k = GetForegroundWindow();//get the focused process handle

foreach (Process p in z)
{
if (k.Equals(p.MainWindowHandle))
{
return true;

}
}
return false;
}

public static void OnTimedEvent(object source, EventArgs e)
{
if (checkProcesses(ft))
{
/*SetForegroundWindow(ft.MainWindowHandle);*/
SendKeys.SendWait("W");
InputSimulator.SimulateKeyPress(VirtualKeyCode.SPA CE);
InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_ W);
}
}

static void Main(string[] args)
{

IntPtr p = ft[0].MainWindowHandle;
System.Timers.Timer timer;
timer = new System.Timers.Timer();
timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
timer.AutoReset = true;
timer.Interval = 5000;
timer.Start();
Application.Run();
GC.KeepAlive(timer);


}
}
}




it sends the key like "W" or whatever but only if im in the texbox in fantasy tennis or in the loby somehow it doest really press w when im in lifewoods tring to use qs...i mean it send the key "w" but it doesnt press w...

it has a timer with interval i can change it to whatever i want ( its in miliseconds - 1000 mil = 1 second)

nobody can help me? i thought we have programmers here...
06/24/2011 21:18 [X]Diesel#4
Ja now I understand your Problem . Then you must wait a little bit . This Section is very little ( Bad english I mean that here are not so many Users :'D ) . You must wait ! I think any Coder comes online and then he can help you !
06/24/2011 21:25 tronsy#5
well i tried to talk with the producer of the qs bot here
he doesnt wanna share with me his code...

if i will solve this problem it will be easy to do the rest.. i will do qs bot for all the maps...