C# | Fenster "unanklickbar" machen

10/19/2012 16:46 meldino#1
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:

Wenn ihr meine Fragenstellung nicht versteht, probierts selbst:
[Only registered and activated users can see links. Click Here To Register...]

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 boxxiebabee#2
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 meldino#3
Quote:
Originally Posted by boxxiebabee View Post
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 boxxiebabee#4
Nö, stackoverflow. Habs dann nur selbst schnell getestet.
10/19/2012 19:49 kissein#5
Hier mal ein Beispiel nur C#, siehe [Only registered and activated users can see links. Click Here To Register...]
10/21/2012 12:46 meldino#6
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 boxxiebabee#7
Nimm doch meine Methode, mit der funktionierts. :facepalm:
10/22/2012 08:51 meldino#8
Quote:
Originally Posted by boxxiebabee View Post
Nimm doch meine Methode, mit der funktionierts. :facepalm:
Stimmt, nur will ich diesen Code nicht benutzen, weil ich ihn nicht verstehe.
Hast du einen Link mit den Erklärungen?