Giter Site home page Giter Site logo

ahkscript / sublimeautohotkey Goto Github PK

View Code? Open in Web Editor NEW
203.0 47.0 44.0 133 KB

AutoHotkey AHK language package for SublimeText including syntax highlighting, comments toggling, auto-completions, build system definitions, commands for ahkrun, ahkcompile, ahkrunpiped.

License: The Unlicense

Python 100.00%

sublimeautohotkey's Introduction

SublimeAutoHotkey - Syntax Package for Sublime Text 2/3

AutoHotkey AHK language package for SublimeText including syntax highlighting, comments toggling, auto-completions, build system definitions, commands for ahkrun, ahkcompile, ahkrunpiped.

Package Installation

Key Bindings

If you have the default Sublime keybindings intact, then:

  • Ctrl+B will run the current file (with AutoHotkey.exe)
  • Ctrl+Shift+B will compile the current file (with Ahk2Exe.exe)

Advanced Configuration

For the build system and ahkrun, ahkrunpiped, and ahkcompile commands, if you have a non-default installation then you will need to set your specific path to AutoHotkey.exe and Ahk2Exe.exe in a file named AutoHotkey.sublime-settings in your User folder. You can access these settings file from the Menu Preferences > Package Settings > AutoHotkey. You should make a copy of AutoHotkey Settings - Default at AutoHotkey Settings - User and modify there since then any settings defined in your User folder will take precedence and the package can still update itself without overwriting your custom settings.

ahkrunpiped

The ahkrunpiped command will allow you to run your code as a piped text string to AutoHotkey (this allows you to run snippets of code without having to save them to a file):

  • If text is selected - ahkrunpiped will pipe and run the selected text only.
  • If no text is selected - ahkrunpiped will pipe and run the entire contents of the current document.

Goto-documentation Integration

Instructions on how to configure goto-documentation plugin for AutoHotkey (F1 Hotkey will take you to documentation for word under cursor)

Credits

sublimeautohotkey's People

Contributors

joedf avatar lildude avatar nuj123 avatar ragnar-f avatar robertcollier4 avatar taebox avatar tmplinshi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublimeautohotkey's Issues

[Feature request] AutoHotkey output panel hide

Request

It would be nice, if you add opportunity hide AutoHotkey panel, if script run was successfully.

Justification

I need hide panel manually, I spend time on it.

Steps for reproduce

I install AutoHotkey → I install and configure SublimeAutoHotkey → I create any ahk file, for example:

:R*:/Sasha::Sasha is amazing!

Ctrl+Shift+PAutoHotkey - Run → if script successful run, output panel not hide for me.

Actual behavior

Possible solution

See answer of BuildNext plugin owner.

        exit_code = proc.exit_code()
        errors_len = len(self.output_view.find_all_results())

        if (exit_code != None and exit_code != 0) or errors_len > 0:
            self.window.run_command("show_panel", {"panel": "output.exec"})
        else:
            self.window.run_command("hide_panel", {"panel": "output.exec"})

Thanks.

Run selection as piped buffer not working

if i choose "run as piped buffer" from the tool menu it runs the file, but if i select some text and try it i get this message:

Error at line 0.

Script file "\\.\pipe\AHK_124765703" cannot be opened.

The program will exit.

i have autohotkey installed in the default location, maybe its the portable version of sublime text 3 that has something to do with it?

Allow download/install on Linux (OSX?)

I'm running AutoHotkey under Wine to automate some Wine programs. However this package is marked Windows-only. Can you edit package-metadata.json (or Package Control settings) to allow installation under all platforms?

I think Package Control is deleting my package whenever I try to copy it from Windows. User-hostile action?

It seems that platform * works.

Ctrl+B doesn't support file path that containing Chinese characters

Console Log:

Running D:\code\AutoHotkey\AutoHotkey.exe /ErrorStdOut D:\Desktop\测试.ahk
Traceback (most recent call last):
File ".\sublime_plugin.py", line 337, in run_
File ".\exec.py", line 154, in run
File ".\exec.py", line 48, in init
File ".\subprocess.py", line 633, in init
File ".\subprocess.py", line 842, in _execute_child
UnicodeEncodeError: 'ascii' codec can't encode characters in position 58-59: ordinal not in range(128)

Tested on Sublime Text 2, Windows 10 x64.

How do I disable autocompletion for the parameters?

How can I make it so the autocomple only finishes the command and not input every single possible parameter? For example, autocompletion of WinWait should be only WinWait and not WinWait, WinTitle, WinText, Seconds [, ExcludeTitle, ExcludeText].

Selenium COM Timeout when script Built from within Sublime

I'm running into a really strange bug that i can't figure out.

I recently made the switch from AHKStudio to Sublime.
I use Selenium to automate Chrome with Autohotkey, and when i try to build a selenium script using the default build system within Sublime i get a:
TimeOut Error
"The driver failed to open the listening port 127.0.0.1:14198 within 10s
Screenshot

The script runs fine if i execute it within AHKStudio, or if i navigate to it in windows explorer and run it, or if i pass it as a parameter to the Autohotkey Executable through CMD.
It's something within Sublime that is causing it to fail, and i'm not sure what could possibly be causing it.

Sample Code:

driver:= ComObjCreate("Selenium.CHROMEDriver") ;Select and Create Chrome driver instance
driver.Get("https://duckduckgo.com/") ;Open selected URL
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding

can't "Goto symbol"

I am having trouble with the "Goto Symbol" functionallity
It works great in the majority of cases. But... in other, the list of symbols is empty.
One file where this happens, is tic's gdip.ahk

does this happen to any one else?

v1.3.0 missing help text

Hello,

There are no help text in version 1.3.0. For example:
MsgBox
LV_Add

I'm now back to use 1.2.9, which has help text like this:
MsgBox, [ Options, Title, Text, Timeout]
LV_Add([Options, Col1, Col2, ...])

[Bug] Not compiling scripts

Summary

Not compiling .ahk scripts.

Expected behavior

Compiling .ahk to .exe, when I use ahkcompile command.

Actual behavior

Not compile.

command: ahkcompile
Traceback (most recent call last):
  File "E:\Sublime Text 3\sublime_plugin.py", line 553, in run_
    return self.run()
  File "ahkexec in E:\Sublime Text 3\Data\Installed Packages\AutoHotkey.sublime-package", line 44, in run
TypeError: list indices must be integers, not str

Steps to reproduce

I tested on Sublime Text without plugins.

I open, for example, this script → save this script in UTF-8 with BOMCtrl+Shift+PAutoHotkey - Compile.

Environment

Operating system and version:
Windows 1067
Sublime Text:
Build 3114
AutoHotkey
Portable Unicode 32-bit

Thanks.

Sublime Completion Request - %% for variables

this package is super useful. I'd like to see the the double percent - "%%" used in autohotkey to wrap variable names added as a completion.

I've tried adding this snippet to the AutoHotkey.sublime-completions file

{ "trigger": "%%", "contents": "%%" },

but that did not do it. Perhaps other, more expert contributors know the way :-)

Inconsistent execution bug

Steps to reproduce

output := ComObjCreate("WScript.Shell").Exec("powercfg /requests").StdOut.ReadAll()  
MsgBox % output

Run from Sublime Text it will show an incorrect output, different from the output of running powercfg /requests from a command prompt. Run by clicking on the .ahk file it will show the correct output.

Also described in ComObjCreate("WScript.Shell").Exec("powercfg /requests") returns different output than actual command run in command prompt : AutoHotkey

Fix

Using AutoHotkeyU32.exe / AutoHotkeyA32.exe on x64 systems runs into this bug.
Changing to a 64-bit executable fixes it.

AutoHotkey.sublime-settings

{
  "AutoHotKeyExePath":
  {
    "default": "C:\\Program Files\\AutoHotkey\\AutoHotkey.exe"
  }
}

