-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
window scripts; make_script replaced by render_template
- Loading branch information
1 parent
8d7bcd5
commit 827a0ca
Showing
9 changed files
with
54 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from ahk.utils import make_script | ||
from ahk.script import ScriptEngine | ||
import ast | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% extends "base.ahk" %} | ||
{% block body %} | ||
WinClose, {{win.title}}, {{win.text}}, {{seconds_to_wait}}, {{win._exclude_title}}, {{win._exclude_text}} | ||
{% endblock body %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% extends "base.ahk" %} | ||
{% block body %} | ||
WinGet, ExStyle, ExStyle, {{win._title}}, {{win._text}}, {{win._exclude_title}}, {{win._exclude_text}} | ||
if (ExStyle & 0x8) ; 0x8 is WS_EX_TOPMOST. | ||
FileAppend, 1, * | ||
else | ||
FileAppend, 0, * | ||
{% endblock body %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% extends "base.ahk" %} | ||
{% block body %} | ||
WinGetPos, x, y, width, height, {{win.title}}, {{win.text}}, {{win._exclude_title}}, {{win._exclude_text}} | ||
s .= Format("({}, {}, {}, {})", x, y, width, height) | ||
FileAppend, %s%, * | ||
{% endblock body %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% extends "base.ahk" %} | ||
{% block body %} | ||
WinSet, {{subcommand}}, {{value}}, {{win.title}}, {{win.text}}, {{win._exclude_title}}, win._exclude_text}} | ||
{% endblock body %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends "base.ahk" %} | ||
{% block body %} | ||
WinGet windows, List | ||
Loop %windows% | ||
{ | ||
id := windows%A_Index% | ||
WinGetTitle wt, ahk_id %id% | ||
r .= wt . "`n" | ||
} | ||
FileAppend, %r%, * | ||
{% endblock body %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,15 @@ | ||
import os | ||
from textwrap import dedent | ||
import logging | ||
|
||
logger = logging.getLogger('ahk') | ||
handler = logging.StreamHandler() | ||
formatter = logging.Formatter( | ||
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s') | ||
handler.setFormatter(formatter) | ||
logger.addHandler(handler) | ||
if os.environ.get('AHK_DEBUG'): | ||
logger.setLevel(logging.DEBUG) | ||
else: | ||
logger.setLevel(logging.ERROR) | ||
|
||
|
||
def make_script(body, directives=None, persistent=True, blocking=True): | ||
""" | ||
Convenience function to dedent script body as well as add #Persistent directive and Exit/ExitApp | ||
:param body: body of the script | ||
:param directives: an iterable of directives to add to the script. | ||
:type directives: str or ahk.directives.Directive | ||
:param persistent: if the #Persistent directive should be added (causes script to be blocking) | ||
:return: | ||
""" | ||
exit_ = 'ExitApp' | ||
if directives is None: | ||
directives = set() | ||
def make_logger(name): | ||
logger = logging.getLogger(name) | ||
handler = logging.StreamHandler() | ||
formatter = logging.Formatter( | ||
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s') | ||
handler.setFormatter(formatter) | ||
logger.addHandler(handler) | ||
if os.environ.get('AHK_DEBUG'): | ||
logger.setLevel(logging.DEBUG) | ||
else: | ||
directives = set(directives) | ||
|
||
if persistent or blocking: | ||
directives.add('#Persistent') | ||
|
||
if not blocking: | ||
directives.remove('#Persistent') | ||
|
||
dirs = '\n'.join(str(directive) for directive in directives) | ||
|
||
script = dedent(f'''\ | ||
{dirs} | ||
{body} | ||
{exit_} | ||
''') | ||
return script | ||
logger.setLevel(logging.ERROR) | ||
return logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters