-
Notifications
You must be signed in to change notification settings - Fork 71
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
Git REALLY hates me version. More changes thn you can poke a stick at #82
base: develop
Are you sure you want to change the base?
Git REALLY hates me version. More changes thn you can poke a stick at #82
Conversation
…e commands. This also makes it a lot easier to see what a command does, to modify commands, or to add new ones. This version has no new commands.
… a couple of new commands
1) break out the import of command modules so you don't have to modify LPHK.py to add a command 2) minor bug fix to error reporting in @async 3) correction of definition of symbol table in scripts.py
…ated (like an old time Hewlett Packard calculator). Very little functionality at the moment, but adding variables to the the symbol table will allow it to do real math and use the results. Putting the stack in the symbol table would allow this to be used to pass values between routines (as parameters), even allowing recursive routines!. Minimal checking right now, but a couple of examples show what can be done.
- Adds variables (global and local, but both currently local) - Adds error checking - Adds more commands - Documentation!
- Bug fixes - Documentation fixes - More documentation - Conditional statements in RPN_EVAL - Stack and global variables are now global to the scripts I would prefer if the stack and global variables were preserved across executions of a script, and local variables are local to that execution of the script (not just the line). Even better would be variables shared between concurrently running scripts (1 instance per instance of LPHK). that may be next.
…command * the stack and local variables are maintained across executions of a script. * the script is only validated the first time you run it, subsequently it is assumed to be OK * RESET_REPEATS is automatically called at the beginning of script execution to reset counters * Global variables are shared across ALL scripts * NO synchronisation of access to global variables (this will likely be problematic and I will fix it later) * Refactored scripts.py to make a button self-aware. In a future version this could be passed to commands to give a simpler interface to commands. * updated documentation * commented examples for the RPN_EVAL function showing how the stack, local, and global variables work.
* locking implemented for global variables * Better example scripts with comments * implemented last_x * added integer division, modulus, integer, frac, chs, and y^x operators * more internal documentation * handles integer and floating point constants as their own type * fixes a bug handling the constant 0 * KNOWN BUG: Validation flags errors but doesn't stop you from running a script!
* So, I called validate (that returns a boolean) instead of parse (that returns the error messages). And my Parse function also didn't do the setup required to operate correctly. A little shuffle shuffle and it's all fixed. * Also, tidied up a script a little (no functional changes).
* long scripts can be hard to debug. Now the line number of the script is printed along with any status or error message.
* Variables can be used in place of constants for mouse commands * variables must now start with an alpha character * refactoring begun on the validation and run code for commands to enable variables and simplify coding * documentation update * some typos fixed (especially with some command validation) This is not a final release. This version is an indication of how variables can be incorporated and still requires a lot of work.
* Damn! I thought I had committed this ages ago (657)
* only the mouse commands are implemented * this is a stepping stone to a far more elegant solution where commands can validate themselves. * updated documentation showing how to add new commands using variables * variables are readable only at present in commands other than RPN_EVAL try the following examples M_MOVE 1.2 7 This will fail because the first parameter is not an integer. negative numbers also cause failure to validate. RPN_EVAL 1.5 > a RPN_EVAL -1 > b M_MOVE a b This validates correctly, but fails at run-time an error indicating the second parameter is negative. The first parameter is converted to an integer, resulting in the value 1 being used. Note that this is currently a simple truncation.
* Parameters are defined in a tuple * No need to code a Validate function in most cases. * Only implemented for the Mouse commands_mouse.py * Significant simplification of the Run command * NewCommands.md not updated yet. :-(
* mostly changes to NewCommands.md * some bug fixes etc discovered while documenting
…ut not ready for prime time * Lots more internal documentation (especially in command_base.py) * constants pulled out into their own module. * Using constants instead of magic numbers for better internal documentation and clarity * Simplification of methods, removing unnecessary intermediate routines. * re-refactoring of commands structure to make it easier to understand. * improvements to validation and messaging structures * Lots of bugs erased! * parameters that aren't numbers don't get converted to 0 by silly code thinking they're variable references! * Added method of declaring "n or more parameters" * methods in RPN_CALC re-ordered to be the same as other commands * added a comment that if you like algebraic notation, you can write a simple infix to postfix converter and use the RPN_EVAL * improved layout in some areas * implementation of mouse commands converted to new structure * working on converting control commands to new structure Whilst a lot of bugs are appearing as I work through this, a great number of them are due to errors in my initial refactoring. The new structure makes it a lot harder to make mistakes (well, some mistakes)
… of a generic flow control class that makes all the other commands really simple. * new class Control_Flow_Basic * fixed problems with boolean return values matching true/false for some values * Fixed problem with auto-validate code to continue to work without auto-validation supplied. * further change to support the [n,None] definition for parameters
* definition pf PT_KEY to do auto-validation of "keys" parameters * addition of Command_Text_Basic class as a descendent of Command_Basic that handles commands with "text" parameters. * conversion of comment command to use Command_Text_Basic * addition of 2 new commands END and ABORT that do the same thing (terminate the script) * conversion of keys commands to use latest command model (as yet untested) * documentation of new commands * bug fix for handling of comments in scripts.py * noting the position in scripts.py where the problem with "second button presses" occurs. I think that the use of PyPI would help here because *reasons*
…he button. This will (in future) allow the buttons to be associated with something other than the 8x8 grid of the LaunchPad. One reason for this is to allow scripts to be called as subroutines without tying up a button. * line, lines, and symbols passed to routines replaced by btn object. * removal of constants associated with coords * created a new class command_text_basic that leaves all the parameters unchanged in split_line[1]. This makes it easier to deal with things like double spaces. * changed the parsing of commands that have no upper limit on their parameters to scan only the number that are present * corrected a very silly error with REPEAR_LABEL * Added an 'abort' command to RPN_EVAL to allow it to cause the script to exit. * Refactored *some* of the external commands. Commands that ideally require multiple strings, or strings with values interspersed are somewhat problematic. to handle transparently. * this version is probably suitable for initial testing. * NewCommands.md is getting very out of date...
* Remember to return values from validation steps * Fix an edge case for enumerating valid numbers of parameters * Correct handling of None vs Boolean vs tuple returns from validation * Fix validation for loaded layouts (it always failed) * Revert an instance of line being changed to btn.Line * Correct use of split_line[0] to cmd_txt in error message * corrections to CHeck_generic_param. It is getting both split_line and btn as parameters (more to do?)
…assed to commands that return values * Ensure we don't try to get the value of variables passed to functions that are supposed to return values into them * Modified M_STORE command to accept (optionally) a pair of variable names in which to place the current mouse coords * Initial work for a new parameter type that returns a boolean value * Re-Corrected the code to count valid param counts for yet another edge case. * Updated the Validate_param_n routine to ensure you don't try to check more parameters than are passed. * made the function Validate_var_name work if incorrect types passed to it. * moved Auto_Store from rpn_calc to Variables to allow any routine to store values in variables. * modified importing of additional commands to allow some commands to be made optional (e.g. win32 specific functions on a linux platform) * corrected referenceing of parameters from self.param to btn.symbols in a few places. * a few more locations found where btn.Line(x) should replace btn.line[x]
…inates are valid for multiple screen setups.
…(yes, setting!) their values * fix a dumb error that tried to look at the first non-existent parameter while validating * update the mouse commands to use the newer syntax
* First win32 specific code. I'd like to make this linux/mac compatible, but that's a future effort. For now it's an optional module in the interpreted form of the program (I'll have to explore the compiled form)
* Fix error in storing variables in RPN_EVAL
…-- to determine if you get to use constants, or also variables by ref or value
* Significantly improved win32 routines to handle various exceptions
… a fragment of the screen. * Modification to command_list to add the new commands as optional. NOTE the python code to scrape the screen has a bug. A link is given to a solution
… implementation of "object" variable types, and correcting a number of bugs and usability issues. * commands_browser_automation.py Implemented (but not tested) all the browsers supported by selenium in BA_START * commands_browser_automation.py Added BA_GET_URL to get the current url from the browser * commands_browser_automation.py Added BA_GET_ELEMENT to search for and return elements of a web page * commands_browser_automation.py Added BA_GET_TABLE_SIZE to get the size of a table * commands_browser_automation.py Added BA_GET_TABLE_CELL to get the contents of a table cell (element) * commands_browser_automation.py Added BA_GET_ELEMENT_TEXT to return the text of an element * commands_browser_automation.py Added BA_CLICK to click an element * commands_browser_automation.py Added BA_SEND_KEYS to send keys to an element * commands_control.py Added code to try to make differing types in IF statements Comparable * commands_control.py Changed parameters of IF commands from PT_FLOAT to PT_ANY * commands_rpncalc.py added substr command to RPN_EVAL * commands_subroutines.py Document default modifiers and implement/document the new Object modifier * commands_win32.py fixed a bug and improved documentation in W_PASTE * dialog.py Modified handling of dialogs to cause the application to become topmost when a dialog is open * scripts.py Prevent multiple indications of a thread being killed by stopping the reporting after it has been reported once * scripts.py ensure PT_ANY doesn't split quoted strings.
* commands_file.py added to introduce new filesystem commands to find home directory and to delete files * commands_browser_automation.py fix validation of wrong parameter, also placing comments in the right place * commands_browser_automation.py added new command BA_SHOW_ELEMENTS to dump the contents of an element * commands_external.py slight documentation and allow variables in CODE_NOWAIT * commands_rpncalc.py fix parameter ordering for substr, and ensure a return value is set. * commands_win32.py allow variables, and note problems with validation * commands_win32.py fix bug in W_COPY * scripts.py fix another bug in copy * window.py add code to display button descriptions when the mouse is over buttons
LPHK.py
Outdated
"-q", "--quiet", | ||
help = "Disable information popups", action="store_true") | ||
ap.add_argument( # make button text variable in size (default is small) | ||
"-f", "--fit", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe make this the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you talking about -q or -f? I see no reason not to make -f the default, and even to remove the option for all-the-same-size annotation text. (just discovered this comment thing!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the f (and there are loads more comments ;) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, OK. I misread "yeah the f" as something other than "yeah the -f option" :-D I will make it the default in my next commit.
…tine dependencies are checked * commands_subroutines.py Fix to parse routine to return errors so we can do something with them * commands_subroutines.py AddFunction properly handles errors in subroutine loading, including not actually loading it! * constants.py New colour (black) for disabled buttons * files.py set new flag "invalid_on_load" to true if script is invalid on load (rather than popping up a dialog that won't go away) * files.py When loading subroutines (not from a layout) keep track of all those loaded successfully or failed. Use this to print a message informing the operator. * files.py after add new routine to check buttons after changing subroutines. * files.py ensure return from Add_function is correctly checked for success * lp_colors add handling for disabled buttons * lp_colors.py supress a message about launchpad discoonnected that will otherwise show up 81 times. * Scripts.py define Button.invalid_on_load and set to False on init. * scripts.py Use invalid_on_load to prevent scheduling of a script * scripts.py Validate_script needs to return error message in case of error * scripts.py mark layout as changed if button scheduled to run is unbound. * scripts.py Unbind_all needs to actually unbind the buttons to cause the text on buttons to be removed. * scripts.py unloading all subroutines also needs to revalidate buttons. * test layout now has an error * window.py fix the "delete button before verifying" bug * window.py get_colour in draw_canvas knows to override colour on invalid buttons * window.py new function mark_disabled adds and removes red crosses over disabled buttons * window.py grid_rects now has room for the lines that need to be drawn and un-drawn to add/remove them * window.py validate_func used to validate scripts in the editor now also updates invalid_on_load
* Commands_Dialog allows variables for title and message * commands_keys.py Autovalidation using declared function fails for int when variable is passed - some code commented out to mask this. This duplicates a previous problem. Need to find a better solution * commands_scrape.py incorrectly spelt SW_SHOWMAXIMIZED * ruggedising of clipboard commands_dialog.py * scripts.py when copying a parsed button, the self.validated value must also be copied * added assorted comments and documentation
…onality improvements * command_list.py - Add commands_documentation.py as a module (to formalise the creation of documentation) * commands_browser_automation.py - add escape characters in sending of text \n (newline) \^ (up-arrow), and \h (home) * commands_browser_automation.py - add LABEL and CSS_SELECTOR as options to find elements * commands_browser_automation.py - rename class Bauto_send_keys to BAuto_send_Text to better match the command (BA_SEND_TEXT) * commands_documentation.py - move the quick and dirty command to create documentation from the test module to its own module (DOCUMENTATION). * commands_file.py - add a return code to F_DELETE * commands_file.py - add a command F_FILE_EXISTS to determine if a file exists * commands_file.py - add a command F_PATH_EXISTS to determine if a path exists * commands_file.py - add a command F_ENSURE_PATH_EXISTS to create directories to make a path valid * commands_scrape.py - add retries to code that gets an image from the clipboard, because it can fail the first time. * constants.py - further constants for DOCUMENTATION command * files.py - fix typo in dialog title * scripts.py - allow source to be included in documentation
help = "Operate without connection to Launchpad", type=str, choices=[LP_MK1, LP_MK2, LP_MINI, LP_PRO]) | ||
ap.add_argument( # option to start with launchpad window in a particular mode | ||
"-M", "--mode", | ||
help = "Launchpad mode", type=str, choices=[LM_EDIT, LM_MOVE, LM_SWAP, LM_COPY, LM_DEL, LM_RUN], default=LM_EDIT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly does this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It starts the program in the specified mode. The default is starting it up in edit mode, so that clicking on a button will start the editor. However, if you're operating without a launchpad, it makes more sense to start in run mode, so that clicking on a button will execute the macro. I always start mine in run mode now. The other modes are there just so you can chose one of them if you have a reason to,
): | ||
|
||
super().__init__("-", # the name of the command as you have to enter it in the code | ||
super().__init__("-, Comment", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that we need a command for this, it's probably faster to just ignore any lines that start with -
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the purpose of it :-)
* commands_rpncalc.py - New commands to allow math with dates * commands_scrape.py 2 bugs fixed. safe_sleep -> Safe_sleep, and passing wrong parameter back * commands_win32.py adding ability to search for windows based on a regex, and detecting the size of a window * INSTALL/* adding the extra modules I'm using. One serious bug remains. Passing a string to the IF commands passes the value incorrectly. The workaround is to assign the value to a string variable and pass that. The fix will involve changes to the parameter passing code.
* command_base.py - Added fields for command deprecation * commands_browser_automation.py - Improved documentation * commands_control.py - Added new IF command * commands_control.py - Deprecated old if commands * commands_control.py - Added Assert command * commands_dialog.py - Improved documentation * commands_documentation.py - Improved access to documentation * commands_file.py - Improved documentation * commands_header.py - improved documentation * commands_header.py - Added @doc+ header to better allow for text wrapping * commands_rpncalc.py - Added documentation (including autogeneration) * commands_scrape.py - slight improvement for documentation * commands_subroutines.py - move the documentation to the right place! * commands_test.py - mark all commands as deprecated * commands_win32.py - improved W_COPY command * commands_win32.py - improved documentation * commands_win32.py - new command to list all windows * constants.py - minor change to add documentation command to hide stuff you don't need to see * files.py - automatically remove blank lines at the beginning and end of subroutines * INSTALL/* - fixups for required libraries * scripts.py - smarter documentation routine to automatically wrap most text * scripts.py - Allow documentation lines in subroutines and buttons to be skipped when printing routine * window.py - Modification to work with newer python versions
* command_base.py Modification to constant flag to be a character more unusual than a quote. * command_base.py Addition of filter to display parameters without the constant flag * commands_control.py fix to "comparable" function to ensure literals compare correctly to variable values (finally!!!) * commands_control.py Better documentation of IF command * commands_external.py More documentation * commands_header.py Additional documentation * commands_keys.py More documentation * commands_mouse.py improved documentation * commands_pause improved documentation * commands_scrape.py significantly improved documentation * commands_subroutines.py slightly improved documentation * scripts.py addition of @name to script lines hidden.
Not sure why my commits in the last fortnight haven't appeared here... |
Oh, there they are! |
* commands-header.py - modify documentation to remove mention of the -f command line option * LPHK.py - remove the -f option and make variable size text the default (and only) option * run.bat remove use of -f option * window.py - always use variable size fonts on buttons
* command_list.py Changed WARNING to INFO as requested * commands_scrape.py Corrected error introduced with checking for Tesseract on the path * files.py - added check for version number before checking for subroutines
As far as I can tell, there are no conflicts between versions of commands_mouse.py or commands_scrape.py. As far as I can tell, all of the differences are now modifications in my code. |
…d LOAD_HEADER * commands_header.py - marking @LOAD_HEADER as deprecated * commands_file.py - Creating new command LOAD_HEADER
* commands_external.py - Added command OS_USERID to return the user id of the logged on user * commands_scrape.py - add alternate method of determining the dominant (vs average colour of an image using the command S_COLOUR * commands_scrape.py - slight fixes to documentation * commands_scrape.py - new commands to convert colour spaces and to determine brightness * commands_rpncalc.py - added new commands "ABS", "X<0?", and commands to convert to string ">A" and to get the length of a string "LEN" * commands_rpncalc.py - making sure LAST_X is correctly updated and that the documentation reflects this
…ariable onto the clipboard (rather than copying it directly)
How is the documentation and bugs currently? |
…the scripts in the buttons are huge, it can take a considerable amount of time to load them. An optional keyword has been added to the LAOAD_LAYOUT command to control the amount of validation and subroutine magic. The parameter "NORMAL" (default) does the normal thing, unloading subroutines, reloading the ones in the layout, loading the layout and checking both the subroutines and buttons. The keyword "FAST" retains the existing subroutines and does not load any specified in the new layout. However the loaded buttons are checked for correctness (and will fail at this if they call a subroutine that is not loaded. To use this successfully, you should ensure that all of your layouts have the same set of subroutines loaded within them. The final option "UNCHECKED" does the same as "FAST", but does NOT check buttons for correctness. Unchecked is significantly faster than "FAST" where there are a lot of buttons, or the buttons have long scripts.py. With "UNCHECKED" parts of the script are still checked. The parts that are checked are the headers since these are the lines that set titles and help strings.
…the button. This is currently experimental and does not limit the colours to those supported by the attached (or emulated) launchpad. The header @colour allows the colour of the button to be described in the script. The command must be followed by a 3 digit hex constant xyz that is converted to the colour #xxyyzz. As an example, @colour F00 makes the button colour bright red.
* Created GOTO and deprecated GOTO_LABEL - it just makes sense! * fixed bugs in reporting in the commands_mouse routines * commands_win32 makes more extensive use of pyperclip and some other reliability improvements * rearranged order of parameters in the various window finding commands and making more parameters optional to make the simple use cases more simple to implement * rearranged parameters on W_COPY to make them more sensible & make the simple use case simpler * improved reliability of W_PASTE (test!) * improved reliability for W_COPY_VAR * make window handle optional for W_WAIT * fake launchpad now implements LedCtrlFlashXYByCode(self, x, y, z) (bug fix) * Safe_sleep now has a default time of DELAY_EXIT_CHECK. Note that configuring DELAY_EXIT_CHECK to be too brief will make copy/paste commands unreliable NOTE: if you have a launchpad attached, for some reason you can't run a button by mouse clicking on it. This may or may not be a feature, since clicking on a button changes focus and this will mess up your scripts unless they can deal with this.
This is a bug-fix version. I found that there was a couple of problems running the code with a launchpad attached that had crept in. These are now resolved (I believe). I have given myself a shoulder injury so I have been off the computer for quite a while to let that fix itself (using the computer one-handed is a real pain) More documentation to be done (as I found out when I looked at the code again). |
Still has some known bugs, and still needs more documentation.
Coloured buttons
subroutines
auto-documenting
dialog boxes
more window handling
text on buttons (screen only, obviously)
standalone mode (no launchpad required)
RUN mode allows scripts to be initiated with a mouse
Start in any mode (Run, Edit, Move, Copy, etc.)
Probably a while lot more...