CS中AWP盲狙瞄准器
严重参考FLASHELF DX的文章:http://www.cnblogs.com/flashelf/archive/2006/10/07/522777.html
呵呵,基本算是抄袭,就是瞄准器根据自己习惯改了下。
学习了一点GDI的东西,顺便记下来。扬州移动出差,偷写。 :-)
主要是通过GetDC API获得桌面的句柄,再根据该句柄创建Graphics对象。
PS:笔记本测试,发现失败,进入CS1.5后,瞄准镜消失,无法最前。有了解的,大家帮忙!!!!!!
代码及程序点击下载
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace cs_cheat
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class CS_CHEAT : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem_config;
private System.Windows.Forms.MenuItem menuItem_exit;
private System.Windows.Forms.MenuItem menuItem_640;
private System.Windows.Forms.MenuItem menuItem_1650;
private System.Windows.Forms.MenuItem menuItem_800;
private System.Windows.Forms.MenuItem menuItem_1024;
private System.Windows.Forms.MenuItem menuItem1;
private System.ComponentModel.IContainer components;
[DllImport("User32.dll")]
public extern static System.IntPtr GetDC(System.IntPtr hWnd);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern bool InvalidateRect(IntPtr hWnd,IntPtr lpRect ,bool bErase);
int x=839;
int y=525;
int w=4;
System.IntPtr DesktopHandle = GetDC(System.IntPtr.Zero);
public CS_CHEAT()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
Windows 窗体设计器生成的代码
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new CS_CHEAT());
}
private void timer1_Tick(object sender, System.EventArgs e)
{
Graphics g = System.Drawing.Graphics.FromHdc(DesktopHandle);
g.FillRectangle(Brushes.Lime,x,y,w,w);
g.FillRectangle(Brushes.Lime,x-15,y,10,w);
g.FillRectangle(Brushes.Lime,x+5+w,y,10,w);
g.FillRectangle(Brushes.Lime,x,y-15,w,10);
g.FillRectangle(Brushes.Lime,x,y+5+w,w,10);
}
private void menuItem_exit_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void Form1_Closed(object sender, System.EventArgs e)
{
InvalidateRect(IntPtr.Zero,IntPtr.Zero,false);
}
private void menuItem_800_Click(object sender, System.EventArgs e)
{
x=399;
y=300;
InvalidateRect(IntPtr.Zero,IntPtr.Zero,false);
}
private void menuItem_1024_Click(object sender, System.EventArgs e)
{
x=511;
y=384;
InvalidateRect(IntPtr.Zero,IntPtr.Zero,false);
}
private void menuItem_640_Click(object sender, System.EventArgs e)
{
x=319;
y=240;
InvalidateRect(IntPtr.Zero,IntPtr.Zero,false);
}
private void menuItem_1650_Click(object sender, System.EventArgs e)
{
x=839;
y=525;
InvalidateRect(IntPtr.Zero,IntPtr.Zero,false);
}
}
}
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace cs_cheat
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class CS_CHEAT : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem_config;
private System.Windows.Forms.MenuItem menuItem_exit;
private System.Windows.Forms.MenuItem menuItem_640;
private System.Windows.Forms.MenuItem menuItem_1650;
private System.Windows.Forms.MenuItem menuItem_800;
private System.Windows.Forms.MenuItem menuItem_1024;
private System.Windows.Forms.MenuItem menuItem1;
private System.ComponentModel.IContainer components;
[DllImport("User32.dll")]
public extern static System.IntPtr GetDC(System.IntPtr hWnd);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern bool InvalidateRect(IntPtr hWnd,IntPtr lpRect ,bool bErase);
int x=839;
int y=525;
int w=4;
System.IntPtr DesktopHandle = GetDC(System.IntPtr.Zero);
public CS_CHEAT()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
Windows 窗体设计器生成的代码
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new CS_CHEAT());
}
private void timer1_Tick(object sender, System.EventArgs e)
{
Graphics g = System.Drawing.Graphics.FromHdc(DesktopHandle);
g.FillRectangle(Brushes.Lime,x,y,w,w);
g.FillRectangle(Brushes.Lime,x-15,y,10,w);
g.FillRectangle(Brushes.Lime,x+5+w,y,10,w);
g.FillRectangle(Brushes.Lime,x,y-15,w,10);
g.FillRectangle(Brushes.Lime,x,y+5+w,w,10);
}
private void menuItem_exit_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void Form1_Closed(object sender, System.EventArgs e)
{
InvalidateRect(IntPtr.Zero,IntPtr.Zero,false);
}
private void menuItem_800_Click(object sender, System.EventArgs e)
{
x=399;
y=300;
InvalidateRect(IntPtr.Zero,IntPtr.Zero,false);
}
private void menuItem_1024_Click(object sender, System.EventArgs e)
{
x=511;
y=384;
InvalidateRect(IntPtr.Zero,IntPtr.Zero,false);
}
private void menuItem_640_Click(object sender, System.EventArgs e)
{
x=319;
y=240;
InvalidateRect(IntPtr.Zero,IntPtr.Zero,false);
}
private void menuItem_1650_Click(object sender, System.EventArgs e)
{
x=839;
y=525;
InvalidateRect(IntPtr.Zero,IntPtr.Zero,false);
}
}
}