Autor Beitrag
Kuehter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30
Erhaltene Danke: 1



BeitragVerfasst: Do 19.11.15 08:57 
habe folgendes Problem. Das Programm was ich habe wird minimiert wenn ich es will, so weit richtig. Nur wenn ich wieder hoch holen möchte geht das nicht ohne weiteres. Kann mir da einer helfen? Glaube das liegt daran das der HotKey nicht Global in Windows hinterlegt ist. Etwas Quellcode wäre auch gut, denn NHotKey in NuGet habe ich schon ausprobiert.
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case Hotkey.WM_HOTKEY_MSG_ID:
                    switch ((int)m.WParam)
                    {
                        case 0:
                            if (this.WindowState == FormWindowState.Normal)
                            {
                                this.WindowState = FormWindowState.Minimized;
                                this.ShowInTaskbar = false;
                                this.ni_Icon.Visible = true;
                            }

                            else
                            {
                                this.ShowInTaskbar = true;
                                this.Show();
                                this.ni_Icon.Visible = false;
                            }
                            break;
                    }
                    break;
            }
            base.WndProc(ref m);
        }

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
        private Hotkey HK;
        public f_MainForm()
        {
            InitializeComponent();
            HK = new Hotkey();
            HK.enable(this.Handle, Hotkey.Modifiers.Win, Keys.Y);
        }

die Hotkey Klasse hier zu finden: Globale Hotkey Klasse

Moderiert von user profile iconTh69: Quote- durch C#-Tags ersetzt
Moderiert von user profile iconTh69: URL Titel hinzugefügt
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4798
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Do 19.11.15 10:34 
Hallo,

setze mal this.WindowState = FormWindowState.Normal vor dem Show()-Aufruf.

Ansonsten prüfe doch mit dem Debugger, ob er in die Methode reinspringt und welchen Wert WindowState hat.
Kuehter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30
Erhaltene Danke: 1



BeitragVerfasst: Do 19.11.15 10:55 
Das war nicht das Problem das Problem ist das der HotKey nicht Global genug ist. In der Form wird der anerkannt, jedoch wenn ich die Form minimiere ist der HotKey nicht mehr verfügbar.
Kuehter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30
Erhaltene Danke: 1



BeitragVerfasst: Do 19.11.15 11:19 
Habe die Antwort.
Es ist dann kein Shortcut oder Hotkey mehr.
sondern es nennt sich ein GlobalHook.
Wer danach googelt wird schnell fündig wie die Lösung ist.