-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds TranspileOnly directive to print resulting AHK code instead of running it #116
Conversation
Looking at the test that failed I'm not sure that that was something I changed in this PR, although I'm by no means sure of that. I'm noticing that it passed on basically the exact same code in the commit before (and the last commit reverts the file back to how it looks on master) so it may just be a flaky test? |
Thanks for this. This is a good idea I've been hoping to implement. Though, directives are supposed to directly correlate 1-1 with a directive that exists in AutoHotkey. So, if I could request 1 change to this: that this be a keyword argument to the Thanks! |
You got it. One issue remains, many scripts will do more than one thing, which means a script like this will print twice: from ahk import AHK
ahk = AHK(transpile = True)
ahk.mouse_move(x=100, y=100, blocking=True) # Blocks until mouse finishes moving (the default)
ahk.mouse_move(x=150, y=150, speed=10, blocking=True) # Moves the mouse to x, y taking 'speed' seconds to move Result: #NoEnv
#Persistent
CoordMode Mouse, Screen
MouseMove, 100, 100, 2
ExitApp
#NoEnv
#Persistent
CoordMode Mouse, Screen
MouseMove, 150, 150, 10
ExitApp I'm not sure how to deal with this, because as far as I can tell you fire and forget AHK, you don't keep it around. In principle one could try and clean it up after the fact by removing duplicate directives and the |
Yeah, I think the result here would be intentional, since that's pretty much what is happening. Also worth noting that there is logging setup to log the scripts as well in the current version: import logging
logging.basicConfig(level=logging.DEBUG)
from ahk import AHK
ahk = AHK()
ahk.mouse_move(100, 100) will produce logging something like:
Though, the action is actually taken. Maybe this feature would be most useful by So someone could do something like: I guess I wonder how people would intend to use this feature. |
Closing this as the project will have a completely new underlying mechanism in v1 |
This is pretty simple, I modified a demo from the readme to get this:
This code did not execute any AHK, instead printing it to stdout:
I'm unsure if you want directives like this to be mixed in with "real" AHK directives, so perhaps this is not an ideal implementation. Also if you like this idea it probably would make sense to have options to write the output to a file instead of stdout.
I look forward to hearing what you think, and thanks for the good work!