Barcode Scanning to Open PDF files Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
smali
Posts: 2
Joined: 03 Feb 2021, 10:36

Barcode Scanning to Open PDF files

03 Feb 2021, 13:24

I'm able to open PDF files by scanning the bar code, but wanted to add two more functions 1. A message if the file is not existed in the folder, and 2. Automatically print when the file is open in pdf to the default printer. Any help is appreciated.

Code: Select all

SetTitleMatchMode 2
Gui, +alwaysontop			;keeps the gui on top level
Gui, Add, Edit , w200 vpdfname, 
Gui, Add, Button, gopenpdf default , OPEN
Gui, show ,, scantopdf			;give name to gui for later reference

return

openpdf:
Gui,Submit,Nohide
If (pdfname = "" )
{
ControlFocus 
return
}
IfExist, P:\PRINT LINK\New prints data file\%pdfname%*.pdf
{
Loop, P:\PRINT LINK\New prints data file\%pdfname%*.pdf
          Run %A_LoopFileFullPath%
      WinActivate
}

IfExist, P:\PRINT LINK\New prints data file\%pdfname%.pdf
run, P:\PRINT LINK\New prints data file\%pdfname%.pdf

;IfNotExist, P:\PRINT LINK\New prints data file\%pdfname%.pdf
    ;MsgBox, The target file does not exist.

Guicontrol,,pdfname,			;makes the edit box blank
sleep 4000				;wait 4 seconds for pdf to load
WinActivate,scantopdf			;then reactivate the gui window
return 

Exit:
GuiClose:
ExitApp
Attachments
AMK Scanning.ahk
(899 Bytes) Downloaded 16 times
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Barcode Scanning to Open PDF files

03 Feb 2021, 16:48

Since you already have IfExist, you can add an Else MsgBox... at the end.

Command line to print varies by PDF handler program. You could check your PDF handler to see what command line it uses, and then just run that when needed.
smali
Posts: 2
Joined: 03 Feb 2021, 10:36

Re: Barcode Scanning to Open PDF files

04 Feb 2021, 08:54

Mike- thanks, I added Else MsgBox... as per your instructions but it is giving a message box every time I scan.

Code: Select all

SetTitleMatchMode 2
Gui, +alwaysontop			;keeps the gui on top level
Gui, Add, Edit , w200 vpdfname, 
Gui, Add, Button, gopenpdf default , OPEN
Gui, show ,, AMK_Prints			;give name to gui for later reference

return

openpdf:
Gui,Submit,Nohide
If (pdfname = "" )
{
ControlFocus 
return
}
IfExist, P:\PRINT LINK\New prints data file\%pdfname%*.pdf
{
Loop, P:\PRINT LINK\New prints data file\%pdfname%*.pdf
          Run %A_LoopFileFullPath%
      WinActivate
}

IfExist, P:\PRINT LINK\New prints data file\%pdfname%.pdf
run, P:\PRINT LINK\New prints data file\%pdfname%.pdf

Else
MsgBox OOh! No Engineering

Guicontrol,,pdfname,			;makes the edit box blank
sleep 4000				;wait 4 seconds for pdf to load
WinActivate,AMK_Prints			;then reactivate the gui window
return 

Exit:
GuiClose:
ExitApp 
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Barcode Scanning to Open PDF files  Topic is solved

04 Feb 2021, 09:10

Could try the newer function.

Code: Select all

pdf = P:\PRINT LINK\New prints data file\%pdfname%.pdf
If FileExist(pdf)
 Run, %pdf%
Else MsgBox OOh! No Engineering
Are you trying to loop through different files? Loop, Files can do that-- see doc for the right syntax. Files means the actual word, "Files".

If your file "does not exist", you can check the value of pdfname.
Fatima
Posts: 1
Joined: 22 Apr 2021, 12:52

Re: Barcode Scanning to Open PDF files

22 Apr 2021, 13:05

Hello,
I want to try also this program, but I don't know in which app or software you use it, could you please share more info about it

Thanks

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, Google [Bot], vysmaty and 243 guests