This is my error message:The error message indicates that you are passing the address of a class method (indicated by "of object".) The hook procedure _cannot_ be a class method, it _must_ be a normal function.
Error: Incompatible type for arg no. 2: Got "<procedure variable type of function(LongInt;Int64;Int64):Int64 of object;StdCall>", expected "<procedure variable type of function(LongInt;Int64;Int64):Int64;StdCall>"
I believe a CLASS PROCEDURE or FUNCTION will also work if the compiler will accept the STDCALL attached on the end of it :Dwith the static modifier. and yes, stdcall will be accepted.
@TheLastCayenThat won't make a difference. The problem here is instance method vs. static/global function.
Replace {$mode objfpc}{$H+} with {$mode delphi}. Check the following thread for more details:
https://forum.lazarus.freepascal.org/index.php/topic,37049.0.html
That won't make a difference. The problem here is instance method vs. static/global function.True. I did not read the error message carefully. Nevertheless the above mentioned thread still has a nice example on hooking(for those who are interested).
I have a hard time understanding what I am doing wrong:( someone can tell me how I can modify this function so it will work?Your function LowLevelKeybdHookProc is contained inside a class (probably your form class), thus it is an instance method, but it must not be such. So either move your function to outside of the class into the implementation section of your unit or declare your function as class function LowLevelKeybdHookProc(...): LRESULT; stdcall; static. Please note however that in both cases you can not directly access your class using Self.
I am getting really desperate here. Any other recommendations?Yes, post the entire code of your hook function. That would help figure out why you're having trouble with it.
If I try to write the code for that function over implementation I get
Fatal: Syntax error, "IMPLEMENTATION" expected but "BEGIN" found
Yeah no problem, I'll most likely get castrated for giving you that bit of info. >:(Why? It was one of the two solutions suggested by me as well.
Why? It was one of the two solutions suggested by me as well.Because he bought cheap real estate, consequently he gets bad schools and extreme neighbors ;)
Indeed, and you can pass self as the lparam.