A method for setting hotkeys for third-party software and related equipment

By designing independent hotkey modules and status detection programs, adding hotkey functions to third-party software in Windows systems has been solved, and the lack of hotkey or hotkey conflicts has been improved, and the efficiency and security of hotkey settings have been improved.

CN114443176BActive Publication Date: 2025-03-14武汉斗鱼鱼乐网络科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011185356.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-30
Publication Date
2025-03-14
Estimated Expiration
2040-10-30

AI Technical Summary

Technical Problem

In Windows systems, third-party software may lack hotkey functions, or the hotkey functions it provides conflicts with other software in the system, resulting in the security being mistaken for viruses or plug-ins.

Method used

Design an independent hotkey module so that third-party software loads the module at startup and provides hotkey functions through export functions. Use template classes to design timing tasks and status detection programs, detect hotkey status regularly, and perform shortcut operations if necessary.

Benefits of technology

It has realized the addition of hotkey functions to third-party software, avoid conflicts with other software, and improves the efficiency of hotkey settings, ensuring that security is not misjudged.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114443176B_ABST
    Figure CN114443176B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a method and related equipment for setting hotkeys for third-party software, which are used to improve the efficiency of hotkey setting. The method includes: designing an independent hotkey module so that the third-party software loads the independent hotkey module when starting, the independent hotkey module is used to add a hotkey function to the third-party software, and the independent hotkey module includes an export function; designing a timing function of a timing task through a template class, and creating a task template to call the timing function; writing a status detection program, setting a function of the status detection program to detect the hotkey state, and executing the task template in the status detection program; when the third-party software does not have a hotkey, adding a hotkey function of the third-party software through the independent hotkey module; obtaining the hotkey state corresponding to the third-party software through the status detection program; if the hotkey state corresponding to the third-party software is pressed and released, executing the shortcut operation of the hotkey corresponding to the third-party software.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information processing technology, and in particular to a method for setting hot keys for third-party software and related devices. Background Art

[0002] Many third-party software programs are installed on Windows systems. Some offer extensive hotkey functionality, while others lack it. In practice, several issues arise: adding hotkeys to third-party software without the software's source code; modifying hotkey functionality when the third-party software's hotkey functionality conflicts with other system software; and adding hotkeys to third-party software, which often has high security requirements and may be mistaken for viruses or plug-ins. Therefore, overcoming these issues when setting up hotkeys for third-party software is a pressing issue. Summary of the Invention

[0003] The embodiments of the present application provide a method and related equipment for setting hot keys for third-party software, which can improve the efficiency of hooking system functions.

[0004] A first aspect of an embodiment of the present application provides a method for setting a hotkey for third-party software, the method being applied to a Windows platform and characterized by comprising: designing an independent hotkey module so that the third-party software loads the independent hotkey module when it is started, the independent hotkey module being used to add a hotkey function to the third-party software, the independent hotkey module including an export function, the export function being used to make the independent hotkey module available for external invocation and initialization; designing a timing function for a timed task through a template class, and creating a task template to call the timing function; writing a status detection program, setting a function for the status detection program to detect the hotkey status, and executing the task template in the status detection program to regularly detect the status of the hotkey, the status detection program being an independent section of code, dynamically allocating execution memory when the status detection program is executed, and the status detection program being released together with the independent hotkey module; when the third-party software does not have a hotkey, adding a hotkey function for the third-party software through the independent hotkey module; obtaining the hotkey status corresponding to the third-party software through the status detection program; and executing a shortcut operation for the hotkey corresponding to the third-party software if the hotkey status corresponding to the third-party software is pressed and released.

[0005] Optionally, the design of an independent hotkey module so that the third-party software loads the independent hotkey module when it is started includes: writing an independent dll module component to obtain the independent hotkey module, and designing the hotkey setting function of the independent hotkey module, the hotkey setting function includes adding new hotkeys and modifying hotkeys; determining the priority loading module after the third-party software is started through the system function LoadLibrary(); adding an import item of the independent hotkey module at the front of the import table item corresponding to the priority loading module, the import item of the independent hotkey module includes the module name of the independent hotkey module and the exported function.

