Page 1 of 1

Using <get drop> and <get trigger> in CTB

Posted: 17 Feb 2013 20:05
by klownboy
A quick and quite butchered-up example on using both <get trigger> and <get drop> in a script assigned to a CTB. If you drop a photo/picture on the CTB, it sets the photo as your wallpaper using Irfanview. If you left click the CTB, it will display a menu and right click display a slightly modified menu. Of course you could make the right click and/or left click do whatever you want, but the point here was just to show "drag and drop" melded in with the left and right click of a CTB. Please read the comments in the script.

Edit: Don has now given us the capability to recognize a drag/drop with the left mouse button vs the right mouse button to a CTB along with the existing left click and right click capability. I expanded the example script to distinguish a left and right drag so I've assigned one action (provides Meta data on the JPG) for dragging a JPG file to a CTB with the left mouse button and a different action (setting the JPG as your destop wallpaper) if the JPG was dragged with right mouse button to the same CTB. Obviously you can change the actions to whatever you desire. This is only an example. Nice though that we can essentialy have a CTB doing 4 separate actions, one for left drag, right drag, left click and right click, never mind the possibilities available through the use of menus. Assign the left click of the CTB to load "D:\Tools\Xyplorer\Scripts\scriptname.xys", "_Lmouse"; and the right click to, load "D:\Tools\Xyplorer\Scripts\scriptname.xys";

Code: Select all

"_Lmouse";
  perm $p_Lmouse = "Lmouse";
  //or you could establish up front that's it a left drop  if (<get trigger> != 1) { perm $p_Drag = "Left_Drag";} 
  load self(file);

"_Initialize";
  if (<get drop |> == ""){
   if (<get trigger> == 1) {
     perm $TB; $TB = "[no TB]"; 
     }
   if (<get trigger> == 2) {
     perm $TB; $TB = "[with TB]"; 
     }
    }
  else {
    $File_Cnt = gettoken(<get drop |>, "count", "|");
       end $File_Cnt > "1", "You have selected more than one file, aborting!";
     $p = property("#11", "<get drop>");            // determine if the dropped file is a picture
     if ($p == "Picture") {                         // checks properties to make sure it's an image/picture       
       if ($p_Lmouse == "Lmouse") {
       #197;                            //Display Photo Metadata, but you can put any command here like the next line
       //run "cmd /c """"D:\Graphics\ImageMagick\identify.exe"" -verbose ""<get drop>"" > g:\downloads\imginfo.txt""", , 1; open "g:\downloads\imginfo.txt";
       end (1==1); }
       else {
       run "D:\Graphics\IrfanView\i_view32.exe <get drop> /wall=3 /killmesoftly";
       end (1==1);}
       }
      else {
         msg "You didn't drop a picture file!";
         end (1==1);}
     }
   }
"Folders $TB|:lasttarget";  ''If you click on a sub menu item and you left clicked the CTB, you'll loose all your bars)
"-"
"XY folder|:goprev" goto "<xypath>"; //Just an example...I'd set the folder to one containing photos to show thumbs in the full XY frame with no nav pnl
    sub _expand_it;
"XY Scripts|:goprev" goto "<xyscripts>";
    sub _expand_it;
"-"
"Back to all bars";      //I'd have a CKS that will bring back your normal state such as in sub "_normal" if you remove all the bars!
    sub _normal;

"_expand_it";    // Set these bars anyway you want them.

     if get(#660) {#660;}     // Address Bar
     if ($TB == "[no TB]")  {  // Toolbar
        if get(#661) {#661}
        }
     if ($TB == "[with TB]") {
        if !get(#661) {#661}
        }
      if get(#662) {#662;}    // Tab bar
      if get(#663) {#663;}    // Nav Pnl
      if get(#665) {#665;}    // Info Pnl
      if get(#670) {#670;}    // Status Bar
      if get(#1061) {#1061;}  // Menu Bar
      if get("#800") {#800;}  // Dual Pane
      end (1==1)

"_normal";      
 if get(#660) {#660;}    // Address Bar
    if !get(#661) {#661;}   // Tool Bar
    if !get(#662) {#662;}   // Tab bar
    if !get(#663) {#663;}   // Nav Pnl
    if !get(#664) {#664;}   // Catalog
    if get(#665) {#665;}    // Info Pnl
    if !get(#670) {#670;}   // Status Bar
    if !get(#1061) {#1061;} // Menu Bar
    if get("#800") {#800;}  // Dual Pane
   #552;#1040;#1009;goto "C:\";

"_Terminate";
    perm $TB = "[with TB]";
    unset $p_Lmouse;
Thanks Don for the new toys,
Ken

Re: Using <get drop> and <get trigger> in CTB

Posted: 20 Feb 2013 02:04
by klownboy
Don has now given us the capability to recognize a drag/drop with the left mouse button vs the right mouse button to a CTB along with the existing left click and right click capability. Based on the new options, I expanded the example script in the first post to distinguish a left and right drag so I've assigned one action (provides Meta data on the JPG) for dragging a JPG file to a CTB with the left mouse button and a different action (setting the JPG as your destop wallpaper) if the JPG was dragged with right mouse button to the same CTB. More info on the first post. You of course can assign whatever actions you want. It's quite nice though that we can now assign different actions for left drag, right drag, left click and right click of a CTB. I suppose we'll need awful long title descriptions to explain and remember the CTB assignments.
Thanks again Don for the new toys,
Ken