Archive

Posts Tagged ‘Piger’

How to add command line arguments to your piger commands

April 1st, 2020 Comments off

First the basics

The first argument is the command we wish to execute, the second one is the command line argument and the last one is if we wish to run as administrator or not, (with privileged access).

How to get the arguments?

You have various commands to get the arguments entered.

You can get the ones typed by the user

Or you can also get the selected folder if there is one

Remember that we could have selected more than one folder

Putting it all together

If you have an app like cmder or even the default command line app you can put it all together

And save the file and call it “cmder.lua” and save it in your root command folder, (or subdirectory).

Then if the user types

  • cmder home – they will go to their home directory
  • cmder – they will go to their system drive
  • cmder (with the cursor over a folder name) – they will go to that folder.

More?

You can get more information on the piger github page

Categories: Cheat-sheet, Myoddweb Piger Tags: ,

How to compare multiple folders with BeyondCompare 4 and Piger

June 2nd, 2016 Comments off
Why?

In some cases you might often need to compare folders using beyond compare and using a Piger command might just do the trick.

The problem is that you might want to open/compare more than one folder at a time, so here is how to do it.

How

First of all, go and download your version of Beyond compare and get the latest version of Piger.

Open a blank file with your favourite editor, we will create a LUA file in this case.

— the path to the BC4 exe.
local bCompare = [[%ProgramFiles%\Beyond Compare 4\BCompare.exe]];

— compare folder A and folder B
am_execute( bCompare, [[/filters=”-bin\;-*.exe” “c:\folderA” “c:\folderB”]]);

— also compare folder X and folder Y
am_execute( bCompare, [[/filters=”-lib\;-*.user” “c:\folderX” “c:\folderY”]]);

The part “/filter=” contains the files you want to filter out, in the first example, the folder(s) “bin\” will be filtered out as well as files with the executable extension, (*.exe).

Finally, the 2 folders are listed one after the other, I suggest that you add quotes around them, especially if they have spaces, (but do it anyway).

Admin or not?

You might not access to all the folders, (for whatever reason), but you might have access as an admin, so, when in doubt, set the admin flag to true, this might help a little.

But it is not generally needed…

am_execute( bCompare, [[/filters=”-lib” “c:\X” “c:\Y”]], true);

String in LUA

A small note about the way I escaped the strings in my example.

normally special characters are ‘escaped’ in LUA, (characters like quotes and so on).

local x = “This is how you do it, \”normally\””

but you can use double square brackets to make your life slightly easier, (and more importantly, easier to read).

local x = [[This is how you do it, “normally”]]

See Lua String for more info.

Finally

Save you file with whatever command you want to call it, for example “compare.lua”, make sure that it has the “.lua” extension.

Move the file to your command folder, ( located in “%appdata%\MyOddWeb\ActionMonitor\RootCommands\” by default).

Reload Piger, (use the command “this.reload”).

And your new command should now appear.

What I had forgotten about WM_CLOSE

March 28th, 2016 Comments off

When I was working on the next version of Piger I would sometime get an issue when using the this.bye command, (to close Piger).

What happens in the background is I call WM_CLOSE to close the active window, this message is sent to all the windows.

When it is processed by the message pump no other messages are been processed, this is a problem in case some windows are still dishing out messages, (like a fading dialog box in our example).

So remember, once you call WM_CLOSE, all bets are off and your message pump is as good as dead.

Best to have your own ‘Close()’ that does all the housekeeping in the background before you actually post WM_CLOSE to the main thread…

Otherwise your app my appear to hang.

Released piger 0.3.2

February 27th, 2016 Comments off

I released the first version of Piger on Github after moving from sourceforge.net

This new release is pretty much the same as the previous one just brought to the 21st century …

The changes are

  1. Python 3.5.1
  2. Python is not required on the host machine, (something that was causing a break before!)
  3. Lua 5.2
  4. x64 or x86 build, (not for memory reasons, but for env. variable reasons).
  5. Moved from Sourceforge.net, (I added a readme.md to redirect to github). Please Google for some well documented reasons to move away from them…

Please try it and tell me if you see something cool that should be added.

I am also looking for cool scripts to be added to my list, so please, send them my way!

Categories: Myoddweb Piger Tags: , , ,

Embed Python in your C++ application without Python installed on guest machine

February 27th, 2016 Comments off

For my Piger application, I wanted my C++ app to parse Python scripts but I quickly became aware of the fact that the user must have Python installed on their machine, not only that they needed the same version as mine, (version 3.5).

The normal call would be something like…

But that throws an error when the user does not have Python installed.
And if they have an older version installed, it _might_ work, but the scripts might not work as expected.

The solution is to embed the Python you want to run in your app.

  1. Go to the Python website and download the Embeddable zip file for your app, (x64 or x86)
  2. Extract the python35.zip located inside that zip file
  3. Copy it somewhere where it can be referenced.
  4. Add the code below.

Now your app will work using version Python 3.5.1