Hello.... i got an question. Is there any way that C# can use "right click" or press a key , like "F1" or any others...?
Send/PostMessage API can do that but as you're in CO Programming section that wont suit your needs, because that gets you send to clickjail.Quote:
Hello.... i got an question. Is there any way that C# can use "right click" or press a key , like "F1" or any others...?
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class Form1 : Form
{
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
public Form1()
{
}
public void DoMouseClick()
{
//Call the imported function with the cursor's current position
int X = Cursor.Position.X;
int Y = Cursor.Position.Y;
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
}
//...other code needed for the application
}
I thought it was only click jail if u sent to a background window? If im wrong, bummer, if im not, then C# has the SendKeys package as well, which can be used for sending keyboard presses. [Only registered and activated users can see links. Click Here To Register...]Quote:
Send/PostMessage API can do that but as you're in CO Programming section that wont suit your needs, because that gets you send to clickjail.
I've tried Send/Postmessage with client on top and got me clickjailed, tried on top and in background both same result :)Quote:
I thought it was only click jail if u sent to a background window? If im wrong, bummer, if im not, then C# has the SendKeys package as well, which can be used for sending keyboard presses. [Only registered and activated users can see links. Click Here To Register...]
public class Mouse
{
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetCursorPos(int X, int Y);
[DllImport("user32.dll")]
public static extern void mouse_event(uint dwFlags, long dx, long dy,
uint dwData, IntPtr dwExtraInfo);
public static void Move(ushort xpos, ushort ypos)
{
SetCursorPos((int)xpos, (int)ypos);
}
public static void LeftClick()
{
mouse_event(0x02, 0, 0, 0, IntPtr.Zero);
mouse_event(0x04, 0, 0, 0, IntPtr.Zero);
}
public static void LeftClick(ushort xpos, ushort ypos)
{
Move(xpos, ypos);
LeftClick();
}
public static void LeftDrag(ushort to_x, ushort to_y)
{
mouse_event(0x02, 0, 0, 0, IntPtr.Zero);
Move(to_x, to_y);
mouse_event(0x04, 0, 0, 0, IntPtr.Zero);
}
public static void RightClick()
{
mouse_event(0x08, 0, 0, 0, IntPtr.Zero);
mouse_event(0x10, 0, 0, 0, IntPtr.Zero);
}
public static void RightClick(ushort xpos, ushort ypos)
{
Move(xpos, ypos);
RightClick();
}
public static void RightDrag(ushort to_x, ushort to_y)
{
mouse_event(0x08, 0, 0, 0, IntPtr.Zero);
Move(to_x, to_y);
mouse_event(0x10, 0, 0, 0, IntPtr.Zero);
}
public static void LeftHold(TimeSpan wait)
{
mouse_event(0x02, 0, 0,0, IntPtr.Zero);
System.Threading.Thread.Sleep(wait);
mouse_event(0x04, 0, 0, 0, IntPtr.Zero);
}
public static void LeftHold(int millisecondwait)
{
LeftHold(new TimeSpan(0, 0, 0, 0, millisecondwait));
}
}