mirror of
https://github.com/greenshot/greenshot
synced 2025-07-31 12:10:15 -07:00
FEATURE-998: opening the explorer with the last file selected, this makes it jump to the correct file. [skip ci]
This commit is contained in:
parent
5e653cd3f1
commit
48fc52aab7
1 changed files with 18 additions and 3 deletions
|
@ -1304,8 +1304,8 @@ namespace Greenshot {
|
||||||
private void NotifyIconClick(ClickActions clickAction) {
|
private void NotifyIconClick(ClickActions clickAction) {
|
||||||
switch (clickAction) {
|
switch (clickAction) {
|
||||||
case ClickActions.OPEN_LAST_IN_EXPLORER:
|
case ClickActions.OPEN_LAST_IN_EXPLORER:
|
||||||
string path = null;
|
string path = _conf.OutputFileAsFullpath;
|
||||||
if (!string.IsNullOrEmpty(_conf.OutputFileAsFullpath)) {
|
if (!File.Exists(path)) {
|
||||||
string lastFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath);
|
string lastFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath);
|
||||||
if (!string.IsNullOrEmpty(lastFilePath) && Directory.Exists(lastFilePath)) {
|
if (!string.IsNullOrEmpty(lastFilePath) && Directory.Exists(lastFilePath)) {
|
||||||
path = lastFilePath;
|
path = lastFilePath;
|
||||||
|
@ -1320,7 +1320,22 @@ namespace Greenshot {
|
||||||
|
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
try {
|
try {
|
||||||
using (Process.Start(path)) {}
|
// Check if path is a directory
|
||||||
|
if (Directory.Exists(path))
|
||||||
|
{
|
||||||
|
using (Process.Start(path))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check if path is a file
|
||||||
|
else if (File.Exists(path))
|
||||||
|
{
|
||||||
|
// Start the explorer process and select the file
|
||||||
|
using (var explorer = Process.Start("explorer.exe", $"/select,\"{path}\""))
|
||||||
|
{
|
||||||
|
explorer?.WaitForInputIdle(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// Make sure we show what we tried to open in the exception
|
// Make sure we show what we tried to open in the exception
|
||||||
ex.Data.Add("path", path);
|
ex.Data.Add("path", path);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue