The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,358 other followers

Archive for January 6th, 2021

Automating the closing of the Creative Cloud signing and ABBY FindReader for ScanSnap 5.0 dialogs

Posted by jpluimers on 2021/01/06

Every time my scan VM logs on I get the dialog on the right.

Every time I finish an OCR scan, I get the dialog below.

There are two reasons I want to close the ABBY dialog:

  1. While open, it will keep both the original PDF and OCR PDF files alive.When after a while, Windows updates auto-reboots the machine, before clicking the OK buttons I have to manually check if the conversion succeeded before removing the non-OCR PDF.This is time consuming.
  2. While open, it still consumes a lot of system resources: about 100 megabyte for a simple single monochrome A4 page. Much more for complex, multi-page or colour documents.When scanning a lot of document this causes the system to run out of memory, after becoming much much slower because the truckload of Window handles and underlying threads drags Windows down.

I do not want to fully get rid of these dialogs, as often being aware of the progress is important, and I always forget how to re-enable things. If you can do without the dialogs, then try these:

Finding the Windows and controls

I did use one nice feature of AutoHotKey: their Windows Spy utility, which is implemented as a AHK script: [WayBack] AutoHotKey-scripts/WindowSpy.ahk at master · elig0n/AutoHotKey-scripts · GitHub. In the past this was a separate executable, so do not start looking for that any more. You can get it either after a full install of the [WayBack] Releases · Lexikos/AutoHotkey_L · GitHub, or by extracting from the most current AutoHotKey.zip from [Archive.is] AutoHotkey Downloads.

Related:

This gets these for the Create Cloud and ABBY windows:

Automating the click

I contemplated about using AutoIt (freeware, but closed source) or AutoHotKey_L (the current active fork of AutoHotKey).

AutoIt is now closed source, forked in the past as AutoHotKey, which has a lot of half backed – usually poorly documented – scripts needing you to learn a new API wrapper around existing Windows API functionality.

So I reverted back to using the Windows API using Delphi: a simple repeat loop, to check for the existence of the underlying processes, windows and controls, plus some logic to terminate then the user stops the application (Ctrl-C, Ctrl-Break), logs off, or Windows shuts down.

Releated Windows API  keywords and posts:

 

I could have used AutoHotKey with these hints to get it working:

MacOS

Note that when you run on MacOS, you need an alternative like for instance the video below shows via [WayBack] Stop ScanSnap From Prompting You When You Scan.

–jeroen

Read the rest of this entry »

Posted in Development, Fujitsu ScanSnap, Hardware, ix100, ix500, Power User, Scanners, Scripting, Software Development, Windows, Windows 10, Windows 8.1 | Leave a Comment »

Batch files: deleting first/middle/ending parts of environment variables

Posted by jpluimers on 2021/01/06

Batch files are often a pain to write, but you cannot always rewrite them in PowerShell.

The pain below is about deleting parts of environment variables in batch files.

I’ll just redirect to and quote from posts that can way better describe this than I do:

  • [WayBack] Check if Batch variable starts with “…” – Stack Overflow made me find
  • [WayBack] windows – Batch – Delete Characters in a String – Super User
  • [WayBack] CMD Variable edit replace – Windows CMD – SS64.com

    The variable _test containing 12345abcabc is used for all the following examples:

    ::Replace '12345' with 'Hello '
       SET _test=12345abcabc
       SET _result=%_test:12345=Hello %
       ECHO %_result%          =Hello abcabc
    
    ::Replace the character string 'ab' with 'xy'
       SET _test=12345abcabc
       SET _result=%_test:ab=xy%
       ECHO %_result%          =12345xycxyc
    
    ::Delete the character string 'ab'
       SET _test=12345abcabc
       SET _result=%_test:ab=%
       ECHO %_result%          =12345cc
    
    ::Delete the character string 'ab' and everything before it
       SET _test=12345abcabc
       SET _result=%_test:*ab=% 
       ECHO %_result%          =cabc
    
    ::Replace the character string 'ab' and everything before it with 'XY'
       SET _test=12345abcabc
       SET _result=%_test:*ab=XY% 
       ECHO %_result%          =XYcabc
    
    
    :: To remove characters from the right hand side of a string is 
    :: a two step process and requires the use of a CALL statement
    :: e.g.
    
       SET _test=The quick brown fox jumps over the lazy dog
    
       :: To delete everything after the string 'brown'  
       :: first delete 'brown' and everything before it
       SET _endbit=%_test:*brown=%
       Echo We dont want: [%_endbit%]
    
       ::Now remove this from the original string
       CALL SET _result=%%_test:%_endbit%=%%
       echo %_result%

    All the examples on this page assume the default Expansion of variables, if you are using DelayedExpansion then you can choose to change the variable references to !_variable! instead of %_variable%

    One advantage of DelayedExpansion is that it will allow you to replace the % character, it will still have to be escaped as %% but the replace action will then treat it like any other character:

    Replace the letter P with a percent symbol:
    Setlocal EnableDelayedExpansion
    _demo=somePdemoPtextP
    _demo=!_demo:P=%%!

    Remove spaces from a text string

    To delete space characters use the same syntax as above:

    SET _no_spaces=%_some_var: =%

–jeroen

Posted in Batch-Files, Development, Scripting, Software Development | Leave a Comment »

Want to use SmartPointers in Delphi? Use the Spring4D one: it is unit tested and optimised

Posted by jpluimers on 2021/01/06

A while ago, there was a nice discussion on smart pointers at [WayBack] Smart Pointers – Generics vrs non-generic implementastion – RTL and Delphi Object Pascal – Delphi-PRAXiS [en].

Conclusion from that:

  • many people think that reference counted interfaces are the same as Smart Pointers
    (basically Smart Pointers are the next level and of course they are based on reference counting)
  • there are a lot of Smart Pointer implementations, but few have a test suite, nor are optimised , nor easy to use
  • The combo Shared/IShared<T>/TShared<T> from Spring4D has all of the above advantages
  • in order to optmise Smart Pointer implementations, you really have to well know the effects of modern Delphi language constructs on the compiler in various target platforms

The discussion mentioned above includes both feature and speed comparisons.

I was a bit amazed that at CodeRage 2018, Marco Cantu introduced yet another smart pointer implementation: one worse than existing implementations, and one with only basic demonstration code, leaving out a test suite.

There have many posts on my blog about smart pointers (see the list below), but Spring4D smart pointer implementation has been around for such a long time that any well respected Delphi developer by now should use them. The source is at  Shared/IShared (search for {$REGION 'Shared smart pointer'} at the current repository).

This list below on my Smart Pointer related blog posts might not be fully complete, but at least mentions that by now you should be using Spring4D.

Some comments on the CodeRage 2018 demos

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Spring4D | Leave a Comment »

 
%d bloggers like this: