It is absolutely correct to have the commas where you placed them. I explain below.
In part of my spare time, I work on fun projects.
"In part of my spare time" is an adverbial phrase and in formal contexts, I would definitely retain the comma, as it precedes the subject of the sentence. A comma should always be used in this way, but it is sometimes acceptable to omit it when the adverbial is short enough that leaving out the comma will not hamper the reader's grasp of the intended meaning. Thus, a sentence such as
Occasionally I work on fun projects
is acceptable in informal contexts. However, one is more likely to find a comma inserted in formal situations:
Occasionally, I work on fun projects
Now, to the second sentence:
When I have spare time, I work on fun projects.
"When I have spare time" is a dependent clause, or more specifically, an adverbial clause. As it precedes the independent clause, it should be followed by a comma. Again, it is possible in some contexts to leave out the comma when the preceding independent or adverbial clause is short enough that leaving it out would not obscure the intended meaning, but contexts such as these are hard to find. In publications like novels or magazines, one might readily find a construction such as this:
When he comes we are going to have a ball
This reads easily without a comma. Consider this, though:
When the sky is darkened on many a stormy night, I curl up beside my lamp
and read my son to sleep
It would be difficult to argue for the omission of a comma in this case.
The comma also indicates a pause in communication. The writer can thus choose to insert it or leave it out to create the desired effect. You could bear this in mind while deciding on your commas. Include them where you feel a pause makes sense.
What is the difference between "Are you sure to xxx?" and "Do you sure to xxx?"
Both don't really make much sense. "Do you sure to ..." is simply incorrect, whereas you can say "be sure to do something", meaning "don't forget to do it" (e.g. be sure to lock the door before you go to bed), yet this is also not how you would phrase things in the context of asking a user to confirm an action.
E.g. I want to confirm the user whether to delete a file, Should I use "Are you sure to delete this file?" or "Do you sure to delete this file?
What you want to ask is "Are you sure you want to xxx?". In your case this would be "Are you sure you want to delete this file?"
Edit: As @BoldBen points out, this phrase might be a little long. Something like "Are you sure?" or "Really delete file?" is probably better.
Best Answer
Yes, use the comma. It makes the sentence clearer than if there's no comma. Sometimes commas are unnecessary, and sometimes they help. In this case, I had to read the comma-less sentence twice to separate item and click. Readers don't like have to read the same thing twice to be able to understand it. If what you're saying is inherently difficult to understand, that's one thing, and the readers have to deal with their own intellectual limits. But if it's merely a matter of writing mechanics and punctuation, it's your job as a technical writer to make everything you write as clear and as easy to understand as possible. That's what I try to do all day long.