Home > database >  Pb registered hotkey
Pb registered hotkey

Time:10-10

I want to registered in multiple Windows are hot keys
I was in A, B two Windows were registered hotkey, if open any window alone, hot keys don't have any problem,
If I opened A window first, in the absence of closure in open window, B B window will prompt registration failed!
If the code under; Thank you

//API the following statement is as follows:
The FUNCTION Boolean RegisterHotKey (long HWND, long id, long fsModifiers, long vitamin k) LIBRARY "user32. DLL" alias for "RegisterHotKey; ANSI
"The Function Boolean UnregisterHotKey (long HWND, long id) library 'user32 alias for' UnregisterHotKey; ANSI '
The FUNCTION long GlobalAddAtom (ref string lpString) LIBRARY "kernel32. DLL" ALIAS FOR "GlobalAddAtomA; ANSI
"The FUNCTION long GlobalDeleteAtom (long nAtom) Library "kernel32" Alias for "GlobalDeleteAtom; ANSI
"
////registered hotkey F1 ~ F5
The Integer li_ret
The Integer I
String ls_dt, ls_err

For I=1 To 11
Sleep (0.1)
Ls_dt=string (rand (100)) + string (I) + string (Today (), "yyyy - mm - dd hh: mm: ss: FFF")
//messagebox (' ', ls_dt)
//"AtomId" + ls_out + String (Today (), "yyyy - mm - dd hh: mm: ss: FFF")
AtomId [I]=GlobalAddAtom (ls_dt)//get a unique ID, guarantee the conflicts with other applications
//li_ret=RegisterHotKey (Handle (This), AtomId [I], 0, 111 + I)//111 for F1, registered hotkey from F1
If RegisterHotKey (Handle (This), AtomId [I], 0, 111 + I)=false then
If li_ret=0 Then ls_err +="F" + String (I)
End the if

Next
If ls_err & lt;> "' Then MessageBox (" warning", "key" + ls_err + "registration failed!" )


The Integer I
If the Message. The Number=786 Then
For I=1 To 11
If wParam=AtomId [I] Then
Of_set_hotkey (' F '+ String (I))
The Exit
End the If
Next
End the If



Choose a Case as_keyName
Case "F1"
Messagebox (" ", 'F1')

Case "F2
"Messagebox (" ", 'F2')

Case "F3"
Messagebox (" ", 'F3')

Case "F4"
Messagebox (" ", "F4")

The End Choose
Who can tell me where there is a problem thanks

CodePudding user response:

This way, you didn't try,
With hooks function is ok, but need to use other tools to write a DLL,

CodePudding user response:

Hello can excuse me the hook function USES the method of you tell me?
Thank you if it's convenient please add my QQ 2627901607
  • Related