Click here to Skip to main content
15,903,362 members
Home / Discussions / C#
   

C#

 
AnswerRe: Insert the data of datagridview in a database. Pin
Gerry Schmitz25-Feb-15 23:37
mveGerry Schmitz25-Feb-15 23:37 
QuestionGlobal Hotkeys? Pin
Linus Agren24-Feb-15 4:57
Linus Agren24-Feb-15 4:57 
SuggestionRe: Global Hotkeys? Pin
Richard MacCutchan24-Feb-15 5:41
mveRichard MacCutchan24-Feb-15 5:41 
GeneralRe: Global Hotkeys? Pin
Linus Agren24-Feb-15 5:56
Linus Agren24-Feb-15 5:56 
AnswerRe: Global Hotkeys? Pin
Eddy Vluggen24-Feb-15 7:19
professionalEddy Vluggen24-Feb-15 7:19 
QuestionRe: Global Hotkeys? Pin
Linus Agren24-Feb-15 16:59
Linus Agren24-Feb-15 16:59 
AnswerRe: Global Hotkeys? Pin
Eddy Vluggen25-Feb-15 0:30
professionalEddy Vluggen25-Feb-15 0:30 
AnswerRe: Global Hotkeys? Pin
BillWoodruff24-Feb-15 19:51
professionalBillWoodruff24-Feb-15 19:51 
I have used the code from the CP article by Mamaladze you cite successfully for Global Hooking with Visual Studio 2013, compiling against FrameWork 4.5.1., and it's now running okay in Visual Studio 2015 CTP 5 compiled against FrameWork 4.6.

Note, however, that I have taken Mamaladze's source code, copied it, hacked out the 'Global bits, and the 'Mouse hook bits, and then re-compiled it. So I'm using it as an Application level Hook only, and only trapping Keyboard entries.

Reality check:

1. Your project (I'm assuming WinForms) should reference to 'MouseKeyboardActivityMonitor dll

2. The Form that instantiates the Hook should have Using statements that look like this:

using MouseKeyboardActivityMonitor;
using MouseKeyboardActivityMonitor.WinApi;

This is what working code in my "test-bed" looks like for the MainForm:
C#
using System;
using System.Windows.Forms;
using MouseKeyboardActivityMonitor;
using MouseKeyboardActivityMonitor.WinApi;

namespace Test_Mama_HotKey
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            m_KeyboardHookManager = new KeyboardHookListener(new AppHooker());
            m_KeyboardHookManager.Enabled = true;
            m_KeyboardHookManager.KeyDown += HookManager_KeyDown;
        }

        private readonly KeyboardHookListener m_KeyboardHookManager;

        private void HookManager_KeyDown(object sender, KeyEventArgs e)
        {
            Log(string.Format("{0} {1} {2}", ActiveForm.Text, ActiveForm.ActiveControl.Name, e.KeyData));
        }

        private void Log(string text)
        {
            textBox1.AppendText(string.Format("{0}{1}", text, Environment.NewLine));
        }

        // other code removed
    }
}
Edit: After exploring Toub's HotKey implementation more deeply, I have come to the decision not to use it.

I am currently experimenting with using the Hook code in this article by Toub: [^] to install an Application (not Global) wide HotKey hook in Visual Studio 2015 CTP 6 compiled against FrameWork 4.6. I've essentially taken out his code which does the "Global" bit, and taken out his mouse-hook code, since I just want the low-level keyboard hook; it compiles okay, now, but is not fully tested.

End Edit.

The best advice I can give you is to study Mamaladze's working example and figure out what is missing from your code, or what you are not instantiating, or using, in your code.

With your adapted Mamaladze hook code now: does it compile ? Are there any specific errors at run-time. What, exactly, does not work ?
«I'm asked why doesn't C# implement feature X all the time. The answer's always the same: because no one ever designed, specified, implemented, tested, documented, shipped that feature. All six of those things are necessary to make a feature happen. They all cost huge amounts of time, effort and money.» Eric Lippert, Microsoft, 2009


modified 25-Feb-15 4:52am.

QuestionDateTime ToString [confused] Pin
V.24-Feb-15 2:19
professionalV.24-Feb-15 2:19 
AnswerRe: DateTime ToString [confused] Pin
GuyThiebaut24-Feb-15 2:43
professionalGuyThiebaut24-Feb-15 2:43 
AnswerRe: DateTime ToString [confused] PinPopular
OriginalGriff24-Feb-15 2:43
mveOriginalGriff24-Feb-15 2:43 
GeneralRe: DateTime ToString [confused] Pin
V.24-Feb-15 2:51
professionalV.24-Feb-15 2:51 
GeneralRe: DateTime ToString [confused] Pin
Rob Philpott24-Feb-15 2:57
Rob Philpott24-Feb-15 2:57 
AnswerRe: DateTime ToString [confused] Pin
F-ES Sitecore24-Feb-15 3:33
professionalF-ES Sitecore24-Feb-15 3:33 
AnswerRe: DateTime ToString [confused] Pin
Daniel Pfeffer25-Feb-15 2:54
professionalDaniel Pfeffer25-Feb-15 2:54 
QuestionIterate through data table Pin
dattagunturu24-Feb-15 1:39
dattagunturu24-Feb-15 1:39 
AnswerRe: Iterate through data table Pin
manchanx24-Feb-15 2:00
professionalmanchanx24-Feb-15 2:00 
AnswerRe: Iterate through data table Pin
Pete O'Hanlon24-Feb-15 2:03
mvePete O'Hanlon24-Feb-15 2:03 
Questionbest pattern queue Pin
vahidbakhtiary23-Feb-15 21:29
vahidbakhtiary23-Feb-15 21:29 
AnswerRe: best pattern queue Pin
OriginalGriff23-Feb-15 21:40
mveOriginalGriff23-Feb-15 21:40 
AnswerRe: best pattern queue Pin
Pete O'Hanlon23-Feb-15 21:45
mvePete O'Hanlon23-Feb-15 21:45 
AnswerRe: best pattern queue Pin
vahidbakhtiary23-Feb-15 23:07
vahidbakhtiary23-Feb-15 23:07 
GeneralRe: best pattern queue Pin
OriginalGriff23-Feb-15 23:42
mveOriginalGriff23-Feb-15 23:42 
GeneralRe: best pattern queue Pin
vahidbakhtiary24-Feb-15 0:02
vahidbakhtiary24-Feb-15 0:02 
GeneralRe: best pattern queue Pin
OriginalGriff24-Feb-15 0:17
mveOriginalGriff24-Feb-15 0:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.