dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2018
    Posts
    1

    How to create a AutoHotkey like hotstring using C++?

    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.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,153

    Re: How to create a AutoHotkey like hotstring using C++?

    Do you mean something like Accelerator Tables?
    Victor Nijegorodov

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.