[0006] Optionally, the function of setting hotkeys of the independent hotkey module includes: when adding a new hotkey for the third-party software, the function of setting hotkeys of the independent hotkey module includes: obtaining the unique identification information of the hotkey through the formula KeyId=GlobalAddAtom(_T("keyid"))-0xc000, the KeyId is used to represent the unique identification information of the hotkey, the legal value range of the KeyId is 0x0000~0xBFFF, and the function GlobalAddAtom is used to obtain the hotkey identification _T("keyid"); registering the hotkey function by calling the system function RegisterHotKey((Handle,keyid,MOD_XXX,VK_XXX), the handle represents the window handle of the WM_HOTKEY message generated by the hotkey, the MOD_XXX represents the identifier of the combination key, and the VK_XXX represents the keyboard key identifier; registering the hotkey function by calling the system function LRESULT Wind::HandleMessage(UINT uMsg,WPARAM wParam, LPARAM, and lParam) are used to set the response function of the hotkey, the uMsg represents the specified message to be sent, the wParam and lParam are used to represent the specified additional message-specific information, when the message type of the uMsg is the WM_HOTKEY message, the parameter wParam is used to store the unique identification information of the hotkey; or, when modifying the hotkey for the third-party software, the function of setting the hotkey of the designed independent hotkey module includes: determining the current hotkey of the third-party software through the parameters of the system function RegisterHotKey; if the current hotkey conflicts with the hotkey of other software, hooking the system function RegisterHotKey and modifying the current hotkey.

[0007] Optionally, the design of the timing function of the scheduled task through the template class and the creation of the task template to call the timing function include:<typename Time,typename Elapse=typename Time::duration> Design the template class, the Time is used to represent the system clock, the typename Elapse = typename Time::duration is used to represent the time interval parameter of the computing task; obtain the last task execution time point according to the system clock, and design a function execution unit, the function execution unit is applicable to functions of all parameter types; construct the function TimeTask(), the function TimeTask() is an explicit function, the input parameters of the function TimeTask() include the execution time point of the last task and the function execution unit; create the task template TimeTask task() according to the constructor TimeTask(), and set the preset time length of the interval of the task template TimeTask task() to execute the task function; realize the uninterrupted execution of the task template TimeTask task() through the while loop, and release the CPU resources after the task execution is completed through the system function this_thread::yield.

[0008] Optionally, the function of setting the preset time length of the task template TimeTask task() to execute the task includes: obtaining the current time through the function auto now = Time::now(), where Time is the system clock in the template class; calculating the current task time interval between the current time and the last task execution time point; if the current task time interval is greater than the preset time interval, determining the current time as the execution time of the current task to realize the task execution function with the preset task interval.

[0009] Optionally, the function of setting the status detection program to detect the hot key status includes: determining the memory address of the system function GetAsyncKeyState() in the dynamic execution memory; calling the system function GetAsyncKeyState((vk_code)&0x8000) according to the memory address, the return value of the system function GetAsyncKeyState((vk_code)&0x8000) is used to indicate whether the hot key to be tested is pressed, the vk_code is used to represent the key code of the virtual key to be tested, and the &0x8000 is used to represent the high value of the key code of the virtual key to be tested.

[0010] Optionally, determining the memory address of the system function GetAsyncKeyState() in the dynamic execution memory includes: determining the system module corresponding to the system function GetAsyncKeyState() through the function GetModuleHandle(), and obtaining the memory address through the function GetProcAddress(); or, obtaining the memory address of the function GetAsyncKeyState() in the independent hotkey module, and passing the memory address to the dynamic execution memory.

[0011] The second aspect of the embodiment of the present application provides a hotkey setting device, including: a design unit for designing an independent hotkey module so that the third-party software loads the independent hotkey module when it is started, the independent hotkey module is used to add a hotkey function to the third-party software, the independent hotkey module includes an export function, and the export function is used to make the independent hotkey module available for external call and initialization; the design unit is also used to design a timing function of a timed task through a template class, and create a task template to call the timing function; the design unit is also used to write a status detection program, set the function of the status detection program to detect the hotkey status, and The task template is executed in the status detection program to periodically detect the status of the hot key. The status detection program is an independent segment code. Dynamic execution memory is allocated when the status detection program is executed. The status detection program is released together with the independent hot key module; a new adding unit is used to add a hot key function of the third-party software through the independent hot key module when the third-party software does not have a hot key; an acquisition unit is used to obtain the hot key status corresponding to the third-party software through the status detection program; an execution unit is used to execute the shortcut operation of the hot key corresponding to the third-party software if the hot key status corresponding to the third-party software is pressed and released.

[0012] In summary, it can be seen that in the embodiment provided by the present application, an independent hotkey module is designed so that the third-party software loads the independent hotkey module when it is started. The independent hotkey module is used to add a hotkey function to the third-party software. The independent hotkey module includes an export function, which is used to make the independent hotkey module available for external call and initialization; the timing function of the timed task is designed through a template class, and a task template is created to call the timing function; a status detection program is written, the function of the status detection program to detect the hotkey status is set, and the task template is executed in the status detection program to regularly detect the status of the hotkey, the status detection program is an independent segment code, dynamic execution memory is allocated when the status detection program is executed, and the status detection program is released together with the independent hotkey module; when the third-party software does not have a hotkey, the hotkey function of the third-party software is added through the independent hotkey module; the hotkey status corresponding to the third-party software is obtained through the status detection program; if the hotkey status corresponding to the third-party software is pressed and released, the shortcut operation of the hotkey corresponding to the third-party software is executed.

[0013] Through the embodiment of the present application, an independent hotkey module is designed so that the third-party software loads the independent hotkey module when it is started. The independent hotkey module is used to add a hotkey function to the third-party software. The independent hotkey module includes an export function, which is used to make the independent hotkey module available for external call and initialization; a timing function of a timed task is designed through a template class, and a task template is created to call the timing function; a status detection program is written, the status detection program is set to detect the hotkey status, and the task template is executed in the status detection program to regularly detect the status of the hotkey. The status detection program is an independent segment code, and dynamic execution memory is allocated when the status detection program is executed. The status detection program is released together with the independent hotkey module; when the third-party software does not have a hotkey, the hotkey function of the third-party software is added through the independent hotkey module; the hotkey status corresponding to the third-party software is obtained through the status detection program; if the hotkey status corresponding to the third-party software is pressed and released, the shortcut operation of the hotkey corresponding to the third-party software is executed. This can improve the efficiency of hotkey setting. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 A flowchart of a possible method for setting hotkeys for third-party software provided in an embodiment of the present application;

[0015] Figure 2 A schematic diagram of a possible hot key setting device provided in an embodiment of the present application;

[0016] Figure 3A schematic diagram of the hardware structure of a possible hotkey setting device provided in an embodiment of the present application;

[0017] Figure 4 A schematic diagram of a possible electronic device according to an embodiment of the present application;

[0018] Figure 5 A schematic diagram of an embodiment of a possible computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0019] The embodiments of the present application provide a method and related devices for setting hotkeys for third-party software, which can improve the efficiency of hotkey setting.

