Go down
avatar
TheAncient
Posts : 5
Join date : 2019-12-27

Move from 9 to 10 breaks batch file to re-create Stickies Empty Move from 9 to 10 breaks batch file to re-create Stickies

on Fri Dec 27, 2019 2:19 am
Way back in 2016 (and in a previous incarnation of this forum) some kind soul helped me to create a batch file to delete and then re-create a sticky on my desktop. - A header with the account type/name and the current date.
This batch program has been running nightly since then without any problems but, after an upgrade from version 9.0e to version 10_0a this batch file no longer works. Would someone be able to let me know why it no longer works and how to fix it?
Thank you!

Here is the batch file:
@echo off

set BackupDate=%Date:/=-%

Set Account1Text="%UserName%    -   MS ADMIN Account as of     %BackupDate%"
Set Account1ColorR=0
Set Account1ColorG=99
Set Account1ColorB=177

:: Delete sticky with the title "LogDate"
apicmd.exe "do desktop LogDate delete"

:: Create new sticky with title "LogDate"
apicmd.exe "do new sleeping encoded <X>0306<Y>-017<WIDTH>967<HEIGHT>-1<ID>LogDate<rolled>0<" > nul

apicmd.exe "set desktop LogDate text %Account1Text%" > nul

apicmd.exe "set desktop LogDate colour %Account1ColorR%,%Account1ColorG%,%Account1ColorB%" > nul

apicmd.exe "set desktop LogDate style 2" > nul

apicmd.exe "set desktop Logdate skinpath S:\someplace\Zhorn Stickies/skins/sticky6_basic.ssk" > nul

@Exit
avatar
Sooyke
Posts : 147
Join date : 2018-04-28

Move from 9 to 10 breaks batch file to re-create Stickies Empty Re: Move from 9 to 10 breaks batch file to re-create Stickies

on Fri Dec 27, 2019 11:30 am
It seems you cannot set the ID to " LogDate " , version 10 uses an internal incrementing ID , apicmd.exe is quite restricted what it can do so after creating a new sticky you cannot read the ID to use in the following commands.

I guess the only solutlon is using the normal api ( application interface ) to interact with stickies but this does not work with the batch file scripting language. ( Or asking for an adaptation of apicmd.exe )

Best regards
avatar
TheAncient
Posts : 5
Join date : 2019-12-27

Move from 9 to 10 breaks batch file to re-create Stickies Empty Stick with version 9.0e

on Fri Dec 27, 2019 4:04 pm
I guess I will have to remain on version 9.0e then - unless the maintainers of this software (Tom?) stumble across this thread and decide to modify apicmd or offer some other solution for working with stickies from outside the program. The entire concept of apicmd, as I understand it was, to permit operating on a given sticky via external programs (including batch files). If you cannot specify which sticky you want to work on, apicmd becomes pretty much useless. Seems to me, it should not be too tough to retrieve the sticky ID - especially, since in my case, most of text of the sticky will remain the same (only the date changes from one day to the next).
avatar
Sooyke
Posts : 147
Join date : 2018-04-28

Move from 9 to 10 breaks batch file to re-create Stickies Empty Re: Move from 9 to 10 breaks batch file to re-create Stickies

on Fri Dec 27, 2019 5:42 pm
The standard way of interacting with stickies is using the api   https://www.zhornsoftware.co.uk/stickies/api.html

This is what is said about apicmd.exe :

Also available is a VC++ non-MFC project command line application which sends one-way messages to Stickies. It's one-way, as command line apps have no window to which Stickies can send replies. To that end, it's rather limited in what it can do.


It is quite easy to code for an equivalent to your batch file using the WM_COPYDATA but you need another language than the batch file to write the script.
I will stay with v9 ( even v8 on an older system ) too because for me having the images in a directory is more important than some advantages of v10 .


Greetings and best wishes for the new year .
avatar
TheAncient
Posts : 5
Join date : 2019-12-27

Move from 9 to 10 breaks batch file to re-create Stickies Empty Re: Move from 9 to 10 breaks batch file to re-create Stickies

on Fri Dec 27, 2019 6:17 pm
Unfortunately, I am quite a few decades too old for those other languages. (Assembler, Fortran, or APL anyone?) I haven't done any coding in the last 30 years or so. Thus, I have no choice but to remain on v9. Thanks a lot for your help and best wishes to you as well.
Admin
Admin
Admin
Posts : 206
Join date : 2018-03-30
Location : London
http://www.zhornsoftware.co.uk

Move from 9 to 10 breaks batch file to re-create Stickies Empty Re: Move from 9 to 10 breaks batch file to re-create Stickies

on Wed Jan 01, 2020 3:09 pm
TheAncient - what Sooyke says is right, it's not the API which is limited, but instead apicmd.exe.  It's the nature of the way that's written that it's one-way communication.  The script you're using relies on being able to specify a unique ID for a new note, and it assumes that the commands it sends to Stickies work OK.  If instead you used the API directly, then you'd get confirmation from Stickies, and along with that would come the ID of the new note you'd created.

