Global "hotkey" could be useful in utilities.
In this sample, when you press Alt-F10 in any app, your dialog receives this message and is able to do what it wants.
You have 3 sec to close a dialog by Alt-F4.
Of course, you can registrate any other key.
In this sample, when you press Alt-F10 in any app, your dialog receives this message and is able to do what it wants.
You have 3 sec to close a dialog by Alt-F4.
Of course, you can registrate any other key.
Code:
#Compile Exe #Register None #Dim All #Include "Win32Api.Inc" %ID_Text = 201 CallBack Function DlgProc Static nAtom As Dword Select Case CbMsg Case %WM_INITDIALOG nAtom = GlobalAddAtom ("My Hotkey" + Str$(Timer)) RegisterHotKey CbHndl, nAtom, 1, %VK_F10 ' Alt-F10 SetTimer CbHndl, 1, 5000, ByVal 0 Case %WM_DESTROY UnregisterHotKey CbHndl, nAtom GlobalDeleteAtom nAtom Case %WM_HOTKEY ShowWindow CbHndl, 1 SetTimer CbHndl, 1, 3000, ByVal 0 ' CbWparam = nAtom Control Set Text CbHndl, %ID_TEXT, "Alt-F10 pressed at " + Time$ Case %WM_TIMER KillTimer CbHndl, 1 ShowWindow CbHndl, 0 End Select End Function Function PbMain Local hDlg As Long Dialog New 0, "HotKey (Alt-F10)",,, 300, 40, %WS_SYSMENU, _ %WS_EX_TOPMOST Or %WS_EX_TOOLWINDOW To hDlg Control Add Label, hDlg, %ID_Text, "Press Alt-F10 in another apps or Close this dialog", _ 5, 10, 290, 15, %SS_CENTER Dialog Show Modal hDlg Call DlgProc End Function
Comment