Need add-on features
Need add-on features
Hi,
I'm new joiner here. Been research on AHK for my company requirement. Idea from https://www.autohotkey.com/board/topic/102329-scan-barcodeopen-file/. But i would like to add-on if PDF and JPG in same filename, can a GUI prompt to let me select PDF or JPG to open? Instead of both open automatically.
I'm new joiner here. Been research on AHK for my company requirement. Idea from https://www.autohotkey.com/board/topic/102329-scan-barcodeopen-file/. But i would like to add-on if PDF and JPG in same filename, can a GUI prompt to let me select PDF or JPG to open? Instead of both open automatically.
Re: Need add-on features
Sorry, i am new to program the script. Can you show me the below script where should i input a script to make it prompt once is detected same filename in PDF and JPG, the GUI will prompt to let me select whether to open up PDF or JPG?
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, C:\Barcode Images\%pdfname%*.pdf
{
Loop, C:\Barcode Images\%pdfname%*.pdf
Run %A_LoopFileFullPath%
WinActivate
}
IfExist, C:\Barcode Images\%pdfname%.jpg ;location and filename of pic
run, C:\Barcode Images\%pdfname%.jpg ;location and filename of pic
IfExist, C:\Barcode Images\%pdfname%.pdf
run, C:\Barcode Images\%pdfname%.pdf
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
Re: Need add-on features
Code: Select all
dir := StrReplace(A_WinDir, "Windows", "Barcode Images")
Gui, Pick:New, -SysMenu +Hwndpick
Gui, Font, s10
Gui, Add, Radio , vchoice , PDF
Gui, Add, Radio , , JPG
Gui, Add, Button, x130 ym+8 Default, OK
Gui, Name:New
Gui, +AlwaysOnTop
Gui, Font, s10
Gui, Add, Edit , w200 vpdfname gCheck
Gui, Add, Button, Default, Open
Gosub, Check
Gosub, F3
F3::Gui, Name:Show, w250, Scan to PDF
Check:
Gui, Name:Submit, NoHide
GuiControl, % pdfname > "" ? "Enable" : "Disable", Open
Return
NameButtonOpen:
Gui, Name:Submit
Loop, %dir%\%pdfname%*.pdf
{ SplitPath, A_LoopFilePath,,,, fnBare
If FileExist(jpg := dir "\" fnBare ".jpg") {
Gui, Pick:Show, w350, %fnBare%
SoundBeep, 1500
WinWaitClose, ahk_id %pick%
} Else choice := 1
Run, % choice = 1 ? A_LoopFilePath : jpg
}
Return
PickButtonOK:
Gui, Pick:Submit
Return
Re: Need add-on features
Hi Mikey,
Thanks for your assist, your script is working perfectly, but after i submit the pdf or jpg open, then i close it, the GUI "Scan to PDF" is disappear, only if i reload the script then its call out again. Can it reload the GUI again after the PDF or JPG shown?
Thanks for your assist, your script is working perfectly, but after i submit the pdf or jpg open, then i close it, the GUI "Scan to PDF" is disappear, only if i reload the script then its call out again. Can it reload the GUI again after the PDF or JPG shown?
Re: Need add-on features
Three ways to show your GUI:
1. Add the NoHide option to your Gui, Submit (keeps the GUI visible).
2. Press the F3 key manually (displays the GUI).
3. Add Gosub, F3 to the script, wherever you want the GUI to be shown.
1. Add the NoHide option to your Gui, Submit (keeps the GUI visible).
2. Press the F3 key manually (displays the GUI).
3. Add Gosub, F3 to the script, wherever you want the GUI to be shown.
Re: Need add-on features
Hi Mikey,
It's worked great. But I still need 2 extra steps for my script, can you assist me on this?
Previous script:
Based on this above, i still need 2 more feature to make it perfect:
1) If the folder doesn't have pdf file, just a jpg alone, can it set to open straight as well. In current script, the jpg only able to open if the pdf is exist, then i can choose jpg to open it. If without PDF, the jpg won't open.
2) example: my current directory path is (Z:\drawings), and i have multiple folders in (Z:\drawings), e.g: Folder A, Folder B and Folder C. For this script, if i input a filename like (drawing123), can i let STReplace to search all my sub-folder (Folder A,B,C) which included this file (drawing123)? And, if 2 of the folder like (folder A and B) also found the same filename (drawing123) no matter is pdf or jpg, can it prompt a GUI of those files and show the directory path right besides it's filename?
Please correct the above script that you sent me that day with my requirement, appreciated.
It's worked great. But I still need 2 extra steps for my script, can you assist me on this?
Previous script:
Code: Select all
dir := StrReplace(A_WinDir, "Windows", "Barcode Images")
Gui, Pick:New, -SysMenu +Hwndpick
Gui, Font, s10
Gui, Add, Radio , vchoice , PDF
Gui, Add, Radio , , JPG
Gui, Add, Button, x130 ym+8 Default, OK
Gui, Name:New
Gui, +AlwaysOnTop
Gui, Font, s10
Gui, Add, Edit , w200 vpdfname gCheck
Gui, Add, Button, Default, Open
Gosub, Check
Gosub, F3
F3::Gui, Name:Show, w250, Scan to PDF
Check:
Gui, Name:Submit, NoHide
GuiControl, % pdfname > "" ? "Enable" : "Disable", Open
Return
NameButtonOpen:
Gui, Name:Submit
Loop, %dir%\%pdfname%*.pdf
{ SplitPath, A_LoopFilePath,,,, fnBare
If FileExist(jpg := dir "\" fnBare ".jpg") {
Gui, Pick:Show, w350, %fnBare%
SoundBeep, 1500
WinWaitClose, ahk_id %pick%
} Else choice := 1
Run, % choice = 1 ? A_LoopFilePath : jpg
}
Return
PickButtonOK:
Gui, Pick:Submit
Return
1) If the folder doesn't have pdf file, just a jpg alone, can it set to open straight as well. In current script, the jpg only able to open if the pdf is exist, then i can choose jpg to open it. If without PDF, the jpg won't open.
2) example: my current directory path is (Z:\drawings), and i have multiple folders in (Z:\drawings), e.g: Folder A, Folder B and Folder C. For this script, if i input a filename like (drawing123), can i let STReplace to search all my sub-folder (Folder A,B,C) which included this file (drawing123)? And, if 2 of the folder like (folder A and B) also found the same filename (drawing123) no matter is pdf or jpg, can it prompt a GUI of those files and show the directory path right besides it's filename?
Please correct the above script that you sent me that day with my requirement, appreciated.
Re: Need add-on features
I leave the newest change to you. You have the tools here. Loop, Files can also identify files recursively. Example
I noticed that my earlier script did not use Loop, Files, but I would recommend that. Best wishes.
I noticed that my earlier script did not use Loop, Files, but I would recommend that. Best wishes.
Re: Need add-on features
Hi Mikey,
File, loop is really new to me. i have read all the example and always receive error. Can you example it, so i can learn from it. Thanks. Sorry to trouble again. And, how i can make the GUI prompt if the file is exist but difference directory, so i can easily choose from the GUI and based on the correct path. Thanks.
File, loop is really new to me. i have read all the example and always receive error. Can you example it, so i can learn from it. Thanks. Sorry to trouble again. And, how i can make the GUI prompt if the file is exist but difference directory, so i can easily choose from the GUI and based on the correct path. Thanks.
Re: Need add-on features
Sorry I cannot write the new script for you. It is more involved than the original. Nonetheless, this thread contains examples of both GUI and Loop, Files. You are welcome to post any revisions, so that readers can examine them and provide you with feedback. My suggestion is to write a detailed, plain-language description of every step. This will be more detailed than the description that you have provided, because there will be comparisons of file names, decisions about multiple files in subdirectories, etc. You would then go line by line, converting your description into a new script.