|
You last visited: Today at 04:58
Advertisement
C# | Fenster "unanklickbar" machen
Discussion on C# | Fenster "unanklickbar" machen within the .NET Languages forum part of the Coders Den category.
10/19/2012, 16:46
|
#1
|
elite*gold: 0
Join Date: Sep 2012
Posts: 12
Received Thanks: 4
|
C# | Fenster "unanklickbar" machen
Hallo, ich möchte meinen ersten kleinen Shooter-"Hack" fertigstellen.
Nur habe ich ein Problem:
Wenn ich den Hack benutze, kann ich nicht schießen, da der Mauszeiger ja automatisch am Crosshair (Was ja eine Form ist) oben ist. Und wenn ich klicke wird ingame sofort das Pausenmenü angezeigt, da das Fenster ja gewechselt wurde.
Ausserdem sieht man die ganze Zeit den Mauszeiger, da man ja im Fenster des Hacks drinne is ^^
Hier der Code:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Crosshair
{
public partial class Form1 : Form
{
public int fixiert = 0;
Point lastClick;
public Form1()
{
InitializeComponent();
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (fixiert == 0)
lastClick = e.Location;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (fixiert == 0)
{
if (e.Button == MouseButtons.Left)
{
this.Left += e.X - lastClick.X;
this.Top += e.Y - lastClick.Y;
}
}
}
private void Fixieren_Click(object sender, EventArgs e)
{
fixiert = 1;
Fixieren.Visible = false;
this.Size = new System.Drawing.Size(32, 32);
}
}
}
Wenn ihr meine Fragenstellung nicht versteht, probierts selbst:
Einfach irgendein Spiel im Fenstermodus öffnen und den Hack starten, ins Spiel rein, Hackfenster zum gewünschten Ort verschieben und FIX drücken
Ihr werdet merken, dass wenn ihr schießen wollt, manchmal das Hackfenster anvisiert, und das Spiel pausiert wird.
Also, wie kann ich den Mauszeiger verschwinden lassen, und wie das Hackfenster "unanklickbar" machen?
Vielen Dank im Vorraus!
|
|
|
10/19/2012, 18:10
|
#2
|
elite*gold: 0
Join Date: May 2008
Posts: 1,222
Received Thanks: 500
|
Das wäre der Code um z.B. die ganze Form unanklickbar zu machen:
Code:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
#region GWL enum
public enum GWL
{
ExStyle = -20
}
#endregion
#region LWA enum
public enum LWA
{
ColorKey = 0x1,
Alpha = 0x2
}
#endregion
#region WS_EX enum
public enum WS_EX
{
Transparent = 0x20,
Layered = 0x80000
}
#endregion
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
public static extern int GetWindowLong(IntPtr hWnd, GWL nIndex);
[DllImport("user32.dll", EntryPoint = "SetWindowLong")]
public static extern int SetWindowLong(IntPtr hWnd, GWL nIndex, int dwNewLong);
[DllImport("user32.dll", EntryPoint = "SetLayeredWindowAttributes")]
public static extern bool SetLayeredWindowAttributes(IntPtr hWnd, int crKey, byte alpha, LWA dwFlags);
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
int wl = GetWindowLong(Handle, GWL.ExStyle);
wl = wl | 0x80000 | 0x20;
SetWindowLong(Handle, GWL.ExStyle, wl);
SetLayeredWindowAttributes(Handle, 0, 128, LWA.Alpha);
}
}
}
|
|
|
10/19/2012, 18:24
|
#3
|
elite*gold: 0
Join Date: Sep 2012
Posts: 12
Received Thanks: 4
|
Quote:
Originally Posted by boxxiebabee
Das wäre der Code um z.B. die ganze Form unanklickbar zu machen:
Code:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
#region GWL enum
public enum GWL
{
ExStyle = -20
}
#endregion
#region LWA enum
public enum LWA
{
ColorKey = 0x1,
Alpha = 0x2
}
#endregion
#region WS_EX enum
public enum WS_EX
{
Transparent = 0x20,
Layered = 0x80000
}
#endregion
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
public static extern int GetWindowLong(IntPtr hWnd, GWL nIndex);
[DllImport("user32.dll", EntryPoint = "SetWindowLong")]
public static extern int SetWindowLong(IntPtr hWnd, GWL nIndex, int dwNewLong);
[DllImport("user32.dll", EntryPoint = "SetLayeredWindowAttributes")]
public static extern bool SetLayeredWindowAttributes(IntPtr hWnd, int crKey, byte alpha, LWA dwFlags);
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
int wl = GetWindowLong(Handle, GWL.ExStyle);
wl = wl | 0x80000 | 0x20;
SetWindowLong(Handle, GWL.ExStyle, wl);
SetLayeredWindowAttributes(Handle, 0, 128, LWA.Alpha);
}
}
}
|
Ist der Code von dir?
|
|
|
10/19/2012, 18:28
|
#4
|
elite*gold: 0
Join Date: May 2008
Posts: 1,222
Received Thanks: 500
|
Nö, stackoverflow. Habs dann nur selbst schnell getestet.
|
|
|
10/19/2012, 19:49
|
#5
|
elite*gold: 0
Join Date: Sep 2005
Posts: 427
Received Thanks: 87
|
Hier mal ein Beispiel nur C#, siehe
PHP Code:
public Form1() { this.FormBorderStyle = FormBorderStyle.None; this.ShowInTaskbar = false; this.WindowState = FormWindowState.Maximized; this.TopMost = true;
InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) { this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.TransparencyKey = Color.FromKnownColor(KnownColor.Control); this.Update(); }
private void Form1_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawString("+", new Font(FontFamily.GenericMonospace, 20f), Brushes.Black, new PointF((float)(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width / 2 - 10f), (float)(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height / 2 - 10f))); }
|
|
|
10/21/2012, 12:46
|
#6
|
elite*gold: 0
Join Date: Sep 2012
Posts: 12
Received Thanks: 4
|
habs jetzt mit der Drawing-Methode gemacht.
Nur auf gezeichnete Sachen kann man auch raufklicken!
Kann man das nicht irgendwie ausschalten?
Danke
|
|
|
10/21/2012, 16:02
|
#7
|
elite*gold: 0
Join Date: May 2008
Posts: 1,222
Received Thanks: 500
|
Nimm doch meine Methode, mit der funktionierts.
|
|
|
10/22/2012, 08:51
|
#8
|
elite*gold: 0
Join Date: Sep 2012
Posts: 12
Received Thanks: 4
|
Quote:
Originally Posted by boxxiebabee
Nimm doch meine Methode, mit der funktionierts. 
|
Stimmt, nur will ich diesen Code nicht benutzen, weil ich ihn nicht verstehe.
Hast du einen Link mit den Erklärungen?
|
|
|
All times are GMT +1. The time now is 04:59.
|
|