Pseudo Icon states

Discuss and share scripts and script files...
serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Pseudo Icon states

Post by serendipity »

With latest beta v12.40.0203, the code simplifies to this:

Example: Manual sort ON/OFF state:
1) Add a custom user button to toolbar.
2) Then paste the below code in the on-click field.
You'll ofcourse need the icons from the zip file to be placed in xyicons folder for this to work.

Code: Select all

// Manual Sort toggle
          if (ctbicon() == "hand.ico") {
            ctbicon("drag-green.ico");
            #414;//Toggle Manual Sort
          } else {
            ctbicon("hand.ico");
            #414;//Toggle Manual Sort
          }  
Until we have real icons states here is a workaround with pseudo icon state for those who like some visual feedback.
Basically all I am doing is renaming the icons and refreshing them which gives the icon toggle effect.

Example: Manual sort ON/OFF state:
1) Add a custom user button to toolbar and set the icon as <xyicons>\hand.ico.
2) Then paste the below code in the on-click field.
Note that I have my OFF icon state as "hand" and ON icon state "drag-green". If you rename your icons to something else, make sure you change that in the first 2 lines below.
[code]
//Toggle Manual Sort
$icon1="hand";
$icon2="drag-green";
$fakename="fakeicon";
renameitem ("$fakename", "<xyicons>\$icon2.ico");
renameitem ("$icon2", "<xyicons>\$icon1.ico");
renameitem ("$icon1", "<xyicons>\$fakename.ico");
#502;//Refresh Icons
#414;//Toggle Manual Sort
[/code]
Edit: SC swapnames would have been perfect, but for that I have to preselect filenames.
Manual Sort.png
ManualSortIcons.zip
To see the attached files, you need to log into the forum.
Last edited by serendipity on 19 May 2013 20:30, edited 2 times in total.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Pseudo Icon states

Post by serendipity »

And this simplifies to:

Code: Select all

// Minitree toggle
          if (ctbicon() == "tree1.ico" AND get(#489)==0) {
            ctbicon("tree2.ico");
            button "minitree";//Toggle Manual Sort
          } else {
            ctbicon("tree1.ico");
            button "minitree";//Toggle Manual Sort
          }  
Note: added get command in line "if" condition to retrieve minitree state. :D
One more example with Mini tree OFF/ON:

[code]
//Toggle Mini tree icon
$icon1="tree1";
$icon2="tree2";
$fakename="fakeicon";
renameitem ("$fakename", "<xyicons>\$icon2.ico");
renameitem ("$icon2", "<xyicons>\$icon1.ico");
renameitem ("$icon1", "<xyicons>\$fakename.ico");
#502;//Refresh Icons
button "minitree";
[/code]
Modified icons from Fatcow.
ToggleMiniTree.png
MiniTree.zip
To see the attached files, you need to log into the forum.
Last edited by serendipity on 19 May 2013 20:38, edited 2 times in total.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Pseudo Icon states

Post by serendipity »

And this ofcourse provided by Don, works great:

Code: Select all

// cloud cycle
  $n = substr(ctbicon(), 1, 1);
  $n++;
  if ($n == 5) {
    $n = 1;
  }
  ctbicon("c$n.ico");
One last post, this is a proof-of-concept to show that you can toggle more than two icon states in the toolbar.
Below code toggles between 4 different cloud states continuously 3 times. Its pretty useless, but it's to show how to toggle between 4 icons.
To make it work, unzip the zipped icons in xyicons folder and create a new user button with below code and have the icon set to <xyicons>\c1.ico, you'll see 4 cloud states toggle 3 times when you click the button.
[code]
//Toggle 4 cloud icons

$total=3;//Number of times to cycle the 4 icons
$count=0;

WHILE($count != $total){

$icon1="c1";
$icon2="c2";
$fakename="fakeicon";
renameitem ("$fakename", "<xyicons>\$icon2.ico");
renameitem ("$icon2", "<xyicons>\$icon1.ico");
renameitem ("$icon1", "<xyicons>\$fakename.ico");
#502;//Refresh Icons
wait(100);

$icon1="c1";
$icon2="c3";
$fakename="fakeicon";
renameitem ("$fakename", "<xyicons>\$icon2.ico");
renameitem ("$icon2", "<xyicons>\$icon1.ico");
renameitem ("$icon1", "<xyicons>\$fakename.ico");
#502;//Refresh Icons
wait(100);

$icon1="c1";
$icon2="c4";
$fakename="fakeicon";
renameitem ("$fakename", "<xyicons>\$icon2.ico");
renameitem ("$icon2", "<xyicons>\$icon1.ico");
renameitem ("$icon1", "<xyicons>\$fakename.ico");
#502;//Refresh Icons
wait(100);

$icon1="c1";
$icon2="c2";
$fakename="fakeicon";
renameitem ("$fakename", "<xyicons>\$icon2.ico");
renameitem ("$icon2", "<xyicons>\$icon1.ico");
renameitem ("$icon1", "<xyicons>\$fakename.ico");
#502;//Refresh Icons
wait(100);

$icon1="c2";
$icon2="c3";
$fakename="fakeicon";
renameitem ("$fakename", "<xyicons>\$icon2.ico");
renameitem ("$icon2", "<xyicons>\$icon1.ico");
renameitem ("$icon1", "<xyicons>\$fakename.ico");

$icon1="c3";
$icon2="c4";
$fakename="fakeicon";
renameitem ("$fakename", "<xyicons>\$icon2.ico");
renameitem ("$icon2", "<xyicons>\$icon1.ico");
renameitem ("$icon1", "<xyicons>\$fakename.ico");

$count++;

}
[/code]
CloudStates.png
CloudStates.zip
To see the attached files, you need to log into the forum.
Last edited by serendipity on 19 May 2013 20:40, edited 2 times in total.

admin
Site Admin
Posts: 66294
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Pseudo Icon states

Post by admin »

Wow, what a dirty work. :) That's near-hacking.

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

Re: Pseudo Icon states

Post by klownboy »

Hi serendipity,
Very nice idea. I'll surely be killing some time with this technique! :appl:

I know it's not as meaning full as changing the icon based on the state or condition as in mini-tree, but it looks like using your technique, we can cycle an icon(s) back and forth when you're starting a program. I did that experimenting and it works fine, but it changes the icon on the CTB obviously back and forth with each run of the program.

Let's say as an example, we want to open a program like "CCleaner" and want the CTB icon assigned to change to different CCleaner version icon before opening CCleaner, but we want the icon on the CTB to revert back to the original icon assigned (in the "icon" assignment block) once the CCleaner program starts or after it's done. Before I would simply use the open command to start CCleaner, but to get the icon state to revert back to what it was previously (i.e., the one in the "icon" assignment block), I had to resort to using the "run" command with the wait state "2". Using run with the wait state though has it's drawbacks. See the example below:

Code: Select all

  $icon1="ccleaner01";
  $icon2="ccleaner02";
  $fakename="fakeicon";
  renameitem ("$fakename", "<xyicons>\$icon2.ico"); 
  renameitem ("$icon2", "<xyicons>\$icon1.ico"); 
  renameitem ("$icon1", "<xyicons>\$fakename.ico"); 
  #502;                        //Refresh Icons

  run """D:\Tools\CCleaner\CCleaner64.exe""", ,2;
  renameitem ("$fakename", "<xyicons>\$icon2.ico"); 
  renameitem ("$icon2", "<xyicons>\$icon1.ico"); 
  renameitem ("$icon1", "<xyicons>\$fakename.ico"); 
  #502;                        //Refresh Icons
My question is, would there be a easy way of accomplishing this without resorting to a run command?
Thanks for sharing this nice new technique,
Ken

admin
Site Admin
Posts: 66294
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Pseudo Icon states

Post by admin »

How about making this a bit less dirty by adding a script command to set the CTB icon?

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

Re: Pseudo Icon states

Post by klownboy »

Don, that's sounds like a great idea. So we could then change the CTB's icon at will within a script. Would we call out the CTB number in some manner and an icon? Would the new script command be able to change the icon of any CTB or just the icon of the "current" CTB script? In my example above, would I still have to use the "run" command with a wait state "2" to change the icon back to what it originally was?
Thanks Don and thanks serendipity for the nifty idea,
Ken

admin
Site Admin
Posts: 66294
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Pseudo Icon states

Post by admin »

Yes, my idea was CTB number and icon. Later tonight I'll think deeper about it.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Pseudo Icon states

Post by serendipity »

admin wrote:How about making this a bit less dirty by adding a script command to set the CTB icon?
Well, hence my request the other day to enhance toolbar SC.
I did not want to disturb your hype-focused beta waves. :mrgreen:

admin
Site Admin
Posts: 66294
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Pseudo Icon states

Post by admin »

serendipity wrote:
admin wrote:How about making this a bit less dirty by adding a script command to set the CTB icon?
Well, hence my request the other day to enhance toolbar SC.
I did not want to disturb your hype-focused beta waves. :mrgreen:
:biggrin: I feel a bit sorry for your ingenious filename swap idea, but it will soon be obsolete... :mrgreen:

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Pseudo Icon states

Post by serendipity »

admin wrote:
serendipity wrote:
admin wrote:How about making this a bit less dirty by adding a script command to set the CTB icon?
Well, hence my request the other day to enhance toolbar SC.
I did not want to disturb your hype-focused beta waves. :mrgreen:
:biggrin: I feel a bit sorry for your ingenious filename swap idea, but it will soon be obsolete... :mrgreen:
:lol:

admin
Site Admin
Posts: 66294
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Pseudo Icon states

Post by admin »

Works nicely with your cloud icons. :D

Code: Select all

// cloud cycle
  $n = substr(ctbicon(), 1, 1);
  $n++;
  if ($n == 5) {
    $n = 1;
  }
  ctbicon("c$n.ico");

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Pseudo Icon states

Post by serendipity »

admin wrote:Works nicely with your cloud icons. :D

Code: Select all

// cloud cycle
  $n = substr(ctbicon(), 1, 1);
  $n++;
  if ($n == 5) {
    $n = 1;
  }
  ctbicon("c$n.ico");
:appl: :appl: :appl:

A new toy for me. :mrgreen:

admin
Site Admin
Posts: 66294
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Pseudo Icon states

Post by admin »

Is it only me, or is the forum totally lame currently??? :om:

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Pseudo Icon states

Post by serendipity »

admin wrote:Is it only me, or is the forum totally lame currently??? :om:
You mean slow?

Post Reply