ZAAP Scripting
ZAAP Scripting can be used to extend ZTreeWin's capabilities in ways that cannot be matched by the F9 Application Menu.In particular it is possible to modify lists of tagged files.
ZTreeWin has a powerful tagging capability, which lets you select files by combining a number of criteria, but is limited to boolean logic and cannot compare between different fields.
I wanted to identify files which have a "Creation Date" after Last Write.
This could be done by generating a list of files, filtering in an external script, and using Zlog to tag the resulting files.
It can be done directly using a script accessing the ZAAP capability.
Usage
- Execute the AutoIt3 script.
- Tag the list of files to be analysed.
- Run the ZTreeWin Ctrl-Y Assist command, Enter at the prompt.
; Purpose: This is a AutoIt3 script to Untag files where Creation is after Last Write
; i.e. to leave a tagged list of files "created" after last write
; Author: Ian Binnie
; Requires: ZbarCOM.dll (this is a COM wrapper around ZbarLib)
; Source: http://binnie.id.au/Downloads/ZbarCOM.zip
; Requires: AutoIt v3
; Source: http://www.autoitscript.com/autoit3/
; Note: ZTreeWin needs to have the ZAAP feature enabled (by use of the /ZB command line switch).
; Note: ZbarCOM.dll needs to be registered
#include <GuiConstants.au3>
#Include <date.au3>
Dim Const $ZBAR_NEW = 1
; This code block logs zbar.dat
$oZbar = ObjCreate("ZbarCOM.Zaap")
If @error Then
MsgBox(4096,"Error", "Cannot create object")
Exit
Else
$LogResult = $oZbar.LogZbar
If @error Then
MsgBox(4096,"Error", "Cannot run method LogZbar")
Exit
Else
If $LogResult == 0 Then
$ReadResult = $oZbar.ReadZbar
If @error Then
MsgBox(4096,"Error", "Cannot run method ReadZbar" )
Exit
EndIf
Else
MsgBox(4096,"Error", "Cannot Log zbar.dat" & $LogResult, 10)
EndIf
EndIf
EndIf
; loop to monitor zbar.dat
While 1
$ReadResult = $oZbar.ReadZbar
If $ReadResult == $ZBAR_NEW Then
$WriteZbar = Asc("k") ; Error response, use "e" to pause ZTree, "u" to untag, "k" to leave tagged
$ZtreePage = $oZbar.ZtreePage
If $ZtreePage == Asc("F") Then
$NewFilename = $oZbar.NewFilename
$tw = FileGetTime($NewFilename, 0, 0)
$tc = FileGetTime($NewFilename, 1, 0)
If NOT @error Then
$WriteZbar = Asc("k") ; handshake response to ZTreeWin "Y" command
$dd = _DateDiff('s', FileDate2ISO8601($tc), FileDate2ISO8601($tw) )
If NOT @error Then
; The following untags files where Creation is no later than 120 seconds after Last Write
If ($dd > -120) Then $WriteZbar = Asc("u") ; untag
EndIf
EndIf
EndIf
; The following lines automatically respond to ZTreeWin "Y" command
$ZtreeCommand = $oZbar.ZtreeCommand
If $ZtreeCommand == Asc("Y") Then
$oZbar.WriteZbar ($WriteZbar) ; response to ZTreeWin "Y" command
EndIf
Else
Sleep(1)
EndIf
WEnd
Exit
; Convert DateTime array to ISO 8601 string
Func FileDate2ISO8601($dt)
$value = $dt[0] & "-" & $dt[1] & "-" & $dt[2] & " " & $dt[3] & ":" & $dt[4] & ":" & $dt[5]
Return $value
EndFuncDownload
ZbarCOM (12.818Kb)AutoIt3
Contributors to this page: ian
.
Page last modified on Sunday 08 of November, 2009 17:27:18 EST by ian.
Category: ZAAP and ZTree utilities
- wiki page:
Category: ZAAP Utilities
