Skip to content

Instantly share code, notes, and snippets.

@davebrny
Last active November 26, 2021 19:52
Show Gist options
  • Save davebrny/fd31caabaa02a3e7e60095011e97b783 to your computer and use it in GitHub Desktop.
Save davebrny/fd31caabaa02a3e7e60095011e97b783 to your computer and use it in GitHub Desktop.
(autohotkey) - open properties for the selected file (and use "run" if the hotkey didnt send)
#ifWinActive ahk_class CabinetWClass
^+p::goSub, file_properties
#ifWinActive
file_properties:
revert_clipboard := clipboardAll
clipboard =
send ^{c}
clipWait, 0.6
selected_file := clipboard
clipboard := revert_clipboard
if (selected_file = "")
trayTip, file properties, clipWait timed out. try again, 8
else
{
send !{enter} ; default properties hotkey
splitPath, selected_file, filename
winWaitActive, % filename " Properties ahk_class #32770", , 0.5
if (errorLevel = 1) ; if !{enter} didnt open any properties
and !inStr(selected_file, "`n") ; and only a single file was selected
run, properties "%selected_file%"
}
return
/*
[script info]
version = 1.1
description = open properties for the selected file (and use "run" if the hotkey didnt send)
author = davebrny
source = https://gist.github.com/davebrny/fd31caabaa02a3e7e60095011e97b783
*/
@davebrny
Copy link
Author

davebrny commented Jan 25, 2017

send !{enter} doesnt seem to always work when the preview pane is showing in file explorer, so this waits half a second for the properties window to open, then if it doesnt, it uses the run command to open the properties instead. (there is a slight delay when using the run command with the "properties" verb)

the run command cant get file properties if more than one file is selected

@MrrrrTony
Copy link

Hey. I know it's been a while since this project and you seem to no longer be around.

I've encountered a problem after running this code. If it's not going to get a solution, may it be just a heads up.

After using hotkey to view properties of a file, I tried to view properties of "file properties.ahk". The following happened:

  • pressing keys on the keyboard wouldn't type anything, nor did CTRL+SHIFT+ESC (task manager) work
  • double clicking any file would show its properties, had to right click to Open from menu
  • copying any text would not work with CTRL+C, had to right click text to Copy from menu

@davebrny
Copy link
Author

hey @MrrrrTony, yea i switched to linux a few years ago so i havnt been using autohotkey as much. some of the autohotkey stuff still works using wine but im trying to force myself to use python and bash a bit more.

thats doesnt sound good. did the same thing happen with other files as well or just "file properties.ahk"? could be that it gets stuck in a loop trying to check itself or something, im not sure. well thanks for reporting it anyway, at least someone who might use this in the future will hopefully read the comments and know not to run it on itself!

@MrrrrTony
Copy link

Hey @davebrny, thanks for the quick answer.
Given the fact that last time only a restart "fixed" it, I haven't dared to try again yet :)
But I will and post the feedback in here in case someone needs it in the future.

@MrrrrTony
Copy link

Hello again @davebrny. I've done several tests and the problem didn't appear again. That was weird the first time, didn't understand why would something like that even happen - some sort of loop, yes, but how? :)

While testing I noticed just one thing: the script doesn't seem to work for desktop files or folders. Tested in several places and on several file extensions, including repeatedly on file_properties.ahk, nothing "bad" happened anymore, but on desktop it just won't work. :)

Anyway, thanks very much for this script and the rest of them, some are sooo, sooo helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment