#198804 - 2010-06-08 04:35 PM
Re: Pinning Shortcuts to taskbar Windows7
[Re: Mart]
|
Darknoon
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
|
|
|
|
#198806 - 2010-06-08 05:03 PM
Re: Pinning Shortcuts to taskbar Windows7
[Re: Mart]
|
Allen
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
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.
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
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.
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
Fresh Scripter
Registered: 2005-03-24
Posts: 9
|
Hi !  Working for me ! good brain ! lol
|
|
Top
|
|
|
|
#198829 - 2010-06-09 04:29 PM
Re: Pinning Shortcuts to taskbar Windows7
[Re: Allen]
|
Darknoon
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
|
|
|
|
#198947 - 2010-07-05 02:57 PM
Re: Pinning Shortcuts to taskbar Windows7
[Re: nocke62]
|
FabienDupont
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.
; 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 :
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
Just in Town
Registered: 2010-07-07
Posts: 2
Loc: Alabama
|
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.
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 675 anonymous users online.
|
|
|