Reload/build script very unreliable

When I hit Ctrl+B to build/reload my script, nothing happens.

I'm using Windows 8.1 and Sublime build 3083 and I have changed the path to Autohotkey.exe in my user settings.

Include directive doesn't allow a comma

#Include, %A_ScriptDir%\functions.ahk

When you have a comma after #Include, the highlighting becomes incorrect, despite it is a valid AutoHotkey syntax.

  • #Include should be violet.
  • The comma and the path should be green.

include

Moving from tmLanguage to sublime-syntax

Default packages are now use sublime-syntax format instead of tmLanguage. SublimeAutoHotkey doesn't. (Actually, it seems the new format was introduced back in 2016.)

The new format seems to be easier to edit (no XML) and also more powerful.

Specific features in .sublime-syntax that are not available as part of .tmLanguage:

  • The set directive
  • Pushing multiple contexts via a push or set directive. (A single push/pop is equivalent to begin/end.)
  • The clear_scopes directive
  • Variables

Run as piped buffer doesn't work

The error message is:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 549, in run_
    return self.run(edit)
  File "ahkexec in C:\Users\fia\AppData\Roaming\Sublime Text 3\Installed Packages\AutoHotkey.sublime-package", line 96, in run
TypeError: 'NoneType' object is not subscriptable

Multiple paths for AHK executables

It doesn't seem to be possible to enter multiple paths for AutoHotKeyExePath and Ahk2ExePath, like so:

{
    "AutoHotKeyExePath": {
        "default": ["C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe", "C:\\Program Files\\AutoHotkey\\AutoHotkey.exe"]
    },
    "Ahk2ExePath": {
        "default": ["C:\\Program Files (x86)\\AutoHotkey\\Compiler\\Ahk2Exe.exe", "C:\\Program Files\\AutoHotkey\\Compiler\\Ahk2Exe.exe"]
    }
}

Am I just doing it wrong? Or could support for this be added?

The reason I want this is that I'm using the Sublime Package Syncing to sync my Sublime settings between my home computer and my work computer and the executables are saved under different paths on the two computers.

version 1.5.0 with syntax error ?

when i try to run a script from sublime an error message is shown about unexpected comma before bracket

so manually inspecting the file

file: AutoHotkey.sublime-build
lines 8 and 9 follow:

   "target": "ahkcompile",
}

i tried with a fresh sublime 2.0.2 (portable) and upon installing package control and then SublimeAutoHotkey, there is the error.

by the way, despite fixing that, in menu Tools > "AutoHotkey - Run" and the other 2 options are greyed out. The whole ahk build system stopped working several days ago but i didnt bother, so i dont know if it was v1.4.0, v1.4.1, or v1.5.0 that broke it, but i gather this is a matter for a new issue after i make sure its not some detail on my end.

Incorrect highlighting with multi-line directives

Compare

#If, WinActive("ahk_exe foo.exe") || WinActive("ahk_exe bar.exe")

...

#If, WinActive("ahk_exe foo.exe") && CustomFunction()

...

with

#If, WinActive("ahk_exe foo.exe")
    || WinActive("ahk_exe bar.exe")

...

#If, WinActive("ahk_exe foo.exe")
    && CustomFunction()

...

Images:

1
2

It seems the lines 2 and 7 should be green, but they aren't.

Reloading current file?

Is there a way to reload the current AHK script directly from Sublime? If not, would you consider adding it?

[Feature request] Compile and run

1. Request

It would be nice, if would be possible to compile and run AutoHotkey scripts, even if current file already run.

2. Justification

AutoHotkey user/developer will needs fewer steps, it will save his time.

3. Settings

I have a file KristinitaSnippets.ahk. Now I have in it more than 200 snippets, which I use several times per hour. Example snippet:

:R*:/Кристина::Кристина изумительна!

Almost every day I update this file.

4. Steps to reproduce

