#Persistent
#SingleInstance, force
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
;CREDITS TO /u/trashdigger
Menu, Tray, NoStandard
Menu, Tray, Add, Printed Folder, PrintedF
Menu, Tray, Icon, Printed Folder, %A_ScriptDir%\printed.ico
Menu, Tray, Icon, %A_ScriptDir%\printer.ico
Menu, Tray, Add, Print Folder, PrintF
Menu, Tray, Icon, Print Folder, %A_ScriptDir%\print.ico
Menu, Tray, Add, WhatsApp Folder, WhatsappF
Menu, Tray, Icon, WhatsApp Folder, %A_ScriptDir%\whatsapp.ico
Menu, Tray, Add
Menu, Tray, Add, Printer Settings, PrinterS
Menu, Tray, Icon, Printer Settings, %A_ScriptDir%\printer_settings.ico
Menu, Tray, Add, Toggle Pause, tpause
Menu, Tray, Icon, Toggle Pause, %A_ScriptDir%\toggle_pause.ico
Menu, Tray, Add
Menu, Tray, Add, Edit, Edit
Menu, Tray, Add, Exit, Exit
Menu, Tray, Icon, Exit, %A_ScriptDir%\exit.ico
SetTimer, WatchMove, 5000
SetTimer, WatchPrint, 200
PleasantNotify("AUTO PRINTER", "Will be Watching For New Files", , , "b r", "2")
Return
PrintF:
Run, D:\Print
return
PrintedF:
Run, D:\Printed
return
WhatsappF:
Run, C:\Users\%A_UserName%\Google Drive\WhatsApp_Pics
return
PrinterS:
Run, control printers
return
tpause:
Pause, toggle
return
Edit:
Edit
return
Exit:
ExitApp
return
WatchMove:
IfExist C:\Users\%A_UserName%\Google Drive\WhatsApp_Pics\*.jpg
{
Loop, C:\Users\%A_UserName%\Google Drive\WhatsApp_Pics\*.jpg
{
FileLongName = %A_LoopFileLongPath%
FileName = %A_LoopFileName%
PleasantNotify("AUTO PRINTER - Mover", "Moving Files", , , "b r", "3")
FileMove, %A_LoopFileLongPath%, D:\Print,1
}
}
Return
WatchPrint:
IfExist D:\Print\*.jpg ; will only proceed if there is any picture inside folder.
{
FileCount = 0
Loop, D:\Print\*.jpg ;loops the folder
{
FileCount +=1
FileLongName%FileCount% = %A_LoopFileLongPath%
FileName%FileCount% = %A_LoopFileName%
}
PleasantNotify("AUTO Printer", "Waiting 11 Seconds to see if there are more files to print", , , "b r", "11")
pn_mod_msg("Waiting 10 Seconds to see if there are more files to print")
Sleep, 1000
pn_mod_msg("Waiting 9 Seconds to see if there are more files to print")
Sleep, 1000
pn_mod_msg("Waiting 8 Seconds to see if there are more files to print")
Sleep, 1000
pn_mod_msg("Waiting 7 Seconds to see if there are more files to print")
Sleep, 1000
pn_mod_msg("Waiting 6 Seconds to see if there are more files to print")
Sleep, 1000
pn_mod_msg("Waiting 5 Seconds to see if there are more files to print")
pn_mod_msg("Waiting 4 Seconds to see if there are more files to print")
Sleep, 1000
pn_mod_msg("Waiting 3 Seconds to see if there are more files to print")
Sleep, 1000
pn_mod_msg("Waiting 2 Seconds to see if there are more files to print")
Sleep, 1000
pn_mod_msg("Waiting 1 Seconds to see if there are more files to print")
Sleep, 1000
FileCount2 = 0
Loop, D:\Print\*.jpg ;seconds loop to check after 10 seconds to see if there are new pictures.
{
FileCount2 +=1
}
} else {
return
}
If FileCount = %FileCount2% ;this is only if the 1st loop count = the 2nd loop, else it will recheck everything again and wait 10 seconds again.
{
SetTimer, WatchMove, Off ;turn off moving while printing commences.
If FileCount = 1
{
FileTrueName = %FileLongName1%
FileName = %FileName1%
PleasantNotify("AUTO Printer", "Printing Single File:" FileName,,, "b r", "3")
;~ TrayTip, AUTO Printer, Printing Single File: %FileName%, 10, 17
RunWait, "C:\Program Files\IrfanView\i_view64.exe" "%FileTrueName%" /print,,hide ; /c = close /k = kiosk mode to show errors
Sleep, 3000
FileMove, %FileTrueName%, D:\Printed,1
SetTimer, WatchMove, On ;turn watchmove back on after printing is dealt with.
return
} else {
Loop %FileCount%
{
FileTrueName := FileLongName%A_Index%
FileName := FileName%A_Index%
If A_Index = 1
{
TipCount = 0
PrintList := "C:\Program Files\IrfanView\i_view64.exe /print /panorama=(1," Chr(34) FileTrueName Chr(34)
PrintListTip%TipCount% := FileName
} else {
If (OddOrEven(A_Index)) = "Odd"
{
If A_Index = % FileCount
{
TipCount += 1
PrintList := PrintList Chr(34) "`nC:\Program Files\IrfanView\i_view64.exe " Chr(34) FileTrueName Chr(34) " /print"
PrintListTip%TipCount% = %FileName%
break
}
TipCount += 1
PrintList := PrintList "`nC:\Program Files\IrfanView\i_view64.exe /print /panorama=(1," Chr(34) FileTrueName Chr(34)
PrintListTip%TipCount% = %FileName%
} else {
PrintList := PrintList "," Chr(34) FileTrueName Chr(34) ")"
PrintListTip := PrintListTip%TipCount%
PrintListTip%TipCount% = %PrintListTip% and %FileName%
}
}
}
}
;TrayTip, AUTO Printer, Printing Panorama of: %PrintListTip%..., 10, 17
TipCount = 0
Loop, parse, PrintList, `n
{
ToolTipVar := PrintListTip%TipCount%
PleasantNotify("AUTO Printer", "Printing:" ToolTipVar,,, "b r", "3")
;~ TrayTip, AUTO Printer, Printing: %ToolTipVar%..., 10, 17
RunWait, %A_LoopField%,,hide
sleep 2000
TipCount += 1
}
FileMove, D:\Print\*.jpg, D:\Printed,1
SetTimer, WatchMove, On ;turn watchmove back on after printing is dealt with.
Return
} else {
goto WatchPrint
}
return
OddOrEven(num)
{
return ((Num & 1) != 0) ? "Odd" : "Even"
}
PleasantNotify(title, message, pnW=220, pnH=85, position="b r", time=10) {
global pn_title, pn_msg, PN_hwnd, w, h
Notify_Destroy()
Gui, Notify: +AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
PN_hwnd := WinExist()
WinSet, ExStyle, +0x20
WinSet, Transparent, 0
Gui, Notify: Color, 0xF2F2F0
Gui, Notify: Font, c0x07D82F s10 wBold, Segoe UI
Gui, Notify: Add, Text, % " x" 20 " y" 12 " w" pnW-10 " vpn_title", % title
Gui, Notify: Font, cBlack s9 wRegular
Gui, Notify: Add, Text, % " x" 20 " y" 35 " w" pnW-10 " h" pnH-35 " vpn_msg", % message ;-56
RealW := pnW + 40
RealH := pnH + 20
Gui, Notify: Show, W%RealW% H%RealH% NoActivate
WinMove(PN_hwnd, position)
if A_ScreenDPI = 96
WinSet, Region,0-0 w%pnW% h%pnH% R40-40,%A_ScriptName%
/* For Screen text size 125%
if A_ScreenDPI = 120
WinSet, Region, 0-0 w800 h230 R40-40, %A_ScriptName%
*/
winfade("ahk_id " PN_hwnd,210,5)
if (time <> "P")
{
Closetick := time*1000
SetTimer, ByeNotify, % Closetick
}
}
Notify_Destroy() {
global PN_hwnd
ByeNotify:
SetTimer, ByeNotify, Off
winfade("ahk_id " PN_hwnd,0,5)
Gui, Notify: Destroy
return
}
pn_mod_title(title) {
global pn_title
GuiControl, Notify: Text,pn_title, % title
}
pn_mod_msg(message) {
global pn_msg
GuiControl, Notify: Text,pn_msg, % message
}
WinMove(hwnd,position) {
SysGet, Mon, MonitorWorkArea
WinGetPos,ix,iy,w,h, ahk_id %hwnd%
x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ? (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
y := InStr(position,"t") ? MonTop : InStr(position,"vc") ? (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
WinMove, ahk_id %hwnd%,,x,y
}
winfade(w:="",t:=128,i:=1,d:=10) {
w:=(w="")?("ahk_id " WinActive("A")):w
t:=(t>255)?255:(t<0)?0:t
WinGet,s,Transparent,%w%
s:=(s="")?255:s ;prevent trans unset bug
WinSet,Transparent,%s%,%w%
i:=(s<t)?abs(i):-1*abs(i)
while(k:=(i<0)?(s>t):(s<t)&&WinExist(w)) {
WinGet,s,Transparent,%w%
s+=i
WinSet,Transparent,%s%,%w%
sleep %d%
}
}