Looking at your batch file though, it seems to create a new note with more or less the same content every time it's run.  The following is a neater way of doing (pretty much) the same thing, setting many of the properties of the new note on one line.  However, I appreciate it doesn't automatically replace the an earlier note:

Code:
set BackupDate=%Date:/=-%
set msg=%username% ADMIN account %backupdate%
apicmd do new encoded ^<X^>306^<Y^>17^<WIDTH^>967^<COLR^>0^<COLG^>99^<COLB^>177^<RTF^>{\rtf1\ansi{\fonttbl{\f0\fnil\fcharset0
                                                  Tahoma;}}{\colortbl ;\red255\green255\blue255;}\viewkind4\uc1\pard\cf1\f0\fs20 %msg% \cf0\par}

I've broken the long third line - there should be a space between charset0 and Tahoma, not a newline and indentation.  Anyway, it might help you out (and it works with v10!)

Tom
avatar
TheAncient
Posts : 5
Join date : 2019-12-27

Move from 9 to 10 breaks batch file to re-create Stickies Empty Re: Move from 9 to 10 breaks batch file to re-create Stickies

on Wed Jan 01, 2020 7:33 pm
Happy New Year Tom!
I am glad to see that you are still taking an interest in the support of "Stickies". I was afraid, you might have handed support off to someone else by now. You are correct: the sticky I am creating / re-creating is the same from one day to the next with one exception: the DATE.

Let me attempt to explain what I am trying to accomplish:
When troubleshooting, I often work with different systems disks containing copies of the system on different dates.
Disk 1 may contain the system as it exists NOW, Disk 2 may contain the system as it stood BEFORE a particular update and Disk 3 may contain the same system as it existed right AFTER that update.
When I boot into any one of those three disks, chances are, the desktop looks exactly the same and there is nothing to distinguish which version of the three I am actually running. Even the names of the system volumes are identical as they are all versions of the same system. The only way I have found to easily tell them apart is, by placing a sticky with the date on the desktop before I take my nightly backup. That way, every backup, is, essentially, "date-stamped" and when I then restore that backup, the desktop of the restored system will show the date the backup was taken.

Unfortunately, currently I do not have the time to try out the solution you provided here but I know I will have to find a way to delete the previous version of the sticky. I do not know if there is a way of UPDATING the text of the sticky rather than re-creating the entire sticky. Maybe there is a way of retrieving the sticky ID on the basis of the sticky text (something like the reverse of "set desktop <id> text <text>") Given that the <id> is used in a lot of API commands, a way of retrieving it would come in very handy. One difficulty here is the fact that I am using a batch file. (I am more comfortable using a language that's nearly as ancient as I am.)

I tried to download the sample zip files you provided, but it appears all three links to the samples are broken.

If you can come up with any other ideas that can help me delete the previous date sticky and display the current date on the desktop instead, it would be greatly appreciated.
Admin
Admin
Admin
Posts : 206
Join date : 2018-03-30
Location : London
http://www.zhornsoftware.co.uk

Move from 9 to 10 breaks batch file to re-create Stickies Empty Re: Move from 9 to 10 breaks batch file to re-create Stickies

on Mon Jan 13, 2020 10:27 pm
Oh ok, then that should be straightforward enough, assuming I've understood correctly.

Create a new note, put it on the desktop of the machine which is being imaged where you'd like.  Click it, then press control-/ (which will open the properties in Manages).

Make a note of the ID.

Set your batch file to be this:

Code:

 apicmd.exe set desktop 3108 text %Date:/=-%

...and replace 3108 with the ID you've got for the desktop note.

This solution will mean that you'll always have that note on the desktop, and also if you close the note then your batch file will break ... but it's easily enough fixed by just noting down the new ID and updating the batch file.  You could even help avoid your closing the note by setting it to have a skin which has no close button!

Tom
avatar
TheAncient
Posts : 5
Join date : 2019-12-27

Move from 9 to 10 breaks batch file to re-create Stickies Empty Re: Move from 9 to 10 breaks batch file to re-create Stickies

on Thu Jan 16, 2020 3:26 am
Thanks Tom!

Works fine with one exception: The code you gave me, for some reason also re-sets the style and the skin for that sticky.
So after the code runs and sets the text, the sticky is no longer bold, underlined and in white but in a rather unassuming black font.
I had to add

apicmd.exe set desktop 3 text %Account1Text%                                                          <==== Your Code (modified for my system)
apicmd.exe set desktop 3 style 2 > nul                                                                           <==== Had to add this
apicmd.exe set desktop 3 skinpath %MyPath%/skins/sticky6_basic.ssk > nul       <==== Had to add this

With those minor changes it appears to work fine.
I have made those changes to my nightly batch job and expect it will change the date just before the nightly backups start.
The only minor inconvenience: I had to customize my batch file for each computer as the Sticky IDs are different for each machine.

Thank you very much for your help!
Sponsored content

Move from 9 to 10 breaks batch file to re-create Stickies Empty Re: Move from 9 to 10 breaks batch file to re-create Stickies

Back to top
Permissions in this forum:
You can reply to topics in this forum