[APP] CutAndPlot AHKv2.0

Post your working scripts, libraries and tools
Posts: 272
Joined: 29 Jan 2014, 14:40

[APP] CutAndPlot AHKv2.0

08 Nov 2014, 10:03

CutAndPlot is written on AHKv2.0

About CutAndPlot:
In my practice many people used Cutting Plotters and of course most Plotters work with there own communication software (drivers and or communication translators) and all Plotters used PLT files (text file with .plt extension). Actually the communication software in most cases running like

Code: Select all

copy filename.plt com1
CutAndPlot used the same technics but automatically. (In next, if, versions I will catch the serial (COMxx) closer).

What CutAndPlot do:
There 3 known methods to activate some action with the data (passive) files:
1. Double click (file is associated to program).
2. Drag-and-Drop (file is dropped over program window).
3. Pooling (if file appear at given folder - program do it action).
CutAndPlot worked with all THREE methods together.

How CutAndPlot worked:
1. CutAndPlot - associated .plt to itself (using regystry).
2. Read/Create - CutAndPlot.ini (options and FileNameList FIFO usage http://ahkscript.org/boards/viewtopic.p ... 858#p29858).
3. Start to pooling given folder for .plt files
4. Void small semytransparent window (drop-box).

User can double click selected files to append FileNameList.
User can drag-and-drop selected files over CutAndPlot drop-box to append FileNameList.
User can copy/move/export .plt files at the pooling folder to append FileNameList.

CutAndPlot check any 5 seconds it there .plt files at pooling folder and is there any files at FileNameList and if there start copying to communication port (COMxx).
Before any file CutAndPlot void MsgBox for user confirmation to start cutting/plotting edited >>> and repeat until user select No.
Pooling - if file is set to FileNameList from pooling after ending cut/plot file can be DELETED or MOVED to Archive folder (MOVE BY DEFAULT).

CutAndPlot in work:
1. Waiting state - green UP arrow at system tray.
2. Working state - red DOWN arrow at system tray.
3. Pausing state - yellow UP arrow at system tray.

CutAndPlot controls:
Drop-box: can only be moved over the screen and hide/show (Win+Alt+Space). There no double clicks or right mouse button clicks.
Tray-icon: here is main CutAndPlot menu:
Open (Win+Alt+O) DEFAULT - open FileSelect interface (multy sellection possible).
Reject All (Win+Alt+R) - clear FileNameList and Reload.
Pause (Win+Alt+P) - pause.
Options (no short key) - open CutAndPlot.ini for editing in Notepad (depend of .ini association).
Exit (Win+Alt+F4) - terminate application.

CutAndPlot setup:
UnZip CutAndPlot.zip - will be created folder .\CutAndPlot and all needed files will be inside.
script source / libraries / AHKv2.0 / Gdip.dll / icons
run CutAndPlot.cmd
will be created CutAndPlot.lnk for further use (copy this link in Startup folder for example).
run the link to start CutAndPlot.

CutAndPlot will associate only itself for working with AHKv2.0 and only wilt .plt extensions (of course user can select/drag-and-drop files with any extention). Other .ahk files will KEEP association to other AHK or to nothing.

Known limitations:
This version of CutAndPlot is very first version - coming from laboratory tests and never was in action at the free world.
Interrupting CutAndPlot DO NOT INTERRUPT cut/plot action (due to plotter buffer) but possible partial transmission of current file.
AVG antivirus prevent AHKv2.0 to work (suppress hotkey action).
(1.31 MiB) Downloaded 99 times
Last edited by _3D_ on 11 Nov 2014, 19:22, edited 6 times in total.
AHKv2.0 alpha forever.
Posts: 272
Joined: 29 Jan 2014, 14:40

[APP] CutAndPlot AHKv2.0 [Source]

09 Nov 2014, 11:10

CutAndPlot Source code:

Code: Select all

#SingleInstance Force
;Copyright © D.Donchev
  RegWrite("REG_SZ",hkcu capL "\DefaultIcon",,A_ScriptDir "\Visualpharm-2.ico")
  RegWrite("REG_SZ",hkcu capL "\Shell\Open\Command",,'"' A_ScriptDir '\AutoHotkey.exe" "' A_ScriptFullPath '" "`%1"')
  RegWrite("REG_SZ",hkcu ".PLT",,capL)

  iniF:= capL . ".ini"
  cprt:= "© D.Donchev"
  ttle:= capL . " v1.0 " . cprt
  if (comp:=IniRead(iniF, "Options", "COMport", "")) == "", IniWrite(comp:="COM1",                            iniF, "Options", "COMport")
  if (init:=IniRead(iniF, "Options", "COMinit", "")) == "", IniWrite(init:="BAUD=9600 DATA=8 PARITY=N STOP=1",iniF, "Options", "COMinit")
  if (delF:=IniRead(iniF, "Options", "fileDEL", "")) == "", IniWrite(delF:="0",                               iniF, "Options", "fileDEL")
  if (extn:=IniRead(iniF, "Options", "fileEXT", "")) == "", IniWrite(extn:="PLT",                             iniF, "Options", "fileEXT")
  if (pool:=IniRead(iniF, "Folders", "Pooling", "")) == "", IniWrite(pool:=A_ScriptDir,                       iniF, "Folders", "Pooling")
  if (arch:=IniRead(iniF, "Folders", "Archive", "")) == "", IniWrite(arch:=A_ScriptDir "\Archive",            iniF, "Folders", "Archive")
  if !DirExist(arch), DirCreate(arch)
  FileCreateShortcut(A_ScriptDir "\AutoHotkey.exe"
                    ,A_ScriptDir "\CutAndPlot.lnk"
                    ,'"' A_ScriptFullPath '"'
                    ,A_ScriptDir "\Visualpharm-1.ico")
  if A_Args[1] == "INIT", ExitApp
  pToken:= Gdip_Startup()
  Gui, -Caption +E0x80000 +LastFound +ToolWindow +AlwaysOnTop +OwnDialogs 
  Gui, Show, NA
  hwnd1:= WinExist()
  hbm  := CreateDIBSection(mW:=83, mH:=43)
  hdc  := CreateCompatibleDC()
  obm  := SelectObject(hdc, hbm)
  G    := Gdip_GraphicsFromHDC(hdc)
  Gdip_SetSmoothingMode(G, 4)
  gRect(G, 0, 0, mW, mH, 0x3F8F736B) ;background
  gRect(G, 0, 0, 10, 10, 0xFFFF3500) ;red dot
  gRect(G, mW-5, 0, 5, 5, 0xFFFF3500)
  gRect(G, mW-5, mH- 5, 5, 5, 0xFFFF3500)
  Gdip_TextToGraphics(G, capL, "X1 Y0  cFFFFFC00 R4 S10 Bold Italic", "Verdana", mW, 12)
  Gdip_TextToGraphics(G, cprt, "X1 Y10 cFFFFFC00 R4 S8  Bold Italic Right", "Verdana", mW, 12)
  Gdip_TextToGraphics(G, comp, "X1 Y26 cFFFFFC00 R4 S8  Bold Italic", "Verdana", mW, 12)
  t:=StrSplit(init, array(" ", "="))
  Gdip_TextToGraphics(G, t[2] " " t[4] t[6] t[8], "X1 Y33 cFFFFFC00 R4 S8 Bold Italic Right", "Verdana", mW, 12)
  UpdateLayeredWindow(hwnd1, hdc, 1040, 120, mW, mH)
  OnMessage(0x200, "WM_MOUSEMOVE" )
  Menu, tray, Icon, Visualpharm-1.ico
  Menu, Tray, NoStandard
  Menu, Tray, add, Open`tWin+Alt+O, #!O
  Menu, Tray, Default, Open`tWin+Alt+O
  Menu, Tray, add, Reject ALL`tWin+Alt+R, #!R
  Menu, Tray, add, Pause`tWin+Alt+P, #!P
  Menu, Tray, add
  Menu, Tray, add, Options, LB_OPTIONS
  Menu, Tray, add
  Menu, Tray, add, Exit`tWin+Alt+F4, #!F4
  Menu, Tray, Tip, %ttle%
  Loop A_Args.Length
    IniWrite("C&P" , iniF, capL, A_Args[A_Index])
  SetTimer, LB_POOL, Off
  Loop, Files, %pool%\*.%extn%  
    IniWrite("C&P=P", iniF, capL, A_LoopFileFullPath)
  Loop, read, %inif%
    if InStr(A_LoopReadLine, "C&P")
    { menu, tray, Icon, Visualpharm-2.ico
      file:= StrSplit(A_LoopReadLine, "=")
      while (MsgBox(4,ttle, capL " " (A_Index > 1? "for " A_Index " time": "") "`n" file[1]), A_MsgBoxResult) == "Yes"
      { if RunWait("cmd /c MODE " comp " " init,,"Hide")
        { goSUB, #!P
          MsgBox(comp " NOT INIT")
        RunWait('cmd /c copy "' file[1] '" ' comp,,"Hide")
      if file[3] == "P", if delF == "1", FileDelete(file[1])
                         else              FileMove(file[1], arch, 1)
      IniDelete(iniF, capL, file[1])
      menu, tray, Icon, Visualpharm-1.ico
  SetTimer, LB_POOL, 5000

  if visible:=!visible, Gui, Hide
  else                  Gui, Show

  if ahkPause:=!ahkPause
  { SetTimer, LB_POOL, Off
    menu, tray, Icon, Dakirby309-3.ico
  } else
  { SetTimer, LB_POOL, On
    menu, tray, Icon, Visualpharm-1.ico

if (file:= FileSelect("M",pool,ttle,"*.PLT"))
{ file:= StrSplit(file, "`n")
  while file[A_Index+1]
    IniWrite("C&P" , iniF, capL, file[1] "\" file[A_Index+1])
} return

  IniDelete(iniF, capL)



  Loop, parse, %A_GuiEvent%, `n
    IniWrite("C&P" , iniF, capL, A_LoopField)

WM_MOUSEMOVE(wp, y, ms, hd)
{ PostMessage, 0xA1, 2
gRect(pGr, x, y, w, h, c)
{ Gdip_FillRectangle(pGr, pB:=Gdip_BrushCreateSolid(c), x, y, w, h)
  return c
No comments but anything so ordinary.
Last edited by _3D_ on 15 Jan 2015, 18:52, edited 1 time in total.
AHKv2.0 alpha forever.
Posts: 272
Joined: 29 Jan 2014, 14:40

Re: [APP] CutAndPlot AHKv2.0

11 Nov 2014, 19:32

I made some changes in source:
1. Avoid FileMove mistery.
2. Reduce code.
3. Better loop mechanism for current file.
CutAndPlot.zip first post updated.
CutAndPlot source second post updated.
AHKv2.0 alpha forever.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: jeongrak2, robodesign and 108 guests