How create a Shortcut on DX (advanced)

Tuesday, July 17, 2007 by ArileenDesign | Discussion: DesktopX Tutorials

How create a Shortcut on DX (advanced)


A Special thanks goes to sVis for her awesome help to make it a lot of more clear


This tutorial will show you how create an advanced shortcut in DesktopX.
It will have more options than the basic DesktopX shortcut object. I'll show you how to create the object and script. You'll need a little knowledge of scripting and DesktopX. To make it, I have read RomanDA's tutorials which you can find here:
RomanDA articles

You should, at each step of this tutorial, see the picture for more information.


Create the Object

First right click on DesktopX Builder systray icon and select "create object"...



Summary Information

Then, in the object's properties in the "Summary" tab, enter the author name (guess it's you). Set the width to 50 and height to "follow aspect ratio". This is so that all the pictures of your shortcut will only be 50px). Finally, set the object ID.

_________


Add a Custom file

No no, it's not finished yet. Now you need to add the main picture of your object.
Go to "custom files" in the "Summary" tab and then click "add".
Browse for your picture. Here it's the earth. ''('''Note:''' Remember the full name of the image file, you'll need it in future.)''
Here it's "Blue + Black Internet 1.png"

_________


Add States

Now, you'll add some states. In the "States" tab, click on add.



Then, select "mouse away", "mouse over", " mouse down", and "Nothing". To make the "Nothing" state simply edit the name of the state.



In these states, change the appearance to the same picture that you embedded earlier. ("Blue + Black Internet 1.png") It can be found in the drop down menu.



Then, add some effects in the "color" tab. Here I set the brightness to 50 on "mouse over" and 30 on "mouse down", same for the contrast.

_______________


Apply and save. In case of an error you should keep a good copy of the object.




Create the Script

First go to Object Properties and in the "General" tab click on "new" script.



The first part of the script are the OnScriptEnter, OnScriptExit functions.
These will be called on when the widget first runs and when the widget closes. This script will call other functions for saving and loading user settings explained later.

SCRIPT CODE
'Call on script enter
Sub Object_OnScriptEnter
Call LoadSettings()
Object.SetTimer 1000, 2000
Call setinfo
End Sub

'Call on script exit
Sub Object_OnScriptExit
Call SaveSettings()
object.KillTimer 1000
End Sub


Right Click Menu

_________



This script for the right click menu will allow the user to choose an image for the shortcut's icon, and the ability to choose between a file, folder or url as the shortcut's target.


SCRIPT CODE
 
Dim foldername
Dim Icon
Dim target

'Function to set the right click on the object
Function Object_OnRButtonUp(x,y,dragged)
If Not dragged Then
Dim menu
Set menu = DesktopX.CreatePopupMenu
menu.AppendMenu 0, 1, "Select Icon"
menu.AppendMenu 0, 2, "Select File"
menu.AppendMenu 0, 3, "Select Folder"
menu.AppendMenu 0, 4, "Select URL"
Dim rtn
rtn = menu.TrackPopupMenu(0, System.CursorX, System.CursorY)
Select Case rtn
Case 1
Object.States("Mouse away").picture="Blue + Black Internet 1.png"
Object.States("Mouse over").picture="Blue + Black Internet 1.png"
Object.States("Mouse down").picture="Blue + Black Internet 1.png"
Set Sh = CreateObject("WScript.Shell")
On Error Resume Next
Foldername = Desktopx.ExecutableDirectory
Icon = System.FileOpenDialog("Select a Picture....", "", Folder, "Pictures: jpg,bmp,png|*.jpg;*.bmp;*.png", 0)
If Icon<>"" Then
Object.States("Mouse away").picture=icon
Object.States("Mouse over").picture=icon
Object.States("Mouse down").picture=icon
End If
Set Sh = Nothing
Case 2
Object.States("Nothing").picture="Blue + Black Internet 1.png"
Set Sh = CreateObject("WScript.Shell")
On Error Resume Next
Foldername = Desktopx.ExecutableDirectory
target = object.command
x = (System.FileOpenDialog("Select a File...", "", Folder, "All files|*.*", 0))
If x <> "" Then
Object.States("Nothing").picture = x
End If
Set Sh = Nothing
Case 3
Object.States("Nothing").picture="Blue + Black Internet 1.png"
Set Sh = CreateObject("WScript.Shell")
On Error Resume Next
target = object.command
x = (System.FolderDialog("Select a Folder...", "",&H4000))
If x <> "" Then
Object.States("Nothing").picture = x
End If
Set Sh = Nothing
Case 4
Object.States("Nothing").picture="Blue + Black Internet 1.png"
Set Sh = CreateObject("WScript.Shell")
On Error Resume Next
target = object.command
Dim Input
Input = InputBox("Enter URL: ex: 'https://www.wincustomize.com' or an email ex: 'mailto:[email protected]'", "Select URL...")
x= Input
If x <> "" Then
Object.States("Nothing").picture = x
End If
Set Sh = Nothing
End Select
Set menu = nothing
End If
If rtn <> 5 Then
Object_OnRButtonUp=True
End If
End Function


You can see the entire right-click menu code above. I'll explain some of the parts.

Case 1 is the part of the code that changes the picture of the shortcut on all object states: "mouse away", "mouse over", and "mouse down". ''('''Note:''' "nothing" state will be for another function)''

"System.FileOpenDialog" will open a dialog window to choose the file. "Select a Picture...." will be the title of the dialog window. "Pictures: jpg,bmp,png|*.jpg;*.bmp;*.png" will allow the user to browse for those types of files only.

In Case 2,3, and 4, the first line will recall the main settings of the object in error case. Object.States("Nothing").picture="Blue + Black Internet 1.png"
then the target is as set on left click
target = Object.States("Nothing").picture
and there it's the "target = object.command"
So to explain once you'll set a target the address of this one will be copy
on the "Nothing" state and in this three case as object.command too


Case 2 will open the file dialog:

x = (System.FileOpenDialog("Select a File...", "", Folder, "All files|*.*", 0))
If x <> "" Then
Object.States("Nothing").picture = x




Case 3 will open the folder file dialog:

x = (System.FolderDialog("Select a Folder...", "",&H4000))
If x <> "" Then
Object.States("Nothing").picture = x




Case 4 will open the URL/EMAIL inputbox:

Dim Input
Input = InputBox("Enter URL: ex: 'https://www.wincustomize.com' or an email ex: 'mailto:[email protected]'", "Select URL...")
x= Input
If x <> "" Then
Object.States("Nothing").picture = x




Save/Load User Settings

This is where you'll save and load the information of the object stored in the "dim" variables 'foldername', 'Icon', 'target'.

SCRIPT CODE
 
'will save the stteings of the object
Function SaveSettings()
Set Sh = CreateObject("WScript.Shell")
Sh.RegWrite "HKCU\SOFTWARE\desktopx\iconchanger\folder", foldername
Sh.RegWrite "HKCU\SOFTWARE\desktopx\iconchanger\icon", Icon
Sh.RegWrite "HKCU\SOFTWARE\desktopx\iconchanger\target", target
Sh.RegWrite "HKCU\SOFTWARE\desktopx\iconchanger\x", x
Set Sh = Nothing
End Function

'will load the settings
Function LoadSettings()
foldername = Desktopx.ExecutableDirectory
On Error Resume Next
Set Sh = CreateObject("WScript.Shell")
FolderName = Sh.RegRead("HKCU\SOFTWARE\desktopx\iconchanger\folder")
Icon = Sh.RegRead("HKCU\SOFTWARE\desktopx\iconchanger\icon")
target = Sh.RegRead("HKCU\SOFTWARE\desktopx\iconchanger\target")
x = Sh.RegRead("HKCU\SOFTWARE\desktopx\iconchanger\x")
Set Sh = Nothing
Err.Clear
End Function


Tooltip

In this code you'll script the object's tooltip:

SCRIPT CODE
  'will call on a fix time setinfo
Sub Object_OnTimer1000
Call setinfo
End Sub

'will when call set the tooltips with the complet address of the shortcut
Sub setinfo
object.ToolTipText=(Object.States("Nothing").picture)
End Sub


Launch the Shortcut

This script will launch the shortcut when you left click on the object. If it's an image it will open it on your default picture's editor. The address of the shortcut is on the "Nothing" state:

"target = Object.States("Nothing").picture"


SCRIPT CODE
 
'function to set the left click on the object
Function Object_OnLButtonUp(x,y,dragged)
If Not dragged Then
On Error Resume Next
Set Sh = CreateObject("WScript.Shell")
target = Object.States("Nothing").picture
Sh.Run (Chr(34)& target & Chr(34))
Set Sh = Nothing
End If
End Function




Well now you'll need to save your work and export it as object/widget or gadget or add it to a theme. Whatever you want!

I hope this tutorial has been helpful.
Quentin
My page
ArileenDesign
Reply #1 Wednesday, July 18, 2007 8:42 AM
I hope all is clear


maybe not
well i try
sViz
Reply #2 Wednesday, July 18, 2007 10:31 AM
Hey, Q. I could figure it out but I could help you make the format clearer in the wiki if you like.  
ArileenDesign
Reply #3 Wednesday, July 18, 2007 10:40 AM
well i love learn hehe thanks sVis i would like it
SirSmiley
Reply #4 Wednesday, July 18, 2007 12:14 PM
Nice work Q but, take sViz up on the offer!

Maybe compress/size your images a bit better, the load time was awful for me.
ArileenDesign
Reply #5 Wednesday, July 18, 2007 12:20 PM
Nice work Q but, take sViz up on the offer!

Maybe compress/size your images a bit better, the load time was awful for me.


i take it and i'll edit it this night after my daughter birthday's party
and i'll made thumbs in place of the full images thanks Sirsmiley

AND a SPECIAL thanks to you sVis you are amazing my dear you have made a wonderful job to rebuild it
RomanDA
Reply #6 Wednesday, July 18, 2007 12:30 PM
look good Quentin... good work.
ArileenDesign
Reply #7 Wednesday, July 18, 2007 5:52 PM
thanks RomanDA

now it looks a lot better thanks to sVis
sViz
Reply #8 Wednesday, July 18, 2007 6:04 PM
No problem, Q.    Just did one last minor change on the wiki; you can see which parts in the ATOM reader.

This is a great tutorial, nice work!  
ArileenDesign
Reply #9 Wednesday, July 18, 2007 6:16 PM
No problem, Q. Just did one last minor change on the wiki; you can see which parts in the ATOM reader.

This is a great tutorial, nice work!


Thanks

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01