ScreenShot Tool (BMP To ClipBoard + Cursor) Global Hotkey does nothing... lazarus / 34-Windows ---------------------------------------------------------------------- RAW · 2017-08-06 06:20 Hi, I know how to handle one global hotkey... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i UNIT Unit1; {$MODE OBJFPC}{$H+}{$J-} Interface USES  Windows, Classes, SysUtils, Forms, Controls, Dialogs;  TYPE  TWMHotKey = Packed Record   MSG   : Cardinal;   HotKey: PtrInt;   Unused: PtrInt;   Result: PtrInt;  End;  TYPE  TForm1 = Class(TForm)    Procedure FormCreate (Sender: TObject);   Procedure FormClose  (Sender: TObject; Var CloseAction: TCloseAction);     PROTECTED     Procedure WMHotKey(Var MSG: TWMHotKey); Message WM_HOTKEY;  End;  VAR  Form1: TForm1; Implementation {$R *.LFM}  Procedure TForm1.FormCreate(Sender: TObject); Begin  If Not RegisterHotKey(Handle, 111000, MOD_WIN, VK_S)  Then ShowMessage('HotKey failed...');   // more Keys: MOD_CONTROL+MOD_ALT, VK_S End;  Procedure TForm1.WMHotKey(Var MSG: TWMHotKey); Begin  // Show;   ShowMessage('HotKey'); End;  Procedure TForm1.FormClose(Sender: TObject; Var CloseAction: TCloseAction); Begin  UnregisterHotKey(Handle, 111000); End; END. ..but I don't know how to handle several hotkeys... ---------------------------------------------------------------------- taazz · 2017-08-06 07:09 well I do not see any problems. I made some minor changes mostly showing/hiding the main form and playing around with the application.showmainform and application.ExceptionDialog properties, I'm steel trying to enable debug information to see the blue dots in the IDE, but both the shortcuts work in my win7. What exactly is the problem you are having? ---------------------------------------------------------------------- RAW · 2017-08-06 07:39 Thank you very much... interesting the two global shortcuts don't do anything on my system... Do I need dotNet 4.0 or something... Do you have dotNet 4.0 installed ??? FormShow of course is not needed...    I coudn't see the wood for the trees... I've used wndMAIN.Show in the LPR and didn't recognized that... funny... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i BEGIN RequireDerivedFormResource:= True;  Application.Title:= 'ScrShotCursor'; Application.Initialize;  wndMAIN:= TwndMAIN.Create(Application); Application.Run;END. I'm trying right now to get it done without GlobalAddAtom... EDIT: I try a callback function... maybe that's possible... ---------------------------------------------------------------------- taazz · 2017-08-06 07:56 Quote from: RAW on August 06, 2017, 09:39:00 amThank you very much... interesting the two global shortcuts don't do anything on my system... Do I need dotNet 4.0 or something... Do you have dotNet 4.0 installed ??? well dotNet 4.0  comes with visual studio 2015 one of life's little punishments but I doubt that it is required I'll try it on a windows XP VM in a couple of minutes. EDIT: Tried it on windows XP sp3 no visual studio installation works like a charm should I upload the exe somewhere to test it your self? ---------------------------------------------------------------------- RAW · 2017-08-06 08:24 QuoteTried it on windows XP sp3 no visual studio installation works like a charm should I upload the exe somewhere to test it your self? Yes... if you don't mind... do you have got my email address (must be in one of the last PM's) ?? Maybe you can send it to my email box... I cannot use GlobalAddAtom I guess, but I don't get any error from it... weird... I did it... it's working without GlobalAddAtom ... the callback function is working very fine... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Function WndCallback(MyHWND: HWND; uMSG: UINT; wParam: WParam;                   lParam: LParam): LRESULT; StdCall; Begin  If (uMSG = WM_HOTKEY) And (WParam = HotKeyShot)  Then DoScrShot;   If (uMSG = WM_HOTKEY) And (WParam = HotKeyQuit)  Then wndMAIN.Quit;   Result:= CallWindowProc(wndMAIN.PrevWndProc, MyHWND, uMSG, WParam, LParam); End;  Procedure TwndMAIN.FormCreate(Sender: TObject); Begin  SetBounds(1,1,1,1);  PrevWndProc:= Windows.WNDPROC(SetWindowLongPtr(Handle, GWL_WNDPROC,                              PtrInt(@WndCallback)));   If Not RegisterHotKey(Handle, HotKeyShot, MOD_WIN, VK_S)  Then ShowMessage('Global HotKey: WINKEY+S  failed (DoScrShot) !');   If Not RegisterHotKey(Handle, HotKeyQuit, MOD_CONTROL+MOD_ALT, VK_Q)  Then ShowMessage('Global HotKey: CTRL+ALT+Q  failed (Quit) !'); End; ---------------------------------------------------------------------- taazz · 2017-08-06 08:31 Quote from: RAW on August 06, 2017, 10:24:21 amQuoteTried it on windows XP sp3 no visual studio installation works like a charm should I upload the exe somewhere to test it your self? Yes... if you don't mind... do you have got my email address (must be in one of the last PM's) ?? Maybe you can send it to my email box... I cannot use GlobalAddAtom I guess, but I don't get any error from it... weird... That's almost impossible, GlobalAddAtom is used in all sorts of synch in windows any kind of bug would have surface years back. Here is the exe. https://mega.nz/#!4xMESTqL!dRywr5Avc-BadgeklHthx9-P7VPoq2bF0VBu_LSipQY Oh try to run it twice you should get the error message about not able to register the hot keys ---------------------------------------------------------------------- RAW · 2017-08-06 08:59 @taazz Thanks, I will try it later... my browser cannot reach the site... It's probably my Firefox-browser, I changed appox. 300 values inside about:config ... the browser isn't even loading... weird... I try to use another browser...  EDIT: There is no error message, maybe a cypher problem... ---------------------------------------------------------------------- taazz · 2017-08-06 09:10 more than one way to skin a cat (I think that's the correct saying). https://sourceforge.net/projects/codelibrarian/files/3rdParty/ScrShotC ursor.rar/download ---------------------------------------------------------------------- RAW · 2017-08-06 09:18 BTW: Do you know www.tinyupload.com ? I've never used it before, but I want to use this for PDF-files in the future, looks nice 50MB, no login and everything is free... Hey thanks, got your exe-file... guess what... it's working... WTF     I need to check things... I don't get it right now... Do you changed the MouseRight&LeftClick, it's not working anymore...  really funny... EDIT: OK, you prefer doubleclicks... ---------------------------------------------------------------------- taazz · 2017-08-06 09:25 Quote from: RAW on August 06, 2017, 11:18:57 amBTW: Do you know www.tinyupload.com ? I've never used it before, but I want to use this for PDF-files in the future, looks nice 50MB, no login and everything is free... Hey thanks, got your exe-file... guess what... it's working... WTF     I need to check things... I don't get it right now... Do you changed the MouseRight&LeftClick, it's not working anymore...  really funny... EDIT: OK, you prefer doubleclicks...  yeah I added a popup menu. I hate mouse down actions make me very jumpy. well at least I thought I added one, it seems it does not work. I'll upload the source too in a bit. EDIT:   I replaced the exe with the source on sourcefrge https://sourceforge .net/projects/codelibrarian/files/3rdParty/ScrShotCursor.rar/download I'll probably deleted in 48 hours or so. ---------------------------------------------------------------------- RAW · 2017-08-06 09:58 QuoteI'll probably deleted in 48 hours or so. Thanks.. got it... you can delete it...  Meanwhile I installed the crosscompiler and compiled it for x86 and it works !!! So it's a x64/x86-thing I guess... I don't know right now... think I figure it out... thanks again... EDIT: Now I know 3 ways to handle global hotkeys... nice ...  EDIT: QuoteOh try to run it twice you should get the error message about not able to register the hot keys Yes, nice, I can see the ShowMessage Error message... That's strange maybe I should take a look at the winAPI "wiki"-page... why is there something different with a x64-exe... hmmm... ---------------------------------------------------------------------- taazz · 2017-08-06 10:47 main difference between 32 and 64 bit that comes to mind is the SEH handler that is enabed by default on 64bit.