[0020] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or that are inherent to these processes, methods, products or devices. The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the embodiments described are only part of the embodiments of the present application, not all of the embodiments.

[0021] See also Figure 1 , which is a flow chart of a possible method for setting hotkeys for third-party software provided in an embodiment of the present application, specifically including:

[0022] 101. Design an independent hotkey module so that third-party software can load the independent hotkey module when starting;

[0023] Since this solution is to add a hotkey function to third-party software, it is necessary to design an independent hotkey module function. On the Windows platform, an independent DLL module component is written to facilitate the encapsulation and reuse of functions in various software programs. This independent hotkey module contains all the functions to completely solve the hotkey problem. This module can use as few system API functions as possible. At the same time, the module name needs to be more universal, such as help.dll, or a name similar to the system module, base.dll, etc. In addition, this independent hotkey module needs to add version number timestamp information, and it needs to be signed with company signature information. These measures are to prevent antivirus software or other third-party software from detecting that the written independent hotkey mode is a virus or a "plug-in" function. At the same time, this independent hotkey module needs to provide an export function, which is used to make the independent hotkey module available for external calls and to initialize the independent hotkey module.

[0024] It should be noted that since this article is about adding hotkey functionality to third-party software, the independent hotkey module will not be loaded by the third-party program. Therefore, it is necessary to load the independent hotkey module when the third-party software is started. This article can reverse debug the third-party program and set a breakpoint on the system loading module function loadlibrary. The loadlibrary function is used to map the executable module to the address space of the calling process. It is a system interface that must be called when the software loads other component modules. In this way, you can know which component is loaded first after the third-party software is started, and then know which module the third-party software loads first. The specific function implementation is as follows:

[0025] HMODULE WINAPI LoadLibrary(LPCTSTR lpFileName);

[0026] This function is used to load a dynamic link library into memory. HMODULE is used to return the module handle; lpFileName is used to indicate the name of the module that was loaded first.

[0027] After determining the module that loads first, modify the module's import table entry and add a new import entry. When adding the new import entry, move the import entry for the independent hotkey module to the front to ensure that the independent hotkey module is loaded last. The new import entry will be the name and exported function of the independent hotkey module. For example, if the independent hotkey module is named Base.dll and the exported function is init, the import entry for the independent hotkey module could be Base.dll init.

[0028] After adding the import item, when the third-party program is started, all the components it depends on will be loaded first. Therefore, the set independent hotkey module will be loaded first, and the written export function init will be executed to initialize the hotkey function of the independent hotkey module.

[0029] 102. Design the timing function of the scheduled task through the template class, and create a task template to call the timing function;

[0030] Since the purpose of the embodiments of the present application is to add a hotkey function to third-party software, if the third-party software has a detection function, such as a game program with relatively high security requirements, then the game program will detect whether the hotkey function is currently present. If it is, it is considered to be a plug-in program or a virus program. Therefore, if the independent hotkey module of the present application is used to add the hotkey function, it is very likely to be detected. Therefore, it is necessary to provide a method that can bypass this detection.

[0031] In this embodiment of the present application, the system function GetAsyncKeyState can be used to detect whether a hot key is pressed. It should be noted that the system provides GetKeyState to obtain the status of a key, but this function can only be used in the keyboard message handler because it only reports the status of the queried key when the thread reads the keyboard message from the message queue. If you want to use it outside the keyboard message handler, you must use GetAsyncKeyState to detect it.

[0032] In the embodiment of the present application, the GetAsyncKeyState function is adopted for safety. Since the GetAsyncKeyState function is called once to obtain the key status, if the hot key function is to be achieved, a timed task needs to be set to continuously detect the hot key status. It should be noted that in actual applications, the system timer function can be used, and the corresponding task is executed when the timer reaches a certain time. The traditional solution uses the system timer to detect the key status at intervals of time, while the present application needs to call the system function and set the detection callback function address. Since the detection function is executed in the dynamic execution memory, it is inconvenient to call the system function and pass in the callback function address. In addition, the timer is also a common plug-in function, so the risk of the system timer being detected is very high.

