Edit a file through Full Path, as contained in the Clipboard

Get help with using AutoHotkey and its commands and hotkeys
llinfeng
Posts: 34
Joined: 08 Dec 2016, 21:54
GitHub: llinfeng

Edit a file through Full Path, as contained in the Clipboard

12 Aug 2018, 16:57

With the following failed attempt, I would like to achieve the following two goals:

    1. Specify the text editor (and start it with Admin right if I were running the "master AHK script" with Admin);
    2. Open the file as specified in the Clipboard (Full-path) using the text editor.

A failed attempt:

Code: [Select all] [Download] GeSHi © Codebox Plus

+#i::  ; Note, this is a failed attempt 
clipback := ClipboardAll
MsgBox, %clipback%
ShellRun("C:\vim\vim80\gvim.exe", %clipback% , "", 3)
; run "C:\vim\vim80\gvim.exe" %clipback%
return


I see two interesting errors (if we may call them errors) as attached. Using the simple `run` method tries to use the text editor to open a file named as the special character.

AHK_Clip_Message_Display.jpg
Well, this funky character shall stay all the same, regardless of the Full-path of the file that I store in the clipboard.
AHK_Clip_Message_Display.jpg (8.19 KiB) Viewed 30 times


AHK_Clip_Associa.jpg
I have tried to files with various extension, and should get this warning with `.txt` files.
AHK_Clip_Associa.jpg (57.91 KiB) Viewed 30 times


Please advise how to fix the script. Reference for ShellRun: https://github.com/Lexikos/AutoHotkey-R ... ellRun.ahk
User avatar
jeeswg
Posts: 4759
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Edit a file through Full Path, as contained in the Clipboard

12 Aug 2018, 17:00

Try this:

Code: [Select all] [Download] GeSHi © Codebox Plus

+#i::  ; Note, this is a failed attempt
clipback := Clipboard
MsgBox, %clipback%
ShellRun("C:\vim\vim80\gvim.exe", clipback, "", 3)
; run "C:\vim\vim80\gvim.exe" %clipback%
return
llinfeng
Posts: 34
Joined: 08 Dec 2016, 21:54
GitHub: llinfeng

Re: Edit a file through Full Path, as contained in the Clipboard

12 Aug 2018, 17:26

jeeswg wrote:Try this:

Code: [Select all] [Download] GeSHi © Codebox Plus

+#i::  ; Note, this is a failed attempt
clipback := Clipboard
MsgBox, %clipback%
ShellRun("C:\vim\vim80\gvim.exe", clipback, "", 3)
; run "C:\vim\vim80\gvim.exe" %clipback%
return

Running your code yields the same error message, I am pasting a working version that I managed to put together:
AHK_Clip_Association.jpg
Identical error message arise.
AHK_Clip_Association.jpg (61.44 KiB) Viewed 22 times


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Still, I prefer to open windows using some variants of the `ShellRun` command, as it maximizes the window without showing the GUI effects.

PS ==> Missing piece 1: I would also like to make have `ShellRun` to start the editor as Admin, but did not find a way to do it yet. Surprisingly easy, including the `*RunAs` parameter(?) should get me far enough :)

Return to “Ask For Help”

Who is online

Users browsing this forum: colt, Exaskryz, jamie1992, Sabestian Caine and 42 guests