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

Get help with using AutoHotkey and its commands and hotkeys
llinfeng
Posts: 36
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

+#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 57 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 57 times
Please advise how to fix the script. Reference for ShellRun: https://github.com/Lexikos/AutoHotkey-R ... ellRun.ahk
User avatar
jeeswg
Posts: 5406
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

+#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: 36
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

+#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 49 times

Code: Select all

+#i:: 
    clipback := Clipboard
    ; ShellRun("C:\vim\vim80\gvim.exe", clipback, "", 3) ; Yields the same "no-file-association" error.
    ; run, gvim %clipback%, max  ; does not run, cannot find gvim (gvim is available through Run box)
    ; run, "C:\vim\vim80\gvim.exe" %clipback%, Max  ; does not get me a Maximized window
    ; run, "C:\vim\vim80\gvim.exe", %clipback%, Max  ; Opens the editor ony
    run *RunAs "C:\vim\vim80\gvim.exe" %clipback%
    sleep 1000
    ; WinMaximize  ; Well, nothing much goes maximized though.
    send ^#{F10} ;Using MaxTo, a Window manipulator
return
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: MrRED, swagfag and 39 guests