User tasks in Windows 7 and applications

    The article was added by Debbie M. at 01/27/2010.

  Submit | About | Contact & Privacy Policy

You are here: Articles Directory » Windows 7

Bookmark and Share User Tasks User tasks despite their name are additional tasks that can be placed in your application’s Jump List. These are verbs that can invoke your application or any other application, and they’re usually r

User tasks despite their name are additional tasks that can be placed in your application’s Jump List. These are verbs that can invoke your application or any other application, and they’re usually represented by IShellLink objects. After you’ve mastered the intricate details of adding categorized destinations to the Jump List, user tasks are much easier to grasp.

Note Because user tasks are not connected to an existing application instance, it makes sense to set them up during application installation. To do this, you can either ensure that your installer has the same AppID as the application itself, or you can launch an auxiliary application from within the installer that claims the same AppID and creates the user tasks. (This auxiliary application could also be your main application with a “quiet-mode” switch that creates the tasks and exits without displaying UI.)

You need the ICustomDestinationList interface if you’re working from native code. After beginning a list-building transaction (with BeginList), you can use the AddUserTasks method to add a collection of tasks usually represented by an IObjectCollection containing IShellLink objects.

As you might remember, the task list can contain separators that group related tasks. To add a separator, create an IShellLink object and use the IPropertyStore interface to set its System.AppUserModel.IsDestListSeparator property to TRUE. This object can then be added to the Jump List along with the rest of the tasks.

The managed equivalent for adding user tasks is the JumpList.AddUserTasks method, which accepts JumpListLink, JumpListItem, and JumpListSeparator objects and adds them to the underlying tasks collection. The following code snippet, which displays both the native and managed code, demonstrates how to add a few user tasks to the application’s Jump List:

   //C++:
   ICustomDestinationList* pJumpList = NULL;
   if (FAILED(CoCreateInstance(
   CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pJumpList))))
   goto Cleanup;
   if (FAILED(pJumpList->SetAppID(L"Microsoft.Samples.MyApplication")))
   goto Cleanup;
   UINT uMaxSlots;
   IObjectArray* pRemoved = NULL;
   if (FAILED(pJumpList->BeginList(&uMaxSlots, IID_PPV_ARGS(&pRemoved))))
   goto Cleanup;
   IObjectCollection* pContents = NULL;
   if (FAILED(CoCreateInstance(
   CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pContents))))
   goto Cleanup;
   IShellLink* pLink = NULL;
   IPropertyStore* pStore = NULL;
   PROPVARIANT var;
   //Create a simple link to calc.exe:
   if (FAILED(CoCreateInstance(CLSID_ShellLink, NULL,
   CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pLink))))
   goto Cleanup;
   if (FAILED(pLink->SetPath(L"C:\\Windows 7\\System32\\calc.exe")))
   goto Cleanup;
   if (FAILED(pLink->QueryInterface(IID_PPV_ARGS(&pStore))))
   goto Cleanup;
   InitPropVariantFromString(L"Launch Calculator", &var);
   if (FAILED(pStore->SetValue(PKEY_Title, var)))
   goto Cleanup;
   if (FAILED(pStore->Commit()))
   goto Cleanup;
   if (FAILED(pContents->AddObject(pLink)))
   goto Cleanup;
   pStore->Release(); pStore = NULL;
   pLink->Release(); pLink = NULL;
   //Create a separator link:
   if (FAILED(CoCreateInstance(CLSID_ShellLink, NULL,
   CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pLink))))
   goto Cleanup;
   if (FAILED(pLink->QueryInterface(IID_PPV_ARGS(&pStore))))
   goto Cleanup;
   InitPropVariantFromBoolean(TRUE, &var);
   if (FAILED(pStore->SetValue(PKEY_AppUserModel_IsDestListSeparator, var)))
   goto Cleanup;