[0033] As for the detection function of the scheduled task, since the detection function is placed in the dynamic memory for execution, it is hoped that the scheduled task can change every time and no code features will be left. If it is a code, the compiled code is fixed, and if a template is used to implement this function, the code generated by the template each time can be changed, and the template will be expanded into the corresponding code based on the specific template parameters instead of sharing the same code. In addition, the template will copy all of its own code to the place where it is called, while the non-template is that all places where it is called are calling functions, and there is only one copy of the original code. Therefore, it is safer to use a template. Taking the above factors into consideration, the embodiment of the present application designs the timing function of the scheduled task through a template class, and creates a task template to call the timing function, which specifically includes the following:

[0034] Design template class.

[0035] Through the function template<typename Time,typename Elapse=typename Time::duration> Design template class, where Time is used to represent the system clock, and can also be various other system time parameters in the future. The system module provides three clocks, including: steady_clock, system_clock and high_resolution_clock. Among them, steady_clock is a monotonic clock, equivalent to the stopwatch in the hands of a coach, which only increases and is suitable for recording program time; system_clock is the system clock, because the system clock can be modified and even synchronized with the network; high_resolution_clock is the highest precision clock that the current system can provide, and it cannot be modified. Among the three clocks, steady_clock is the fastest, followed by system_clock, and the slowest is high_resolution_clock. This article is based on the task time difference and does not require a precise moment of the system, so you can choose to use the fastest steady_clock.

[0036] The second template parameter, typename Elapse = typename Time::duration, specifies the time interval parameter type used for the calculation task. The system time itself provides the duration type, which represents the unit of the event difference. This limits the time interval setting parameters and prevents users from entering incorrect data and causing program problems.

[0037] Optionally, in order to prevent the template parameters from being passed in with the wrong type, the embodiment of the present application also provides a method for checking the template passed in parameters, using the system function static_assert to check, and the specific implementation function is as follows:

[0038] static_assert(Time::is_steady,"wrong parameter");

[0039] It should be noted that currently there are assert and other detection system functions for checking errors. This article chooses to use static_assert so that errors can be found during code compilation. For assert or other checks, the program must be executed and the relevant statements must be executed before an error is reported. In this way, if the developer uses the wrong template parameter type, the error will be prompted to the developer during code compilation, so that the parameter can be corrected. In addition, for the time parameters of the three systems mentioned above, only steady_clock has is_steady true; the other two time parameters have is_steady false.

[0040] After designing the template class, it is necessary to obtain the last task execution time point based on the template parameter Time. The specific implementation function includes Time::::time_point point, and the function execution unit function is designed.<void()> func, the function execution unit is applicable to functions of all parameter types, where function<void()> It is a template class object. Any execution function logic can use this parameter to improve the corresponding specific execution function. Function can be used for member functions of a class or functions with different numbers of parameters and different parameter types.<void()> This allows for all types of execution.

[0041] Then construct the function TimeTask(), create the task template TimeTask task() according to the constructor TimeTask(), and set the interval preset time length of the task template TimeTask task() to execute the task function; among them, the function TimeTask() is an explicit function, and the input parameters of the function TimeTask() include the execution time point of the last task and the function execution unit; the specific implementation function of the constructor TimeTask() is as follows: explicit TimeTask(typenameTime::time_point checkpoint,std::function<void()> f):point(std::move(checkpoint)),func(std::move(f){}, function<void()> func represents the function execution unit, and Time::time_point checkpoint represents the time parameter after the check. The time parameter and the function execution body parameters require std::move to improve efficiency and transfer lifecycles. The purpose of std::move is to coerce an lvalue into an rvalue reference, which can then be used through the rvalue reference for move semantics. In terms of implementation, std::move is essentially equivalent to a type conversion.

[0042] After creating the task template, use the while loop to implement the task template TimeTask task() to execute the task at the preset time interval. The specific implementation is as follows:

[0043] template<typename TDuration>

[0044] bool lapTask(TDuration&&amount){

[0045] By providing a template parameter TDuration, the parameter type is time interval data. Through the template parameter, it can be associated with the class template parameter of this article, so that this class can adapt to different types of time judgment without modifying any code.

[0046] The current time is obtained through the function auto now = Time::now(), where Time is the system clock of the template class. The time is obtained based on the template parameter type Time of the class, so different time information can be obtained according to different types of time.

[0047] if(now-point <amount){return false;}

[0048] The current task time interval between the current moment and the last task execution time point is calculated according to the formula now-point. The current task time interval is compared with the preset time interval parameter amount through the if function. If it is smaller than amount, it means that the current task time interval does not meet the preset time interval. Otherwise, it means that the current task time interval meets the requirements. In this case, the current task execution time needs to be updated to the current moment through the function point=now, and true is returned.

[0049] After setting the function of the task template, the uninterrupted execution of the task template TimeTask task() is realized through a while loop, and the CPU resources are released after the task execution is completed through the system function this_thread::yield. The details are as follows:

[0050]

[0051] First, check whether the current task time interval meets the requirements. If it does, only execute the task. Optionally, after the task is completed, to avoid excessive consumption of CPU resources, it is necessary to release CPU resources. In the embodiment of the present application, the system function this_thread::yield can be used to release CPU resources. The reasons for choosing the system function this_thread::yield to release CPU resources are mainly considered as follows: This application is to execute tasks at intervals of time, and there is only such a task here, so the system this_thread::sleep_for() function cannot be used. Once the this_thread::sleep_for() function is called, the thread will be dormant. There is no need to wait for other tasks here, so it is hoped to give up the CPU so that other tasks can be executed to improve the performance of the program. Therefore, the system function this_thread::yield is used in this application to release CPU resources.

[0052] 103. Write a status detection program, set the status detection program to detect the hot key status, and execute the task template in the status detection program to regularly detect the hot key status;

[0053] Considering the functional safety of the status detection program, this application independently compiles it into a segment code and releases it together with the independent hotkey module. After being written into an independent segment, a dynamic execution memory will be allocated during execution, and this segment code will be copied to the dynamically allocated memory. It should be noted that using an independent segment makes it easy to place this segment code into the allocated dynamic memory. The advantage of using dynamic memory to execute the code for detecting the key status is that the dynamic memory address requested by the status detection program changes dynamically each time it is executed, so the position is not fixed. More importantly, it does not belong to any dll module, so when hooking it or searching the function call stack, it cannot be traced back to the independent hotkey module, resulting in no connection between the independent hotkey module and the status detection program. In addition, if it is a module, it is easy to use enumeration modules or other tools to view all the modules loaded by the program, but using dynamic memory cannot be found.

[0054] Since the system function GetAsyncKeyState cannot be called directly in the dynamic execution memory, it is necessary to dynamically obtain the memory address of the system function GetAsyncKeyState by obtaining the module to which the system function GetAsyncKeyState belongs. Specifically, the system module is obtained through GetModuleHandle, and the function memory address in the module is obtained through Getprocaddress. It is also possible to first obtain the address of the system function GetAsyncKeyState in the independent hotkey module when allocating dynamic execution memory, and then pass it to the dynamic execution memory. Specifically, the function GetAsyncKeyState is used for detection, and the specific implementation functions include: GetAsyncKeyState(vk_code)&0x8000);

[0055] vk_code is the key code of the virtual key to be tested; &0x8000 means only the high-order bit is taken. If the value returned is 1, it is pressed; otherwise, it is released. This function can be used to detect whether any key is pressed or released.

[0056] After setting up a status detection program to detect hotkey status, execute the task template within the status detection program to periodically check the hotkey status. Specifically, execute the GetAsyncKeyState function within task.func() to detect whether a hotkey is pressed or released, thus achieving hotkey detection. When using a template-type scheduled task, create a TimeTask task(); the template will extend the entire functionality to the calling location.

[0057] 104. When third-party software does not have hotkeys, add hotkey functions for the third-party software through the independent hotkey module;

[0058] In the embodiment of the present application, if the third-party software does not have a hotkey, the hotkey function can be added to the third-party software by programming the hotkey function in an independent hotkey module. The specific implementation is as follows:

[0059] Step 1. Get the hotkey identifier: Get the unique identification information of the hotkey through the formula KeyId = GlobalAddAtom(_T("keyid"))-0xc000. KeyId is used to represent the unique identification information of the hotkey. The legal value range of KeyId is 0x0000~0xBFFF, so 0xc000 is subtracted to meet the calling requirements. The function GlobalAddAtom is used to obtain the hotkey identifier _T("keyid"); the advantage of using this formula is that the legal value range of KeyId is 0x0000~0xBFFF, and the value of the hotkey identifier obtained by the function GlobalAddAtom(_T("keyid")) is between 0xC000 and 0xFFFF, so 0xc000 can be subtracted to meet the calling requirements, that is, to ensure that the value of KeyId is within the legal range, otherwise an error will be reported due to illegal parameters.

[0060] Step 2. Register the hotkey function: Register the hotkey function by calling the system function RegisterHotKey((Handle,keyid,MOD_XXX,VK_XXX). Handle represents the window handle that receives the WM_HOTKEY message generated by the hotkey, MOD_XXX represents the identifier of the key combination, and VK_XXX represents the keyboard key identifier. For example: the system function RegisterHotKey(Handle,keyid,MOD_ALT,VK_F1) means that an ALT+F1 hotkey is registered.

[0061] Step 3. Set the hotkey response function, that is, pressing the hotkey will have a corresponding response; set the hotkey response function through the system function LRESULTWind::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam). When the hotkey is triggered, this message processing function will be called. Among them, UINT, WPARAM, and LPARAM are generally used when defining message types. uMsg indicates the specified message to be sent, and wParam and lParam identify the specified additional message-specific information.

[0062] After receiving the message, the if function If(uMsg == WM_HOTKEY) selects the message. Only messages of type WM_HOTKEY are considered hotkey messages. If it is a hotkey message, the parameter wParam stores the keyid of the hotkey, making it easier to handle multiple hotkeys. Next, you can customize the function that corresponds to pressing a hotkey.

[0063] Therefore, through the above steps, when the third-party software does not have a hotkey, the hotkey function of the third-party software is added through the independent hotkey module.

[0064] In addition, in actual applications, there are also situations where third-party software needs to be modified. That is, if the third-party software itself has a hotkey function, and the hotkey of the third-party software conflicts with the hotkey of other software, it is necessary to disable a certain hotkey function of the third-party software, or adjust the hotkey settings of the third-party software. In the embodiment of the present application, the specific implementation is as follows:

[0065] The current hotkey of a third-party application is determined by the parameters of the system function RegisterHotKey. If the current hotkey conflicts with the hotkey of another application, the hotkey registration of the third-party application will be invalidated. This is done by hooking the system function RegisterHotKey and changing the current hotkey to the hotkey you want to register, thus avoiding hotkey conflicts. For example, if the F1 hotkey is registered, the F1 hotkey can be changed to the F2 hotkey in the hook function.

[0066] Therefore, in the embodiment of the present application, the function of adding hotkeys to these software is realized without the source code; at the same time, some third-party software provides hotkey functions, but may conflict with other software in the system, and the hotkey settings of the third-party software need to be modified to avoid conflicts.

[0067] 105. Obtain the hotkey status of third-party software through the status detection program;

[0068] 106. If the hot key corresponding to the third-party software is in the state of being pressed and released, the shortcut operation of the hot key corresponding to the third-party software is executed.

[0069] After writing and setting the function of detecting the hotkey status of the status detection program, the hotkey status is detected regularly to obtain the hotkey function corresponding to the third-party software.

[0070] When the hotkey state is detected using the system function GetAsyncKeyState(vk_code)&0x8000), and the hotkey corresponding to the third-party software is in the pressed and released state, the shortcut operation of the third-party software hotkey is executed. For example, in a Word document, pressing Ctrl+A and then releasing them simultaneously executes the Select All shortcut corresponding to the hotkey group.