I write new snippet in KristinitaSnippets.ahk file → I save file → I want run new KristinitaSnippets.exe file with my new changes.

5. Actual behavior

If KristinitaSnippets.exe process enable, Ctrl+Shift+PAutoHotkey compile → compilation failed.

Failed

I need manually close KristinitaSnippets.exe process → Ctrl+Shift+PAutoHotkey — CompileCtrl+Shift+PAutoHotkey — Run → I can use my new snippets.

6. Desirable behavior

If KristinitaSnippets.exe process enable, Ctrl+Shift+PAutoHotkey: Compile And Run → old KristinitaSnippets.exe process close → new KristinitaSnippets.exe process run → I can use my new snippets.

Thanks.

InputBox completion suggestion

Hey, great package! :)

I've noticed the InputBox syntax completion is missing the Default parameter.

Current Syntax from the docs

InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default]

Current completion the package is suggesting

InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout

Wrong block comment highlight

/* and */ symbols can be used to comment out an entire section, but only if the symbols appear at the beginning of a line (…)
https://autohotkey.com/docs/Language.htm#comments
It does not correspond with defined syntax:

<dict>
<key>begin</key>
<string>/\*</string>
<key>end</key>
<string>\*/</string>
<key>name</key>
<string>comment.block.ahk</string>
</dict>

supposedly yielding:
ahk-comment-highlight-bad 4b16c
Correct highlight should be
ahk-comment-highlight-good 4b16c


Ran into this in VSCode port ( stef-levesque/vscode-autohotkey#9 ) and after fixing noticed it is derived from here; it seems most (other derived) syntax definitions for AHK exhibits the same bug.

ctrl+b runs, ctrl+shift+b compiles

I have the default Sublime keybindings, but it will run when pressing ctrl+b & compile when ctrl+shift+b, i don't know why?!

the menus "Tools > AutoHotkey - Run" & "Tools > AutoHotkey - Compile" works well.

How can i run my script?

Hi,

"Ctrl+B will run the current file (with AutoHotkey.exe)" is not working for me.
It always compiles the .ahk to an .exe but it won't run it.

what can i do?

Add 'single quoted strings'

Currently only "double-quoted strings" are recognized with the scope name of string.quoted.double.ahk, but not
'single quoted strings'.
I've created a patch via a simple copy&paste of this scope but for single quote marks also changing the name to string.quoted.double.ahk and removing constant.character.escape.ahk, which as far as I understand is not needed for single quoted strings

Should I include a Sublime Text 3 only plugin in this distribution

Hi.
I was thinking of making a plugin that will display tooltip help for a command, directive or a function. It works when you press the required key combo while the caret is on the ahk keyword.
To display tips, it will make use of show_popup() function which is available only in ST 3.
Should I proceed ?

@robertcollier4 @Ragnar-F @joedf

A prototype looks like this -
tthelp

It refers to the .sublime-completions file for syntax. I will have to add a .no-sublime-package file in this repository for this to work.

Syntax highlighting missing for AutoHotkey Built-in Variables

I recently moved from notepad2-mod to Sublime Text 3 and I noticed that his (otherwise excellent) syntax package unfortunately is NOT highlighting AutoHotkey Built-in Variables (e.g. variables beginning with 'A_' such as 'A_WorkingDir' and other vars such as 'Clipboard', 'ErrorLevel', etc..

These built-in variables DO show up in the autocomplete feature BUT they do NOT display wth a unique color after they have been entered (which would be really useful!). Instead they appear just like other user-defined variables with no color differentiation.

A full list of these variables can be found here: https://autohotkey.com/docs/Variables.htm#BuiltIn
Is there any chance that these variables could be uniquely color-coded in a future update? (It would be much appreciated :) -JT

until loops doing the wrong indentation.

Problem: When I use Edit > line > Reindent on a block of code that contains a loop { } until, reindent always indents the section incorrectly.

Before reindent:

Loop
{
	ClickS(TdollRetirementSlot1x+180*rti,TdollRetirementSlot1y)
	ClickS(TdollRetirementSlot1x+180*rti,TdollRetirementSlot1y+318)
	rti := rti+1
	Sleep 10
}Until (rti > rti2)

After reindent:

Loop
{
	ClickS(TdollRetirementSlot1x+180*rti,TdollRetirementSlot1y)
	ClickS(TdollRetirementSlot1x+180*rti,TdollRetirementSlot1y+318)
	rti := rti+1
	Sleep 10
	}Until (rti > rti2)

Also happens with commented out lines

Before reindent:

; SetFilter := 1
; loop, 1
; {
; 	sleep 500
; 	RFindClick("TdollRetirementSelect", "rNoxPlayer mc oTransN,40 w30000,50")
; 	If(SetFilter == 1)
; 	{
; 		RFindClick("SmartSelect", "rNoxPlayer mc o10 w30000,50")
; 		SetFilter--
; 	}
; 	sleep 500
; 	RFindClick("TdollRetirementOK", "rNoxPlayer mc o50 w30000,50")
; }

After reindent:

; SetFilter := 1
; loop, 1
; {
	; 	sleep 500
	; 	RFindClick("TdollRetirementSelect", "rNoxPlayer mc oTransN,40 w30000,50")
	; 	If(SetFilter == 1)
	; 	{
		; 		RFindClick("SmartSelect", "rNoxPlayer mc o10 w30000,50")
		; 		SetFilter--
		; 	}
		; 	sleep 500
		; 	RFindClick("TdollRetirementOK", "rNoxPlayer mc o50 w30000,50")
		; }

Does not work

Simply does not work. I tried to install both ways without given the highlighting option in sublime text 3 newest version 2019-10-17.

When will there be a fix?

fix for function regex matching if statements

Posting this here for anyone using this.
Problem:
currently the function regex matches if statements too if using OTB style causing bad code highlighting on everything in that line.
Fix:
change regex on

<string>^\s*(\w+)(\()(.*)(\))\s*({)\s*(;?.*)$</string>

to ^\s*((?!\bif\b)\w+)(\()(.*)(\))\s*({)\s*(;?.*)$ seems to fix it, this could be expanded to include other statements (like while).

Comment line doesn't include EOL

Currently there is a very annoying bug with ; style comments — autocompletion doesn't turn itself off because it doesn't recognize the last caret position as a comment.line.ahk scope
(so, it's only turned off when you edit comments since then you move away from the end of the line)

changing
<string>(^\s*|\s+)(;)(.*)$</string>
to
<string>(^\s*|\s+)(;)(.*)(\n?)$</string>
fixes it for me, so I'll submit a patch, though not 100% certain this is the proper fix

[Suggestion] Autocomplete To Shows Custom Vars/Functions

First of all my apologies since I don't know where to post suggestions. Also, I really like the project so far, it's working quite well.

I'm not sure how your autocomplete system works, but I've noticed that my custom variables and functions don't always show up in the autocomplete list. For example:
untitled__-sublime_text unregistered _2014-01-01_15-24-55

Before using your package, I used Sublime's C++ built in syntax highlighter:
untitled__-sublime_text unregistered _2014-01-01_15-28-49

Perhaps I'm missing something?

inline comment

inline comment should be detected as comment and not syntax highlighted

Snippets / completions outdated

Some of the snippets / completions use old syntax, others have little typos or opinionated defaults.
A refresh is in order.

Interactive Debugging

I would like to be able to use the AHK's support for DBGp.
However, I was only able to find one forum entry asking for help without replies.

I anyone using this (or the Xdebug Client package) for AHK coding in sublime?

syntax error when using ::

i noticed this syntax error a while back, i think it was in version 1.7.0 as far as i remember but im not sure how far it goes back.

screenshot 2016-12-01

opening build tab

New version opening result of build in new tab.
I think build panel enougth.
Yet i use old ahkexec.py file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.