::Sane AcquireInto...current folder, autoset StartIndex::

Ask for help and post your question on how to use XnView Classic.

Moderators: helmut, XnTriq, xnview

Post Reply
User avatar
wOxxOm
Posts: 26
Joined: Sun Mar 11, 2007 1:29 pm
Contact:

::Sane AcquireInto...current folder, autoset StartIndex::

Post by wOxxOm »

invoke AcquireInto Dialog, set folder to current, analyze index and set it to skip existing files (or 1)
The script is currently launched by Alt-A from XnView window, AltShiftA - "select twainSource" - keyboard shortcuts can be easily changed in the code

well, I needed this one badly, here it is for everyone.

Code: Select all

GiveMeTrayIcon()
#ifWinActive,ahk_class XmainClass
!+A::sendMessage,273,31,0 ;ALT-SHIFT-A   select twain source
!A::AcquireInto()         ;ALT-A         acquire into CURRENT directory
#ifWinActive

GiveMeTrayIcon()
{
   regRead,xn,HKCR,XnView.jpg\DefaultIcon
   stringLeft,xn,xn,% instr(xn,".exe")+3
   splitPath,xn,,xndir
   ifExist,%xndir%\WebTemplate\Visuddhi - Simple\favicon.ico
      menu,tray,icon,%xndir%\WebTemplate\Visuddhi - Simple\favicon.ico
   else
      ifExist,%xn%
         menu,tray,icon,%xn%,0
}

AcquireInto() ;; invoke AcquireInto... set to CurrentFolder ;;
              ;; Start Index is set to ensure that files won't be overwritten
{
   ; get current dir from browser
   ControlGetText,curDir,Edit1

   ; invoke AcquireInto dialog, wait up to 2 secs until it's active
   postMessage,273,32,0
   winWaitActive,Batch scanning ahk_class #32770,,2

   ifWinActive,Batch scanning ahk_class #32770
   {
      ; set target path to current folder from browser
      ; and move caret to the end, to make the most meaningful part of the path visible
      ControlSetText,Edit1,%curDir%
      ControlSend,Edit1,{END}

      ; read sequence parameters from acquireInto dialog box
      ControlGetText,prefix,Edit2
      ControlGetText,seqStart,Edit3
      ControlGet,seqLen,Choice,,ComboBox1
      ControlGet,format,Choice,,ComboBox3
      stringLeft,format,format,% instr(format," ")-1
      format:="." format
      if (substr(curDir,0,1)<>"\")
         curDir:=CurDir "\"

      varSetCapacity(seqMask,seqLen,asc("?"))
      stringLeft,seqMask,seqMask,%seqLen%

      ; get files from currentdir to determine which one has the highest index
      ; with the current prefix and numeric sequence of given length
      loop,% curDir . prefix . seqMask . format
         files:=files . A_LoopFileName "`n"
      stringTrimRight,files,files,1
      sort,files

      ; get the last line - a file with the biggest index (after sort)
      i:=instr(files,"`n",true,0)
      StringTrimLeft,files,files,%i%

      ; extract just the numbers
      files:=substr(files,strlen(prefix)+1,seqLen)

      ; set dialog box "Start index" to the next value (or 1 if no files exist)
      if !(files)
         files:=0
      ControlSetText,Edit3,% files+1
   }
   return
}
P.S. to use: download and install AutoHotKey - THE hotkey control as it should be :-)
Put the code from above into XnViewScan.ahk - then just double click it, it will sit in the tray notification area.
It is possible to compile the code using ahk2exe( in AutoHotKey folder) - under 200kB ;-) and no extra files needed!
Post Reply