[0071] In the embodiments of the present application, hotkeys can be added to third-party software without the source code. If some third-party software provides hotkey functionality but conflicts with other system software and does not provide hotkey configuration, the hotkey settings of the third-party software can be modified. Furthermore, when adding hotkeys to third-party software, hotkeys can be added safely to avoid being mistakenly identified as viruses or "hacks" by the third-party software.

[0072] The above describes the method for setting hot keys for third-party software in the embodiment of the present application. The following describes the hot key setting device in the embodiment of the present application.

[0073] See also Figure 2 , an embodiment of the hot key setting device in the embodiment of the present application, the hot key setting device includes:

[0074] A design unit 201 is configured to design an independent hotkey module so that the third-party software loads the independent hotkey module when the third-party software is started. The independent hotkey module is configured to add a hotkey function to the third-party software. The independent hotkey module includes an export function for making the independent hotkey module available for external invocation and initialization.

[0075] The design unit 201 is further configured to design a timing function of a timing task through a template class, and create a task template to call the timing function;

[0076] The design unit 201 is further configured to write a status detection program, set the status detection program to detect the hotkey status, and execute the task template in the status detection program to periodically detect the hotkey status. The status detection program is an independent section code, and dynamic execution memory is allocated when the status detection program is executed. The status detection program is released together with the independent hotkey module.

[0077] A adding unit 202 is configured to add a hotkey function of the third-party software through the independent hotkey module when the third-party software does not have a hotkey;

[0078] An acquiring unit 203 is configured to acquire the hotkey status corresponding to the third-party software through the status detection program;

[0079] The execution unit 204 is configured to execute a shortcut operation of the hotkey corresponding to the third-party software if the hotkey status corresponding to the third-party software is pressed and released.

[0080] above Figure 2 The hotkey setting device in the embodiment of the present application is described from the perspective of modular functional entities. The hotkey setting device in the embodiment of the present application is described in detail from the perspective of hardware processing. Figure 3 An embodiment of the recommendation device 300 for a live broadcast room in an embodiment of the present application includes:

