Run selected text in AutoHotKey AHK

Run selected text in AutoHotKey AHK

1581
Power UserPower User
1581

    Jan 22, 2015#1

    I edit a file for AutoHotKey and want to test it.

    Way 1 - save and run:
    User defined tool - Option "Save before run" - "ahk.exe %F"
    That works fine and is no problem.

    Way 2 - run the a) entire content / b) the selected content without saving?
    I tried the user defined command "ahk.exe %sel%" - but no success.

    How to run Way 2a or 2b?

    Peter
    UE 26.20.0.74 German / Win 10 x 64 Pro

    6,680583
    Grand MasterGrand Master
    6,680583

      Jan 23, 2015#2

      Command line interface of Windows, Linux and MacOS do not support parameter strings containing newline characters. Therefore it is not possible to pass a multi-line string as parameter to an application. You must copy the selection into a new file and save it with a file name.

      It would be perhaps a good idea for use cases like this one if IDM Computer Solutions, Inc. would enhance the list of options for user and project tools by one more option.

      %sel% results in passing the current selection (without newline characters) as parameter to started application. So behavior is unchanged for %sel%.

      But with %SEL% the behavior changes. In this case UE/UES should
      1. create in directory %TEMP% a new file with a random but unique file name using encoding of active file,
      2. copy current selection into this new file and save it,
      3. start the application and pass for placeholder %SEL% the name of the temporary file,
      4. wait until started application terminated in case of a console application or a few seconds in case of a Windows application,
      5. delete the temporary file.
      I don't know if the scripting syntax of AutoHotKey makes it possible to delete all newline characters and get nevertheless a working code as with C/C++/JavaScript and other programming languages.

      In this case it would be possible for small multi-line selections to use an UltraEdit script to
      1. copy the selection into a new file,
      2. remove all leading spaces/tabs,
      3. remove all trailing spaces/tabs,
      4. remove all carriage returns and line-feeds,
      5. select the remaining single line string,
      6. run the user tool from within script,
      7. close the new file without saving.
      This would be a possible solution for small selections of a code block not exceeding the command line length limits after removing all unnecessary white spaces if the scripting syntax of AutoHotKey do not depend on line terminators.
      Best regards from an UC/UE/UES for Windows user from Austria

      1581
      Power UserPower User
      1581

        Jan 23, 2015#3

        Hi Mofi

        I suppose you sent your idea directly to IDM?
        UE 26.20.0.74 German / Win 10 x 64 Pro

        6,680583
        Grand MasterGrand Master
        6,680583

          Jan 24, 2015#4

          No, I have not sent my idea to IDM support up to now.
          Best regards from an UC/UE/UES for Windows user from Austria