drag and drop lost with program ran by autohotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
thegooddoctor
Posts: 8
Joined: 16 Apr 2018, 22:47

drag and drop lost with program ran by autohotkey

16 Apr 2018, 23:12

I have a simple script that remaps some of the Window's built in hotkeys.

#e::Run "C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE"
#p::Run "C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE"
#f::Run "C:\Program Files\AutoHotkey\hotkeys\WFS.exe"

but one thing that I have noticed is when I call up these programs via the hotkeys (or use something like PowerPro to call up the program) I can't drag and drop a file into the program.
For example, normally I could drag a .jpg from my desktop into Word and have the .jpg imported, but when the program is called by autohotkey I can't do it and the cursor changes into the slashed circle.

I tried 32/64/administrator and nothing seems to work.

Any ideas?


(The WFS.exe file is an AutoIt executable to run the fax/scanner program - strangely I can't run it from AutoHotKey)
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: drag and drop lost with program ran by autohotkey

16 Apr 2018, 23:50

- If you provide the source code for the AutoIt script/exe, we should be able to achieve the same in AutoHotkey.

- You could open the shortcut files (lnk files) instead of the exe files:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs
C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

- You could use the complete command-line strings with parameters (not just the exe paths). There are tips to show the command-line string in Task Manager, and to retrieve it programmatically for the active window, here:
jeeswg's Explorer tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=31755

- Another possibility is to run the AutoHotkey script as admin.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
thegooddoctor
Posts: 8
Joined: 16 Apr 2018, 22:47

Re: drag and drop lost with program ran by autohotkey

17 Apr 2018, 19:38

jeeswg wrote:- If you provide the source code for the AutoIt script/exe, we should be able to achieve the same in AutoHotkey.
yup ... i provided the source already

#e::Run "C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE"
#p::Run "C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE"
#f::Run "C:\Program Files\AutoHotkey\hotkeys\WFS.exe"


I'll make it even easier --- just use this script

Code: Select all

#w::Run "C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE"
and you'll find that you cannot drop a .jpg image to import into WORD (MS Office 2010)
jeeswg wrote: - You could open the shortcut files (lnk files) instead of the exe files:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs
C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
tried that already ... does not work
jeeswg wrote: - You could use the complete command-line strings with parameters (not just the exe paths). There are tips to show the command-line string in Task Manager, and to retrieve it programmatically for the active window, here:
jeeswg's Explorer tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=31755
well that is not the easiest way ... why not just use Process Explorer by Mark Russinovinch (Sysinternals)
anyways ... that does not work either
jeeswg wrote: - Another possibility is to run the AutoHotkey script as admin.
yup ... i tried that already as stated "I tried 32/64/administrator and nothing seems to work."
if this does not make sense to you then i'll break it down
compiled the script as a 32bit application - does not work
compiled the script as a 64bit application - does not work
tried running the 32bit and 64bit applications as the administrator - does not work
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: drag and drop lost with program ran by autohotkey

17 Apr 2018, 21:20

- You could try ShellRun:
AutoHotkey-Release/ShellRun.ahk at master · Lexikos/AutoHotkey-Release · GitHub
https://github.com/Lexikos/AutoHotkey-R ... ellRun.ahk
- Out of interest, if you manually double-click a Start menu shortcut in an Explorer folder window, that should open it fine. If you get AutoHotkey to double-click that shortcut, does it work?
- I meant to provide the AutoIt source code for WFS.exe.
- It might be worth mentioning the Windows OS.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
thegooddoctor
Posts: 8
Joined: 16 Apr 2018, 22:47

Re: drag and drop lost with program ran by autohotkey

21 Apr 2018, 09:51

double clicking the start menu shortcut works fine
having an external program send the mouse commands to emulate a double click on the shortcut works fine
it just seems if I use autohotkeys (or PowerPro) drag and drop is broken

I will look into shellrun.ahk; the support site (that explains the method) is down and I want to understand proper implementation the theory behind the script

Windows 7 Pro x64
thegooddoctor
Posts: 8
Joined: 16 Apr 2018, 22:47

Re: drag and drop lost with program ran by autohotkey

21 Apr 2018, 10:06

Wow ... that was the problem
Had to execute those executables via shellexecute

thanks!

(hmmmm ... seems other program shortcuts I'm using can benefit from being called via shellexecute as well)
thegooddoctor
Posts: 8
Joined: 16 Apr 2018, 22:47

Re: drag and drop lost with program ran by autohotkey

21 Apr 2018, 11:51

now another problem
the script works when I double click on it
but fails to work if I have it in my startup folder OR as a scheduled task (drag and drop is lost)
it seems that I must physically call this program up myself in order for it to work properly

i'm not using the ShellRun.ahk as the site that explains the script is still down

what I did was created some autoit executables that include the function shellexecute and then have autohotkeys call the autoit executables

it would be nice to see native support for shellexecute within autohotkey
thegooddoctor
Posts: 8
Joined: 16 Apr 2018, 22:47

Re: drag and drop lost with program ran by autohotkey

21 Apr 2018, 11:54

autoit also does apparently support shellexecute in the manner that any shortcuts are called up via shellexecute
(https://autohotkey.com/board/topic/7764 ... arameters/)

and I can verify that this is true

but if the initial execution of the autohotkey script/executable is via taskmanager OR by the startup folder, the drag and drop function is lost

#w::Run "C:\Program Files\AutoHotkey\hotkeys\WINWORD.lnk"
(works if I double click on it, but having this script as a scheduled task OR in the startup folder again loses the drag and drop function)

edit: ok ... it does work this way (via the startup folder); it seems there is the odd time on a fresh startup that the drag and drop isn't there but if press the hotkey again it works
just the odd time that it doesn't
(for some reason)

thanks for your help!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], SimmoF, uchihito and 215 guests