Widgets ok but not gadgets..

Does anybody know a way to get gadgets to save their settings(position/ second hand-showing..I made a few clocks and noticed that widgets work fine but when it comes to making gadgets they just don't work right.. sVis wrote me a couple of scripts for clocks. When they work right you can choose whether to show/hide second hand plus second hand has a bounceback to it... Default is not showing.. But when(as a gadget) I choose to show second hand and move to different part of screen it always goes back to the place where it first loaded with the second hand not showing(when restarted). But as a widget it saves settings  just fine, when restarted. I guess I'll just make them widgets unless someone knows how to fix this.. Windows 7 64 bit....

7,545 views 8 replies
Reply #1 Top

Thanks for helping me out guys...

Reply #2 Top

i'm still looking thru posts..... X-(

 

 

 

 

Reply #3 Top

i have noticed that gadgets i have used alway default back to original settings

 

but not to despair....

 

I'm sure that shortly one of those smart scripters like sViz will drop by.

 

 

 

 

Reply #4 Top

I tried a few gadgets I made and the settings stick for me.

The only other thing I can think of for you to try is to create an INI file. So when the gadget closes, it saves its settings to an external file. On reload it will read the file and set itself up again.

Here's an example:

Code: vbscript
  1. Const ForReading = 1, ForWriting = 2, ForAppending = 8
  2. Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
  3. Dim filename : filename = "myobjectsettings.txt"
  4.  
  5. 'Called when the script is executed
  6. Sub Object_OnScriptEnter
  7.  setup
  8. End Sub
  9.  
  10. 'Called when the script is terminated
  11. Sub Object_OnScriptExit
  12.  writeFile
  13. End Sub
  14.  
  15. Function setup
  16.  iData = readFile
  17.  If iData <> "" Then
  18.   iDataSettings = split(iData,vbcrlf)
  19.   object.Left = iDataSettings(0) '--apply the first setting listed
  20.   object.top = iDataSettings(1)  '--second setting
  21.   'object.visible = iDataSettings(2) '--third setting
  22.  End If
  23. End Function
  24. Sub writeFile
  25.  textfile = DesktopX.ExecutableDirectory & "\" & filename
  26.  Set f = fso.OpenTextFile(textfile, ForWriting, True)
  27.  'List settings to write to file
  28.  xpos = object.Left
  29.  ypos = object.Top
  30.  'othersetting = object.visible
  31.  f.Write xpos & vbcrlf & ypos '& vbcrlf & othersetting
  32.  f.Close
  33. End Sub
  34. Function readFile
  35.  textfile = DesktopX.ExecutableDirectory & "\" & filename
  36.  fileinfo = ""
  37.  If fso.FileExists(textfile) Then
  38.   Set f = fso.OpenTextFile(textfile, ForReading)
  39.   fileinfo = f.readall
  40.   f.Close
  41.  Else
  42.   writeFile
  43.  End If 
  44.  readFile = fileinfo
  45. End Function

In the example above, you set "filename" to the name of your INI file. It will be saved in the ExecutableDirectory, i.e., wherever the gadget is launching from (you'll likely find it in the main DesktopX folder.) The "writeFile" function is where you would add any extra settings you want to save (see the examples commented out.) The "setup" function is where you would apply the settings in the order in which they were saved to file.

 

Reply #5 Top

Sorry didn't have thing checked that says, persist object status across reloads (position, size, etc) Everythings fine now, thanks..Thanks sVis & Bichur..& sVis what's your name anyway? Get tired of jusy saying sVis. Anyway I may try that on something else..Also these sliding drawer templates I downloaded when I thought I was downloading Summer weather 2(updated cache) are pretty neat.. Are you going to upload them or do a tutorial using them?, cause I might like to use them sometime but I don't want to use them if you've got plans for them in the future. I won't even condider using them unless you give the ok..

Reply #7 Top

Glad You got it sorted out Richard! :thumbsup: