I have figured out an effective way to create a hotkey using C++.
AutoHotkey example Alt+A to run a file.
Alt & a::
Run, C:\blah\blah\blah\abc.png
Return
C++ example Alt+A to run a file.
Code:
while(true) {
if( GetKeyState(VK_MENU) & 0x8000 ) {
if( GetKeyState('A') & 0x8000 ) {
ShellExecute(NULL, "open", "C:\\blah\\blah\\blah\\abc.png", NULL, NULL, SW_SHOWNORMAL);
}}}
I now want to understand how to create a hotstring using C++. For example how can I convert following AutoHotkey code into C++?
Code:
::abc::
Run, C:\blah\blah\blah\abc.png
Return
I don't know what logic the AutoHotkey developers used in creating the hotstring functionality but I think something like this might work.
Code:
if( GetKeyState(VK_SPACE) & 0x8000 ) {
// press Shift+Left until space detected;
// press Shift+Right after space detected;
// press Control+C to send highlighted word clipboard;
// convert clipboard to string;
// add that string to a variable;
if(//the value of variable is abc) {
ShellExecute(NULL, "open", "C:\\blah\\blah\\blah\\abc.png", NULL, NULL, SW_SHOWNORMAL);
}
else {//send space}}
The problem is I don't know how to implement this completely because while I can send keyboard events, I don't know how to detect highlighted characters and use them in if statements. plus, I don't know if this is the best way because it might make typing a simple space take too long. Someone please help.