Below in conjunction with accompanying drawing the present invention is given to describe in detail.
Referring to Fig. 1, among the figure: 1~No. 8 key is the fixed definitions function key area, sets the function that the user can not self-defined these keys when machine dispatches from the factory; 9~No. 11 keys be of the present invention can self-defined shortcut keypad, the user can define the function of these keys according to the actual conditions of oneself and use; 12~No. 14 keys are the systemic-function keypad, are defined by Windows operating system; Remainder is traditional QWERTY keyboard keypad.
14,08, OC, 10,07, OE, 04, OD, 11,12,13 utilize the hardware circuit of keyboard that each shortcut is encoded, just can send specific coding to host computer system when certain shortcut is pressed, in the present invention, the key of 1-11 key is defined as:.When a certain function key is pressed, corresponding key value will be sent.Driver can be finished corresponding operation according to key.
The self-defined implementation method of shortcut of the present invention is below described.
At first, the interface of design shortcut program and keyboard driver.
When a certain shortcut is pressed, keyboard driver will receive the scanning code value of a correspondence, and according to this scan code, keyboard driver will send MYWM_FASTKEY message, expression has shortcut to press, and the parameter wParam of Chuan Songing represents the key value of shortcut simultaneously.
Following function is the interface of keyboard driver and shortcut program, during the shortcut program run, will at first call this program and register:
bResult=Rmt9807?Register(m_hWnd,MYWM_FASTKEY);
Wherein m_hWnd is the main window handle of shortcut program, MYWM_FASTKEY is self-defining WINDOWS information, rreturn value bResult represents whether to succeed in registration, if bResult=1, just expression is succeeded in registration, when shortcut was pressed, quick keyboard driver will send MYWM_FASTKEY information to the main window of shortcut program later on.
In the software program of self-defined shortcut, define a configuration file, be used for depositing the various information of the application program that is associated with shortcut.Definition in configuration file comprises three parts: the fullpath of application program, working directory, command line parameter.
For example: a certain can self-defined shortcut the time when pressing, system will carry out the program counter (Calc.exe) that the Windows system carries, then corresponding being defined as in the configuration file:
Be defined as N number make by oneself below [hotN] // expression
The justice shortcut.
Execution route=C: WINDOWS the fullpath of Calc.exe // counter program Calc.exe
Working directory=C: operating path during WINDOWS // execution Calc.exe
Command line parameter=// command line parameter when carrying out Calc.exe
When certain shortcut was pressed, the shortcut program will receive key code information MYWM_FASTKEY, and the parameter WPARAM of this information is exactly corresponding key.Below this function be processing after the shortcut program is received key code information:
LONG CMainWnd::OnFastKey (WPARAM wParam, LPARAM 1Param)Switch (wParam) //wParam be shortcut key value ... case KEY USERDEFINE1: // this shows " can self-defined shortcut " RunProgram that has been pressed (" hotN "); Break; ...
Wherein function R unProgram () goes to read definition in the configuration file according to the shortcut title, is finished by following three statements:
GetPrivateProfileString (1pDescription, " execution route ", NULIszFullPath, 255, szProfile);
GetPrivateProfileString (1pDescription, " working directory ", NULL, szWorkDir, 255, szProfile);
GetPrivateProfileString (1pDescription, " command line parameter ", NULL, szCmdParam, 255, szProfile);
Wherein lpDescription represents quick key name, and szProfile represents configuration filename.The execution route value that reads " C: WINDOWS Calc.exe " is placed among the variable szFullPath, and working directory " C: WINDOWS " is placed among the variable szWorkDir, and command line parameter is placed among the szCmdParam.Carry out or open this file according to these values with following statement then:
ShellExecute(m_hWnd,NULL,szFullPath,szCmdParam,szWorkDir,SW_SHOWDEFAULT);
After this statement is finished, the counter program will be opened.
If the function of " but self-defining key " is redefined, only corresponding entry gets final product in the need modification configuration file.
After the user has understood the course of work of shortcut, can be by the manual configuration file of rewriting to realize the self-defined of shortcut, the shortcut program provides the function to can self-defining shortcut redefining simultaneously.Its essence also is the related content of revising in the configuration file.
Detailed process is: the user redefines the definition (" execution route ", " working directory ", " command line parameter " of input application program) of revising shortcut in the dialog box at shortcut.Amended " execution route ", " working directory ", " command line parameter " leave in respectively among variable m_filepath, m_workdir, the m_cmdparam.By following function new definition is write in the configuration file then:
void CDefineKey ∷ OnOK () ... WritePrivateProfileString (m_szKeyName, " execution route ", m_filepath, szProfile); WritePrivateProfileString (m_szKeyName, " working directory ", m_workdir, szProfile); WritePrivateProfileString (m_szKeyName, " command line parameter ", m_cmdparam, szProfile);
Wherein m_szKeyName represents corresponding quick key name, and szProfile is a configuration filename.Depositing " execution route ", " working directory ", " command line parameter " among m_filepath, m_workdir, the m_cmdparam respectively, they will write in the configuration file after having carried out above three statements.
At this moment, when this shortcut that was redefined was pressed, the shortcut program will remove to carry out or open corresponding file according to new definition.
Above-mentioned function G etPrivateProfileString (...), ShellExecute (...), WritePrivateProfileString (...) be the Windows api function of standard.
Only this embodiment is described though should be appreciated that the present invention, is not limited to this embodiment, also comprise the possible modification and the change that are not separated with principle of the present invention and spirit.