if (FAILED(pStore->Commit()))
 goto Cleanup;
 if (FAILED(pContents->AddObject(pLink)))
 goto Cleanup;
 //Create a simple link to notepad.exe:
 if (FAILED(CoCreateInstance(CLSID_ShellLink, NULL,
 CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pLink))))
 goto Cleanup;
 if (FAILED(pLink->SetPath(L"C:\\Windows 7\\System32\\notepad.exe")))
 goto Cleanup;
 if (FAILED(pLink->QueryInterface(IID_PPV_ARGS(&pStore))))
 goto Cleanup;
 InitPropVariantFromString(L"Launch Notepad", &var);
 if (FAILED(pStore->SetValue(PKEY_Title, var)))
 goto Cleanup;
 if (FAILED(pStore->Commit()))
 goto Cleanup;
 if (FAILED(pContents->AddObject(pLink)))
 goto Cleanup;
 IObjectArray* pContentsArr = NULL;
 if (FAILED(pContents->QueryInterface(IID_PPV_ARGS(&pContentsArr))))
 goto Cleanup;
 if (FAILED(pJumpList->AddUserTasks(pContentsArr)))
 goto Cleanup;
 pJumpList->CommitList();
 Cleanup:
 if (pLink != NULL)
 pLink->Release();
 if (pStore != NULL)
 pStore->Release();
 if (pContentsArr != NULL)
 pContentsArr->Release();
 if (pContents != NULL)
 pContents->Release();
 if (pRemoved != NULL)
 pRemoved->Release();
 if (pJumpList != NULL)
 pJumpList->Release();
 //C#:
 JumpList jumpList = JumpList.CreateJumpList();
 jumpList.AddUserTasks(
 new JumpListLink(@"C:\Windows 7\System32\Calc.exe", "Launch Calculator"),
 new JumpListSeparator(),
 new JumpListLink(@"C:\Windows 7\System32\Notepad.exe", "Launch Notepad"));
 jumpList.Refresh();

Unlike custom destinations, tasks cannot be removed from the Jump List by the user, nor can they be pinned to the list. Tasks receive an additional preference when there’s not enough room in the Jump List they are trimmed last so that only the space that remains after displaying all user tasks can be used by the rest of the Jump List categories.

Users expect the user tasks area of the Jump List to remain static. The state of the application should not affect the list of user tasks, especially because the application might shut down unexpectedly, leaving the Jump List in an undesired state. Nonetheless, there are some applications including Windows 7 Live Messenger that use contextual user tasks, such as Sign In and Sign Out, with great success.

Windows 7 Disclaimer

  • The ArticleCity.info articles directory team is not responsible for falsehoods, inaccuracies, or any other types of misinformation this article may contain and will not be liable for any damage or loss suffered by a user through the user's reliance on the information gained here.
  • ArticleCity.info articles directory is not responsible for any and all copyright infringements by writers and authors. If you suspect the information contained by this page for any copyright infringements, please contact us and we'll investigate the specific article(s) and we will remove the copyrighted material.
Other Windows 7 articles
Locating and Use Files and Folders in Windows 7 - Locate and Use Files and Folders The purpose of a file system, of course, is to locate and use the files and folders on your computer, and possibly on other computers connected to yours. Within your computer, there is...
Encrypt files and folders and cleaning disks in Windows 7 - Encrypt Files and Folders Windows 7 Professional, Enterprise, and Ultimate editions, but not Windows 7 Starter, Home Basic, or Home Premium editions, have the ability to encrypt files and folders so that they canno...
Windows 7 How to connect to the Internet Step by Step - Connect to the Internet You can connect to the Internet using a telephone line, a cable TV connection, a satellite link, or a land-based wireless link. Across these various types of connections there are a myriad o...
Windows 7 does not include a mail program use Windows Live - Use Internet Email Windows 7 does not include a mail program, but you can download Windows Live Mail...
Internet connection types available for connecting to Internet - TYPES OF INTERNET CONNECTIONS The following Internet connection type descriptions give you a starting place for determining the type you want, if it is available to you. The speeds and costs are representative averages and ...
The Windows 7 Shell populates and manages the Recent and Frequent destination - The Windows 7 Shell populates and manages the Recent and Frequent destination categories. Simple mechanisms govern the definition of what a recent or frequent item might be and performing integration tasks with these mechanisms does not require...
Recent and Frequent destination categories provided by the Windows 7 Shell - Custom Destinations If the default Recent and Frequent destination categories provided by the Windows 7 Shell are not enough for your application, you’ll want to create custom categories and store your destinations within them....
Windows 7 Thumbnail toolbars are an exceptional productivity feature - Thumbnail Toolbars Thumbnail toolbars are an exceptional productivity feature that gives users the ability to do more with the application’s thumbnail without switching to the application’s window and interrupting t...
Customizing Windows 7 Thumbnail ToolTips - Customizing Thumbnails One of the most visually stunning features of the Windows 7 7 desktop is the multiple live thumbnails shown for each taskbar button (as shown in the following screen shot). The new taskbar thumbnails are mu...
Thumbnail Dimensions in Windows 7 - Thumbnail Dimensions The lParam parameter received by the window procedure for the WM_DWMSETICONICTHUMBNAIL message specifies the width and height of the requested thumbnail the width is the high-order word, and the height is t...