Page 1 of 1

AutoHotKey script HELP please!!!

Posted: 24 Mar 2018, 08:38
by jaggsharry
Hello AutoHotKey Experts,

I'm a newbie to autohotkey and will really appreciate any help to accomplish this requirement. Here it goes, I'm looking for a AutoHotKey script the will copy a highlighted email attachment link into Windows Run Diag (Windows Key+R) and open the email. I so far have parts of what I want working, but can't seem to get it all into one script to give the desired result. This is my requirement and what I have so far to better understand my end goal:

Requirement:

1) Highlighted email attachment link from a browser

2) CTRL + C -- to copy the email attachment link from a browser

3) Windows Key + R -- to open the Windows Run Diag

4) CTRL + V -- Paste the email attachment link into the Windows Run Diag

5) Enter -- to open the email


AutoHotKey Script:
$F10::

Send, ^c -- This command alone copy the email attachment link

ClipWait

FileDlg := ComObjCreate("Shell.Application").FileRun, FileDlg := "" -- this command alone also open the Windows Run Diag

Send, ^c {ENTER}

return


I will really appreciate any help I can get here... Thank you!

Re: AutoHotKey script HELP please!!!  Topic is solved

Posted: 24 Mar 2018, 11:25
by Trogluddite
I can see one obvious problem (probably just a typo!), and there is something else which should make your script more reliable...

Code: Select all

$F10::

	Send, ^c
	ClipWait 

	; Your variable 'FileDlg' doesn't do anything here; the existence of the FileRun dialogue as the
	; active window is sufficient to be able to 'Send' to it.
	ComObjCreate("Shell.Application").FileRun

	; This makes the script wait until the "Run" dialogue is definitely the active window,
	; otherwise you might paste the data back where it came from. It allows the dialogue
	; one second in which to open.
	WinWaitActive, Run,, 1

	; This shows an error message and closes the script if the 'Run' dialogue didn't open,
	; which should never happen, but it's good practice to handle this kind of thing.
	; 'ErrorLevel' is an internal variable which many commands will set if they fail.
	if (ErrorLevel) {
		MsgBox The Run dialogue could not be opened
		ExitApp
	}

	; Your posted code says ^c, which I guess is not what you meant!
	Send, ^v{Enter}

return

Re: AutoHotKey script HELP please!!!

Posted: 24 Mar 2018, 11:49
by jaggsharry
Just wait I'm looking for. Works perfectly! Thank you @Trogluddite for the quick response and for you help here! :)