[Script] WhiteSpaceCtxMenu

Discuss and share scripts and script files...
Post Reply
klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: [Script] WhiteSpaceCtxMenu

Post by klownboy »

CookieMonster wrote: it continues not to work
I'm assuming the load line looks something like...

Code: Select all

elseif($select == "PSD") {openwith """C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe"""; end(1);}
Try using this instead. You're using capital letters "PSD" along "==" so it will not work if the extension is "psd".

Code: Select all

elseif($selext LikeI "psd") {openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe"; end(1);}
Remember as I said before, a menu will not display when there is only one menu item. The psd file should be immediately opened with Photoshop. Make sure the full path/name is correct. If that doesn't work PM me with your script attached and I'll take a look at it. No sense dragging this on any loner than we have to in the forum.

Edit: Thanks highend for comment below. I removed the stray ". That's what I get for copying from a previous post.
Last edited by klownboy on 10 Jul 2015 13:51, edited 1 time in total.

highend
Posts: 14603
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Script] WhiteSpaceCtxMenu

Post by highend »

Code: Select all

elseif("$selext LikeI "psd") {openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe"; end(1);}
Won't work, first quotation mark must be removed...
One of my scripts helped you out? Please donate via Paypal

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: [Script] WhiteSpaceCtxMenu

Post by SkyFrontier »

Ahem...

Code: Select all

// 
  if(get('View') != '6') {
    #308;
  }
  loadlayout('thumbs'); // >>>>>>> not found!
  open 'D:\Tools\AutoHotkey\AHK scripts\TB_XY_hide.ahk'; // >>>>>>> will not be found!  ;)
:whistle:
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: [Script] WhiteSpaceCtxMenu

Post by klownboy »

Hi Skyfrontier,that one was meant to be an example only. As a matter of act the entire script is really just that. The script was intended only as examples of what can be done via right click on WhiteSpace whether it bring up a menu based on the selected extension or immediately runs a program. It can do pretty much what ever you want it to do via scripting. So yes, in that particular case, I was loading a layout which I have named "thumbs". You could, if you want something similar, substitute a layout of your own. That ahk script actually hides the main title bar so the result is pure thumbnail view - no titlebar, no menu, no tree, no toolbar - nothing but thumbnails in a box - you get the idea.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: [Script] WhiteSpaceCtxMenu

Post by SkyFrontier »

...would you mind sharing the AHK, then?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: [Script] WhiteSpaceCtxMenu

Post by klownboy »

No problem. First is a XY script to invoke a thumbnail view which will also hide basically everything including the Titlebar via the saved layout "thumbs" and the ahk script .

Code: Select all

 if(get("pane") == "2") {#802;}
   loadlayout("thumbs");
 if($TitleBar == "0") {run "D:\Tools\AutoHotkey\AutoHotkey.exe" "D:\Tools\AutoHotkey\AHK scripts\TB_XY_unhide.ahk", , 2,0;
    perm $TitleBar = "1";}
  goto "G:\Pictures\Ireland\2012";
  winpos 0, 0; winsize 1920, 1080; 
  run "D:\Tools\AutoHotkey\AutoHotkey.exe" "D:\Tools\AutoHotkey\AHK scripts\TB_XY_hide.ahk", , 0,0;
  perm $TitleBar = "0";
Next is the AHK script.

Code: Select all

#SingleInstance force
DetectHiddenWindows, on
#MaxMem 1
   HWND := WinExist("ahk_class ThunderRT6FormDC")
   IfWinActive, ahk_id %HWND%
	{
	  WinGet, Style, Style, ahk_id %HWND%
	  if (Style & +0xC00000) {	  
	  WinSet, Style, -0xC00000, ahk_id %HWND%     
	  exitapp
      }
	  exitapp
	}
Reverse the "+" to "-" and '-" to "+" to have an TB_XY_unhide.ahk script.

You can invoke how you choose, but I set up a User Defined Commands to open certain photo folders in full screen no bars mode. I have another numpad key set to reverse everything and get me back to my normal configuration the way I would normally work....something like this: Note: I use some perm ($TitleBar) such that XY knows/remembers the status of the titlebar.

Code: Select all

  if(get("instance") == "2") {exit n}  //this is here if I use a XY second instance in some cases
  elseif((get("instance") == "1") AND ($TitleBar == "0"))
     {run "D:\Tools\AutoHotkey\AutoHotkey.exe" "D:\Tools\AutoHotkey\AHK scripts\TB_XY_unhide.ahk", , 2,0;
     perm $TitleBar = "1";}
   #348; seltab 1;
   if(get("pane") == "2") {#802; #348; seltab 1;}
   loadlayout("normal");
   winpos 24, 6; winsize 1852, 1068;

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

I feel as if I'm playing a game of how many times can I type quotes and remove quotes and if I'm lucky Alex Trebek will offer me $200.00 for the most times I can do it.

Honestly I'm lost in quote hell; because this is not working. :evil: :evil: :evil:

Code: Select all

/*** text file menu ***/
   $txt = <<<DOC
"NotePad++|D:\Tools\NotePad++\notepad++.exe" openwith "D:\Tools\NotePad++\notepad++.exe";
"PSPad|D:\Tools\PSPad\PSPad.exe" openwith "D:\Tools\PSPad\PSPad.exe";
"Notepad|C:\Windows\notepad.exe" openwith "C:\Windows\notepad.exe";
DOC;

  $psd = <<<PSD 
"Photoshop|C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe" openwith """C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe""";
psd;

   if(exists("<selitem>") == 1) {
   $selext = getpathcomponent("<selitem>", "ext");
        if(gettokenindex($selext, "ini|txt|nfo|inf|reg|ps1|vbs", '|', 'i')) {load "$txt", , s; end(1);}   //load textfile menu
        elseif("$selext" == "xys") {load("<selitem>"); end(1);}  //no menu - example showing how you can automatically run an XY script on a right click on white
        elseif("$selext" == "ahk") {openwith "C:\Windows\notepad.exe"; end(1);}   //no menu - example to open an AHK file for editing
        elseif("$selext LikeI "psd") {openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe"; end(1);}
        else {#550; end(1);}
   }
   else {
        #550
        }

highend
Posts: 14603
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Script] WhiteSpaceCtxMenu

Post by highend »

because this is not working
Great error message!

- Wrong heredoc syntax (upper / lowercase matters)
- My last post already contained a comment why it doesn't work (regardless of the error message)
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

I may have found the problem !

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: [Script] WhiteSpaceCtxMenu

Post by klownboy »

CookieMonster, I sent you 2 PMs yesterday. The first gave you corrections for the errors. The last line of heredoc must be capitalized, PSD. You corrected the "==" to "LikeI", but you didn't correct or I should say remove the stray " before $selext.

Code: Select all

elseif($selext LikeI "psd") {openwith...
You didn't do what I told you to do yesterday.

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

This isn't correct as it's not working ?

Code: Select all

/*** text file menu ***/
   $txt = <<<DOC
"NotePad++|D:\Tools\NotePad++\notepad++.exe" openwith "D:\Tools\NotePad++\notepad++.exe";
"PSPad|D:\Tools\PSPad\PSPad.exe" openwith "D:\Tools\PSPad\PSPad.exe";
"Notepad|C:\Windows\notepad.exe" openwith "C:\Windows\notepad.exe";
DOC;

  $PSD = <<<PSD 
"Photoshop|C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe" openwith """C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe""";
PSD;

   if(exists("<selitem>") == 1) {
   $selext = getpathcomponent("<selitem>", "ext");
        if(gettokenindex($selext, "ini|txt|nfo|inf|reg|ps1|vbs", '|', 'i')) {load "$txt", , s; end(1);}   //load textfile menu
        elseif($selext == "xys") {load("<selitem>"); end(1);}  //no menu - example showing how you can automatically run an XY script on a right click on white
        elseif($selext == "ahk") {openwith "C:\Windows\notepad.exe"; end(1);}   //no menu - example to open an AHK file for editing
        elseif($selext LikeI "psd") {openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe"; end(1);}
        else {#550; end(1);}
   }
   else {
        #550
        }

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: [Script] WhiteSpaceCtxMenu

Post by klownboy »

Any error message or just doesn't work...meaning what...the psd file selected doesn't open in PhotoShop? Remember a menu is not going to come up when you have only one item in it.

The variable itself has to stay as "$psd" you changed it to "$PSD. It's not the same as $psd. Also, both I and highend also told you previously to change the heredoc line to use single quotes. I don't have PhotoShop so I can't test your setup. You can also put stepping on by pressing ctrl-alt-s prior to running script or right clicking white space in attempt to locate the problem.

I've been bouncing back and forth between opening a file immediately as in the case of the "xys" and "ahk" example that I forgot that you have a one menu item heredoc. Try this: When copying/pasting make sure you don't have extra spaces in there as you did after the initial heredoc statement.

Code: Select all

/*** text file menu ***/
   $txt = <<<DOC
"NotePad++|D:\Tools\NotePad++\notepad++.exe" openwith "D:\Tools\NotePad++\notepad++.exe";
"PSPad|D:\Tools\PSPad\PSPad.exe" openwith "D:\Tools\PSPad\PSPad.exe";
"Notepad|C:\Windows\notepad.exe" openwith "C:\Windows\notepad.exe";
DOC;

  $psd = <<<PSD
"Photoshop|C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe" openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe";
PSD;

   if(exists("<selitem>") == 1) {
   $selext = getpathcomponent("<selitem>", "ext");
        if(gettokenindex($selext, "ini|txt|nfo|inf|reg|ps1|vbs", '|', 'i')) {load "$txt", , s; end(1);}   //load textfile menu
        elseif($selext LikeI "xys") {load("<selitem>"); end(1);}  //no menu - example showing how you can automatically run an XY script on a right click on white
        elseif($selext LikeI "ahk") {openwith "C:\Windows\notepad.exe"; end(1);}   //no menu - example to open an AHK file for editing
        elseif($selext LikeI "psd") {load "$psd", , s; end(1);}
        else {#550; end(1);}
   }
   else {
        #550
        }
I ran the above and it worked. Though I used a different extension, the command executed.

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

The script you posted works, the only difference is Sublime Text XYplorer syntax highlighting is more pronounced in your script then mine & you declared a path for Ps; besides that I don't see any difference ?

I checked the white spacing; compared to yours, all is fine.
klownboy wrote:Any error message or just doesn't work...meaning what...the psd file selected doesn't open in PhotoShop? Remember a menu is not going to come up when you have only one item in it.

The variable itself has to stay as "$psd" you changed it to "$PSD. It's not the same as $psd. Also, both I and highend also told you previously to change the heredoc line to use single quotes. I don't have PhotoShop so I can't test your setup. You can also put stepping on by pressing ctrl-alt-s prior to running script or right clicking white space in attempt to locate the problem.

I've been bouncing back and forth between opening a file immediately as in the case of the "xys" and "ahk" example that I forgot that you have a one menu item heredoc. Try this: When copying/pasting make sure you don't have extra spaces in there as you did after the initial heredoc statement.

Code: Select all

/*** text file menu ***/
   $txt = <<<DOC
"NotePad++|D:\Tools\NotePad++\notepad++.exe" openwith "D:\Tools\NotePad++\notepad++.exe";
"PSPad|D:\Tools\PSPad\PSPad.exe" openwith "D:\Tools\PSPad\PSPad.exe";
"Notepad|C:\Windows\notepad.exe" openwith "C:\Windows\notepad.exe";
DOC;

  $psd = <<<PSD
"Photoshop|C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe" openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe";
PSD;

   if(exists("<selitem>") == 1) {
   $selext = getpathcomponent("<selitem>", "ext");
        if(gettokenindex($selext, "ini|txt|nfo|inf|reg|ps1|vbs", '|', 'i')) {load "$txt", , s; end(1);}   //load textfile menu
        elseif($selext LikeI "xys") {load("<selitem>"); end(1);}  //no menu - example showing how you can automatically run an XY script on a right click on white
        elseif($selext LikeI "ahk") {openwith "C:\Windows\notepad.exe"; end(1);}   //no menu - example to open an AHK file for editing
        elseif($selext LikeI "psd") {load "$psd", , s; end(1);}
        else {#550; end(1);}
   }
   else {
        #550
        }
I ran the above and it worked. Though I used a different extension, the command executed.
Klownboy - I'm wondering if this line has anything to do with why your code works ?

Code: Select all

elseif($selext LikeI "psd") {load "$psd", , s; end(1);}

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: [Script] WhiteSpaceCtxMenu

Post by klownboy »

CookieMonster wrote:Klownboy - I'm wondering if this line has anything to do with why your code works ?
Yes, along with the other things mentioned like the capatilized variable $PSD.

Like I said before though, when there's only one choice (i.e., one menu item), you don't need the heredoc section at all you can simply set it up to run when you right click on white space like this which is what I did for the "xys" and "ahk" file types.

Code: Select all

elseif($selext LikeI "psd") {openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe"; end(1);}  //don't need the variable $psd (heredoc) if run like this
I'm glad it's working in any case. 8)

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

I want to know, I was originally informed to put the full path of Ps, I understand that it is not a menu item, but shouldn't it still work with the full path, if so, why can't I get it working and all I get is a dubious error ?

Post Reply