Hey people!
I using a software that allows me to scan documents and then link the resulting file to an "order" (let's say)
The software also allows to choose a file to link to the order via an entry process.
This is usefull for the documents that i'm receiving by mail.
I would like to avoid this manual process and make it automatically.
My first idea was to create a little server-script (timer) that scrutate a folder for ever :
- If no file in the folder, then loop ↖
- If a file is in the folder, then wait for a certain window to be active AND for a certain key to be pressed
- If so, produce the required actions automatically and loop ↖
Then i got a second idea :
- If a certain window is active, then associate a gui that allows me to click and drop the document that i want to link to the "order"
then produce the required actions automatically
I hope that the explaination is not too unclear and that you get the idea.
My question is, how do i get a file URL ? specially by dragging and dropping a file on a Gui ?
Thank you for reading me, hoping that you will have an interest in this question, and maybe an answer to offer
LeSeb
Getting local file URL by drag and drop
Getting local file URL by drag and drop
Last edited by LeSeb on 01 Nov 2017, 14:42, edited 1 time in total.
- Delta Pythagorean
- Posts: 628
- Joined: 13 Feb 2017, 13:44
- Location: Somewhere in the US
- Contact:
Re: Getting file URL by drag and drop
You can, and keep in mind it'll hurt your brain, make a Gui using ActiveX's Internet explorer control. This control can handle not only Files, but Links as well. The sad part is, you have to be a bit creative with classes and what not. I can give you my work on it (That works great but breaks after getting the same file) and I may upload it to the Scripts and Functions subforum
[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat
Re: Getting file URL by drag and drop
An example , copy url (rightclick) and downloadMy question is, how do i get a file URL ?
Code: Select all
; Example : open https://autohotkey.com/boards/ copy url from flags below (china/germany/spain/france .png ) and download
; like https://autohotkey.com/boards/images/flags/china.png
#NoEnv
setworkingdir,%a_scriptdir%
Filename1=TEST_CopyURL
Gui,2: Color, ControlColor,Black ;- background from edit
Gui,2: Color, Black ;- Gui color
Gui,2:show,x0 y0 w870 h110,%filename1%
Gui,2:Font,cGray ,Fixedsys
Gui,2:add,edit ,x10 y5 h25 w840 vED1 left readonly
Gui,2:add,edit ,x10 y40 h25 w840 vED2 left readonly
Gui,2:add,button,x10 y75 h25 w100 vDnl1 gDownload1,Download
GuiControl,2:disable,dnl1
return
2Guiclose:
exitapp
Download1:
Gui,2:submit,nohide
if ed1<>
{
urldownloadtofile,%ed1%,%a_scriptdir%\%name%
GuiControl,2:,ED2,Downloaded = %name%
}
return
;------------------
OnClipboardChange:
{
If (A_EventInfo=1)
{
GuiControl,2:disable,dnl1
GuiControl,2:,ED1,
GuiControl,2:,ED2,
url = %Clipboard%
if (instr(url, "https://autohotkey.com"))
{
i=0
Loop,parse,url, `n, `r
{
x= %a_loopfield%
if x=
continue
if x contains flags
{
SplitPath, x, name, dir, ext, name_no_ext, drive
if (ext="png")
{
url_ok=%x%
Gui,2:show
GuiControl,2:,ED1,%url_ok%
GuiControl,2:Enable,dnl1
break
}
}
}
}
}
}
url=
clipboard=
return
;============================ END script ====================
- Delta Pythagorean
- Posts: 628
- Joined: 13 Feb 2017, 13:44
- Location: Somewhere in the US
- Contact:
Re: Getting file URL by drag and drop
Code: Select all
#SingleInstance, Force
OnExit, OnExit
MYAPP_PROTOCOL := "App" ; This is used for later in the script.
HTML_page =
(LTRIM Join
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: sans-serif;
background-color: #dde4ec;
}
p {
font-size: 16px;
background-color: #efefef;
border: solid 1px #666;
padding: 4px;
}
</style>
</head>
<body>
<p>Drag and Drop Files or Links onto me!</p>
</body>
</html>
)
Gui Add, ActiveX, x0 y0 w640 h480 vWB, Shell.Explorer
WB.Silent := True ; Surpress JS Error boxes
Display(WB, HTML_page)
ComObjConnect(WB, WB_events) ; Connect WB's events to the WB_events class object.
Gui Show, w640 h480
Return
GuiClose:
ExitApp
OnExit:
FileDelete, %A_Temp%\*.DELETEME.html ;clean tmp file
ExitApp
Class WB_events {
;for more events and other, see http://msdn.microsoft.com/en-us/library/aa752085
NavigateComplete2(wb) {
wb.Stop() ;blocked all navigation, we want our own stuff happening
}
DownloadComplete(wb, NewURL) {
wb.Stop() ;blocked all navigation, we want our own stuff happening
}
DocumentComplete(wb, NewURL) {
wb.Stop() ;blocked all navigation, we want our own stuff happening
}
BeforeNavigate2(wb, NewURL) {
wb.Stop() ; blocked all navigation, we want our own stuff happening
;parse the url
Global MYAPP_PROTOCOL
If (InStr(NewURL, MYAPP_PROTOCOL "://") == 1) {
What := SubStr(NewURL, Strlen(MYAPP_PROTOCOL) + 4)
MsgBox, % NewURL
}
}
}
Display(WB, html_str) {
Count := 0
While (FileExist(f := A_Temp "\" A_TickCount A_NowUTC "-tmp" Count ".DELETEME.html"))
Count += 1
FileAppend, % html_str, % f
WB.Navigate("file://" f)
}
I've used this kind of thing before but it was a while ago. Hope this works for ya.
[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat
Re: Getting file URL by drag and drop
Hey and thank you for answering!!
Are you talking about local file ? (i badly used the word URL...but i'm talking about local file)
I will have a serious look at those scripts tomorrow at work. Here i'm on Linux and it has no autohotkey possibilities!
I will be back with progress, i'm sure!
Are you talking about local file ? (i badly used the word URL...but i'm talking about local file)
I will have a serious look at those scripts tomorrow at work. Here i'm on Linux and it has no autohotkey possibilities!
I will be back with progress, i'm sure!
Re: Getting local file URL by drag and drop
Hello,
I finally used the GuiDropFiles label that i previously didn't even know!
Now i have to "stick" this gui to the right place on a special window so that it always be here when i need it
I finally used the GuiDropFiles label that i previously didn't even know!
Code: Select all
#NoEnv
#Persistent
Gui Show, w640 h480
Return
GuiDropFiles(GuiHwnd, FileArray, CtrlHwnd, X, Y) {
for i, file in FileArray
{
FileCopy, %file%, \\the\folder\you\need
}
}
Who is online
Users browsing this forum: a_riva and 196 guests