[0081] Input device 301, output device 302, processor 303 and memory 304 (wherein the number of processor 303 can be one or more, Figure 3 In some embodiments of the present application, the input device 301, the output device 502, the processor 303 and the memory 304 may be connected via a bus or other means, wherein: Figure 3 The bus connection is taken as an example.

[0082] By calling the operation instructions stored in the memory 304, the processor 303 is configured to perform the following steps:

[0083] Designing an independent hotkey module so that the third-party software loads the independent hotkey module when starting, the independent hotkey module is used to add a hotkey function to the third-party software, and the independent hotkey module includes an export function, and the export function is used to make the independent hotkey module available for external call and initialization;

[0084] Design the timing function of the scheduled task through the template class, and create a task template to call the timing function;

[0085] Writing a status detection program, setting the status detection program to detect the hotkey status, and executing the task template in the status detection program to regularly detect the hotkey status. The status detection program is an independent section code, and dynamic execution memory is allocated when the status detection program is executed. The status detection program is released together with the independent hotkey module;

[0086] When the third-party software does not have a hotkey, adding a hotkey function of the third-party software through the independent hotkey module;

[0087] Obtaining the hotkey status corresponding to the third-party software through the status detection program;

[0088] If the hot key state corresponding to the third-party software is pressed and released, the shortcut operation of the hot key corresponding to the third-party software is executed.

[0089] By calling the operation instructions stored in the memory 304, the processor 303 is also used to execute Figure 1 Any method in the corresponding embodiment.

[0090] See also Figure 4 , Figure 4 Schematic diagram of an electronic device according to an embodiment of the present application.

[0091] like Figure 4 As shown, an embodiment of the present application provides an electronic device, including a memory 410, a processor 420, and a computer program 411 stored in the memory 420 and executable on the processor 420. When the processor 420 executes the computer program 411, the following steps are implemented:

[0092] Designing an independent hotkey module so that the third-party software loads the independent hotkey module when starting, the independent hotkey module is used to add a hotkey function to the third-party software, and the independent hotkey module includes an export function, and the export function is used to make the independent hotkey module available for external call and initialization;

[0093] Design the timing function of the scheduled task through the template class, and create a task template to call the timing function;

[0094] Writing a status detection program, setting the status detection program to detect the hotkey status, and executing the task template in the status detection program to regularly detect the hotkey status. The status detection program is an independent section code, and dynamic execution memory is allocated when the status detection program is executed. The status detection program is released together with the independent hotkey module;

[0095] When the third-party software does not have a hotkey, adding a hotkey function of the third-party software through the independent hotkey module;

[0096] Obtaining the hotkey status corresponding to the third-party software through the status detection program;

[0097] If the hot key state corresponding to the third-party software is pressed and released, the shortcut operation of the hot key corresponding to the third-party software is executed.

[0098] In the specific implementation process, when the processor 420 executes the computer program 411, it can achieve Figure 1 Any implementation manner in the corresponding embodiments.

[0099] Since the electronic device introduced in this embodiment is a device used to implement a hot key setting device in the embodiment of the present application, based on the method introduced in the embodiment of the present application, technical personnel in this field can understand the specific implementation of the electronic device of this embodiment and its various variations. Therefore, how the electronic device implements the method in the embodiment of the present application is no longer introduced in detail here. As long as the equipment used by technical personnel in this field to implement the method in the embodiment of the present application falls within the scope of protection to be protected by this application.

[0100] See also Figure 5 , Figure 5 A schematic diagram of an embodiment of a computer-readable storage medium provided in an embodiment of the present application.

[0101] like Figure 5 As shown, this embodiment provides a computer-readable storage medium 500, on which a computer program 511 is stored. When the computer program 511 is executed by a processor, the following steps are implemented:

[0102] Designing an independent hotkey module so that the third-party software loads the independent hotkey module when starting, the independent hotkey module is used to add a hotkey function to the third-party software, and the independent hotkey module includes an export function, and the export function is used to make the independent hotkey module available for external call and initialization;

[0103] Design the timing function of the scheduled task through the template class, and create a task template to call the timing function;

[0104] Writing a status detection program, setting the status detection program to detect the hotkey status, and executing the task template in the status detection program to regularly detect the hotkey status. The status detection program is an independent section code, and dynamic execution memory is allocated when the status detection program is executed. The status detection program is released together with the independent hotkey module;

[0105] When the third-party software does not have a hotkey, adding a hotkey function of the third-party software through the independent hotkey module;

[0106] Obtaining the hotkey status corresponding to the third-party software through the status detection program;

[0107] If the hot key state corresponding to the third-party software is pressed and released, the shortcut operation of the hot key corresponding to the third-party software is executed.

[0108] In a specific implementation process, the computer program 511 can be implemented when executed by a processor. Figure 1 Any implementation manner in the corresponding embodiments.

[0109] It should be noted that, in the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.

[0110] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0111] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0112] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0113] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0114] The present application also provides a computer program product, which includes computer software instructions. When the computer software instructions are executed on a processing device, the processing device is caused to execute the following Figure 1The process in the method for designing a digital platform for a wind farm corresponds to the embodiment.

[0115] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0116] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0117] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0118] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0119] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0120] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0121] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for setting hotkeys for third-party software, the method being applied to a Windows platform, characterized in that: include: Designing an independent hotkey module so that the third-party software loads the independent hotkey module when starting, the independent hotkey module is used to add a hotkey function to the third-party software, and the independent hotkey module includes an export function, and the export function is used to make the independent hotkey module available for external call and initialization; Design the timing function of the scheduled task through the template class, and create a task template to call the timing function; Writing a status detection program, setting the function of the status detection program to detect the hotkey status, and executing the task template in the status detection program to regularly detect the hotkey status, the status detection program is an independent section code, dynamic execution memory is allocated when the status detection program is executed, and the status detection program is released together with the independent hotkey module; When the third-party software does not have a hotkey, adding a hotkey function of the third-party software through the independent hotkey module; Obtaining the hotkey status corresponding to the third-party software through the status detection program; If the hot key state corresponding to the third-party software is pressed and released, the shortcut operation of the hot key corresponding to the third-party software is executed.

2. The method according to claim 1, characterized in that The designing of the independent hotkey module so that the third-party software loads the independent hotkey module when starting up includes: Compile an independent dll module component to obtain the independent hotkey module, and design a hotkey setting function of the independent hotkey module, wherein the hotkey setting function includes adding a new hotkey and modifying a hotkey; Determine the priority loading module after the third-party software is started by the system function LoadLibrary(); An import entry of the independent hotkey module is added to the front of the import table entry corresponding to the priority loading module, and the import entry of the independent hotkey module includes the module name of the independent hotkey module and the export function.

