Page 2 of 2 <12
Topic Options
#198803 - 2010-06-08 04:33 PM Re: Pinning Shortcuts to taskbar Windows7 [Re: Mart]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Thanks Mart. Post Modified.
Top
#198804 - 2010-06-08 04:35 PM Re: Pinning Shortcuts to taskbar Windows7 [Re: Mart]
Darknoon Offline
Fresh Scripter

Registered: 2005-03-24
Posts: 9
Copy/paste error ! lol
Working now for me.
THX a lot !


Edited by Darknoon (2010-06-08 04:36 PM)

Top
#198805 - 2010-06-08 04:59 PM Re: Pinning Shortcuts to taskbar Windows7 [Re: Darknoon]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
And the fun continues.

I'm on English Win7 with the regional settings set to Dutch.
@userlang returns 0413Dutch and @syslang returns 0409English. I'm not using it but only testing and messing around a bit but the script above does not work for me. Not done testing yet but I guess it will work just fine without the language checks and let it assume the OS is English.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#198806 - 2010-06-08 05:03 PM Re: Pinning Shortcuts to taskbar Windows7 [Re: Mart]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
From this to this in 2 secs...
\:\)

I got an idea.

Top
#198807 - 2010-06-08 06:16 PM Re: Pinning Shortcuts to taskbar Windows7 [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
I think I'm going to need to rework this, and I know it has issues if the pinned icon already exists... but I'd be interested to know if this works for you guys now.

 Code:
Function PinTo($Shortcut, optional $Action)
  dim $Languages[2]
  $Languages[0]="0409English,Pin to Taskbar,Pin to Start Menu"
  $Languages[1]="0407German,An Taskleiste anheften,An Startmenü anheften"
  $Languages[2]="040CFrench,Épingler à la barre des tâches,Épingler au menu Démarrer"

  dim $path,$objshell,$objfolder,$objFolderitem,$colverbs,$objverb,$location,$langid,$dothis,$i
  $PinTo=1
  if not right($shortcut,3)="lnk"
    $shortcut=$shortcut + ".lnk"
  endif 
  if exist($shortcut)
    if getfileattr($shortcut) & 16
      exit 87
    else
      $path=left($shortcut,instrrev($shortcut,"\"))
      $shortcut=right($shortcut,-instrrev($shortcut,"\"))  
    endif
  else
    exit 2
  endif
  $objShell=CreateObject("Shell.Application")		
  $objFolder=$objShell.Namespace($path)
  $objFolderItem=$objFolder.ParseName($shortcut)
  $colVerbs=$objFolderItem.Verbs
  for each $objVerb In $colVerbs
    if instr(@producttype,"Windows 7") and ($action="" or $action="Taskbar")
      for $i=0 to ubound($languages)
        if split($languages[$i],",")[1]=join(split($objVerb.name,'&'),'')
          $dothis=join(split($objVerb.name,'&'),'')
          $location="\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\" + $shortcut
          $objVerb.DoIt
        endif
      next
    else
      for $i=0 to ubound($languages)
        if split($languages[$i],",")[2]=join(split($objVerb.name,'&'),'')
          $dothis=join(split($objVerb.name,'&'),'')
          $location="\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\" + $shortcut
          $objVerb.DoIt
        endif
      next
    endif
  next
  if $dothis and $location	
    if exist($objShell.Namespace(26).self.path + $location)
      $PinTo=0
    else
      exit 82					 
    endif
  else
    exit 1815
  endif
endFunction


Top
#198809 - 2010-06-09 06:41 AM Re: Pinning Shortcuts to taskbar Windows7 [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Here's the latest... wow what a pain. My poor brain was not working tonight...

Give it a whirl and let me know.

 Code:
Function PinTo($Shortcut, optional $Action)
  dim $path,$objshell,$objfolder,$objFolderitem,$colverbs,$objverb,$verbfound,$location
  dim $TaskbarCaptions,$StartMenuCaptions

  $TaskbarCaptions = "Pin to Taskbar,An Taskleiste anheften,Épingler à la barre des tâches"

  $StartMenuCaptions="Pin to Start Menu,An Startmenü anheften,Épingler au menu Démarrer"

  $PinTo=1
  if not right($shortcut,3)="lnk"
    $shortcut=$shortcut + ".lnk"
  endif 
  if exist($shortcut)
    if getfileattr($shortcut) & 16
      exit 87
    else
      $path=left($shortcut,instrrev($shortcut,"\"))
      $shortcut=right($shortcut,-instrrev($shortcut,"\"))  
    endif
  else
    exit 2
  endif
  $objShell=CreateObject("Shell.Application")		
  $objFolder=$objShell.Namespace($path)
  $objFolderItem=$objFolder.ParseName($shortcut)
  $colVerbs=$objFolderItem.Verbs
  
  for each $objVerb In $colVerbs
    if instr(@producttype,"Windows 7") and ($action="" or $action="Taskbar")
      $location=$objShell.Namespace(26).self.path + "\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\" + $shortcut
      if exist($location) and $verbfound=0
        exit 80
      else
        if instr($TaskbarCaptions,join(split($objVerb.name,'&'),'')) and $objVerb.name<>""
          $verbfound=1
          $objVerb.DoIt
          if exist($location)
            $PinTo=0
          endif
        endif
      endif
    else
      $location=$objShell.Namespace(26).self.path + "\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\" + $shortcut
      if exist($location) and $verbfound=0
        exit 80
      else
        if instr($StartMenuCaptions,join(split($objVerb.name,'&'),''))  and $objVerb.name<>""
          $verbfound=1
          $objVerb.DoIt
          if exist($location)
            $PinTo=0
          endif
        endif
      endif
    endif
  next
  if $verbfound=0
    exit 1815
  endif
endFunction

Top
#198815 - 2010-06-09 09:22 AM Re: Pinning Shortcuts to taskbar Windows7 [Re: Allen]
Darknoon Offline
Fresh Scripter

Registered: 2005-03-24
Posts: 9
Hi ! \:\)
Working for me ! good brain ! lol ;\)

Top
#198818 - 2010-06-09 10:33 AM Re: Pinning Shortcuts to taskbar Windows7 [Re: nocke62]
nocke62 Offline
Fresh Scripter

Registered: 2005-03-30
Posts: 12
Loc: Ratingen, Germany
Hello Allen,

this script works fine.
Many thanks for your support.

Regards,
Wolfgang

Top
#198826 - 2010-06-09 03:37 PM Re: Pinning Shortcuts to taskbar Windows7 [Re: nocke62]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Great (and surprising to hear ). Amazing what a little sleep will do... latest version is published to the UDFs now.

PinTo() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=198825#Post198825

Top
#198827 - 2010-06-09 03:41 PM Re: Pinning Shortcuts to taskbar Windows7 [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
@nocke and @darknoon
Might you guys be willing to right click on one of your existing icons on the taskbar and Start Menu and give me the "Unpin ..." strings in your language?

Top
#198829 - 2010-06-09 04:29 PM Re: Pinning Shortcuts to taskbar Windows7 [Re: Allen]
Darknoon Offline
Fresh Scripter

Registered: 2005-03-24
Posts: 9
OK for the unpin function ... ;\)
unpin from startmenu : "Détacher du menu Démarrer"
unpin from taskbar : "Détacher ce programme de la barre des tâches"

Top
#198830 - 2010-06-09 06:08 PM Re: Pinning Shortcuts to taskbar Windows7 [Re: Darknoon]
nocke62 Offline
Fresh Scripter

Registered: 2005-03-30
Posts: 12
Loc: Ratingen, Germany
@Allen
I'll send you tomorrow.

Top
#198833 - 2010-06-10 11:57 AM Re: Pinning Shortcuts to taskbar Windows7 [Re: nocke62]
nocke62 Offline
Fresh Scripter

Registered: 2005-03-30
Posts: 12
Loc: Ratingen, Germany
Here are the German text:

unpin from taskbar: "Von Taskleiste lösen
unpin from startmenu : "Vom Startmenü lösen"

Top
#198947 - 2010-07-05 02:57 PM Re: Pinning Shortcuts to taskbar Windows7 [Re: nocke62]
FabienDupont Offline
Just in Town

Registered: 2008-01-23
Posts: 1
Loc: Toulouse, France
Here are the two functions I use. They are adapted from some vbscripts.

 Code:
; Detache un programme a la superbar
function unpintotaskbar($file)
        ; Decoupage file en dir + filename
        $filename = substr($file, instrrev($file, "\") + 1)
        $dirname  = substr($file, 1, instrrev($file, "\") - 1)
        ; Clic sur "Epingler ..."
        $objShell = CreateObject("Shell.Application")
        $objFolder = $objShell.Namespace($dirname)
        $objFolderItem = $objFolder.ParseName($filename)
        $colVerbs = $objFolderItem.Verbs
        For Each $objVerb in $colVerbs
                if Replace($objVerb.name, "&", "") = "Détacher de la barre des tâches"
                        $objVerb.DoIt
                endif
        Next
endfunction

; Attache un programme a la superbar
function pintotaskbar($file)
        ; Decoupage file en dir + filename
        $filename = substr($file, instrrev($file, "\") + 1)
        $dirname  = substr($file, 1, instrrev($file, "\") - 1)
        ; Clic sur "Epingler ..."
        $objShell = CreateObject("Shell.Application")
        $objFolder = $objShell.Namespace($dirname)
        $objFolderItem = $objFolder.ParseName($filename)
        $colVerbs = $objFolderItem.Verbs
        For Each $objVerb in $colVerbs
                if Replace($objVerb.name, "&", "") = "Épingler à la barre des tâches"
                        $objVerb.DoIt
                endif
        Next
endfunction


Of course, "Épingler à la barre des tâches" and "Détacher de la barre des tâches" are for french language.
The following function lists all verbs for a program, so you can easily find the correct one in your language :

 Code:
function listVerbs($file)
        ; Decoupage file en dir + filename
        $filename = substr($file, instrrev($file, "\") + 1)
        $dirname  = substr($file, 1, instrrev($file, "\") - 1)
        ; Clic sur "Epingler ..."
        $objShell = CreateObject("Shell.Application")
        $objFolder = $objShell.Namespace($dirname)
        $objFolderItem = $objFolder.ParseName($filename)
        $colVerbs = $objFolderItem.Verbs
        For Each $objVerb in $colVerbs
                ? $objVerb
        Next
endfunction


Hope this helps.


Edited by FabienDupont (2010-07-06 06:15 PM)

Top
#198952 - 2010-07-07 08:23 AM Re: Pinning Shortcuts to taskbar Windows7 [Re: Allen]
ghdfans2010 Offline
Just in Town

Registered: 2010-07-07
Posts: 2
Loc: Alabama
 Originally Posted By: Allen
If I had to guess it's probably the lauguage differences in OSs.

If you right click on an icon in Win7 you get two options in English, "Pin to Taskbar" and "Pin to Start Menu". Your language is probably different. You might try changing the action lines in the UDF to match what you have.

 Code:
  if instr(@producttype,"Windows 7") and ($action="" or $action="Taskbar")
    $action="Pin to Taskbar"
    $location="\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\" + $shortcut
  else
    $action="Pin to Start Menu"
    $location="\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\" + $shortcut
  endif



very good! thanx Allen. U help me a lot!

Top
#198956 - 2010-07-07 02:41 PM Re: Pinning Shortcuts to taskbar Windows7 [Re: ghdfans2010]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Alabama? Does Southern English qualify as it's own language now? ;\)

Seriously, if you have a language not covered by the PinTo UDF please post.

 Quote:

If you would like this UDF to support your language please submit the following items.

Your Language (in English)
Right Click on an Icon
"Pin to Taskbar" string (in your language)
"Pin to Start Menu" string (in your language)

I will update as time permits.

Thanks.


The most current version of the PinTo() UDF is here (all the versions above are old):
PinTo() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=197722#Post197722



Edited by Allen (2010-07-07 02:53 PM)

Top
Page 2 of 2 <12


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 675 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.071 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org