Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 04:58

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C# | Fenster "unanklickbar" machen

Discussion on C# | Fenster "unanklickbar" machen within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2012
Posts: 12
Received Thanks: 4
Question 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:

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!
meldino is offline  
Old 10/19/2012, 18:10   #2

 
boxxiebabee's Avatar
 
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);
        }
    }
}
boxxiebabee is offline  
Old 10/19/2012, 18:24   #3
 
elite*gold: 0
Join Date: Sep 2012
Posts: 12
Received Thanks: 4
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?
meldino is offline  
Old 10/19/2012, 18:28   #4

 
boxxiebabee's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,222
Received Thanks: 500
Nö, stackoverflow. Habs dann nur selbst schnell getestet.
boxxiebabee is offline  
Old 10/19/2012, 19:49   #5
 
kissein's Avatar
 
elite*gold: 0
Join Date: Sep 2005
Posts: 427
Received Thanks: 87
Hier mal ein Beispiel nur C#, siehe
kissein is offline  
Old 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
meldino is offline  
Old 10/21/2012, 16:02   #7

 
boxxiebabee's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,222
Received Thanks: 500
Nimm doch meine Methode, mit der funktionierts.
boxxiebabee is offline  
Old 10/22/2012, 08:51   #8
 
elite*gold: 0
Join Date: Sep 2012
Posts: 12
Received Thanks: 4
Quote:
Originally Posted by boxxiebabee View Post
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?
meldino is offline  
Reply




All times are GMT +1. The time now is 04:59.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.