3. The method according to claim 2, characterized in that The function of setting hotkeys of the independent hotkey module includes: When adding a hotkey to the third-party software, the hotkey setting function of the independent hotkey module includes: The unique identification information of the hot key is obtained by the formula KeyId=GlobalAddAtom(_T("keyid"))-0xc000, wherein the KeyId is used to represent the unique identification information of the hot key, and the legal value range of the KeyId is 0x0000 to 0xBFFF, and the function GlobalAddAtom is used to obtain the hot key identification _T("keyid"); Register the hotkey function by calling the system function RegisterHotKey((Handle, keyid, MOD_XXX, VK_XXX), where handle represents the window handle that receives the hotkey to generate the WM_HOTKEY message, MOD_XXX represents the identifier of the combination key, and VK_XXX represents the keyboard key identifier; The response function of the hot key is set through the system function LRESULT Wind::HandleMessage(UINT uMsg, WPARAM wParam, LPARAMlParam), wherein the uMsg indicates the message to be sent, the wParam and the lParam are used to indicate the additional message-specific information, and when the message type of the uMsg is the WM_HOTKEY message, the parameter wParam is used to store the unique identification information of the hot key; Alternatively, when the hotkey is modified for the third-party software, the hotkey setting function of the independent hotkey module includes: Determine the current hot key of the third-party software through the parameters of the system function RegisterHotKey; If the current hotkey conflicts with the hotkeys of other software, the system function RegisterHotKey is hooked and the current hotkey is modified.

4. The method according to claim 1, characterized in that: The timing function of the timed task is designed through the template class, and the task template is created to call the timing function, including: Through the function template<typename Time,typename Elapse=typenameTime::duration> Design the template class, wherein Time is used to represent the system clock, and typename Elapse=typename Time::duration is used to represent the time interval parameter of the computing task; Obtain the last task execution time point according to the system clock, and design a function execution unit, wherein the function execution unit is applicable to functions of all parameter types; Constructor TimeTask(), the function TimeTask() is an explicit function, and the input parameters of the function TimeTask() include the execution time point of the last task and the function execution unit; Create a task template TimeTask task() according to the constructor TimeTask(), and set the interval preset time length of the task template TimeTask task() to execute the function of the task; The uninterrupted execution of the task template TimeTask task() is realized through a while loop, and the CPU resources after the task execution is completed are released through the system function this_thread::yield.

5. The method according to claim 4, characterized in that The function of setting the interval preset time length of the task template TimeTask task() to execute the task includes: Get the current time through the function auto now=Time::now(), where Time is the system clock in the template class; Calculate the current task time interval between the current moment and the last task execution time point; If the current task time interval is greater than the preset time interval, the current time is determined as the execution time of the current task to implement the task execution function separated by the preset task interval.

6. The method according to claim 1, characterized in that The function of setting the status detection program to detect the hotkey status includes: Determine the memory address of the system function GetAsyncKeyState() in the dynamic execution memory; The system function GetAsyncKeyState((vk_code)&0x8000) is called according to the memory address, and the return value of the system function GetAsyncKeyState((vk_code)&0x8000) is used to indicate whether the hot key to be tested is pressed, the vk_code is used to represent the key code of the virtual key to be tested, and the &0x8000 is used to represent the high value of the key code of the virtual key to be tested.

7. The method according to claim 6, characterized in that Determining the memory address of the system function GetAsyncKeyState() in the dynamic execution memory includes: Determine the system module corresponding to the system function GetAsyncKeyState() through the function GetModuleHandle(), and obtain the memory address through the function GetProcAddress(); or, The memory address of the function GetAsyncKeyState() is obtained in the independent hotkey module, and the memory address is transferred to the dynamic execution memory.

8. A hotkey setting device, characterized in that: include: A design unit, used for designing an independent hotkey module, so that the third-party software loads the independent hotkey module when starting, the independent hotkey module is used for adding a hotkey function to the third-party software, and the independent hotkey module includes an export function, and the export function is used for providing the independent hotkey module for external call and initialization; The design unit is also used to design a timing function of a timing task through a template class, and create a task template to call the timing function; The design unit is also used to write a state detection program, set the function of the state detection program to detect the hot key state, and execute the task template in the state detection program to regularly detect the state of the hot key. The state detection program is an independent section code. When the state detection program is executed, dynamic execution memory is allocated. The state detection program is released together with the independent hot key module. A adding unit, used for adding a hotkey function of the third-party software through the independent hotkey module when the third-party software does not have a hotkey; An acquisition unit, used for acquiring the hot key status corresponding to the third-party software through the status detection program; The execution unit is used to execute the shortcut operation of the hot key corresponding to the third-party software if the hot key state corresponding to the third-party software is pressed and released.

9. An electronic device, comprising a memory and a processor, characterized in that: The processor is used to implement the steps of the method for setting hot keys for third-party software as described in any one of claims 1 to 7 when executing the computer management program stored in the memory.

10. A computer-readable storage medium having a computer management program stored thereon, characterized in that: When the computer management program is executed by the processor, the steps of the method for setting hot keys for third-party software as claimed in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Application dump file acquisition method and device and electronic equipment

    CN108255719A

  • Usage of keyboard driver in extensible firmware interface for adding new hot keys at firmware level

    US20060168376A1