找回密码
 加入
搜索
查看: 3961|回复: 3

[AU3基础] unping TaskBar解决方案求完善!

[复制链接]
发表于 2015-7-7 19:09:07 | 显示全部楼层 |阅读模式
本帖最后由 heavenm 于 2015-7-7 19:10 编辑

第一种方法,可以解除大多数标准的 任务栏锁定,但是有些就不行 比如PPS或者百度浏览器
#Include <WinAPIEx.au3>
#Include <array.au3>
_pinunpin('C:\Windows\System32\calc.exe','p2tb')
MsgBox(0, '', '解除')
_pinunpin('C:\Windows\System32\calc.exe','up2tb')
Func _pinunpin($filepath, $action = 'p2sm', $arguments = '')
        Local $clean,$pathsplit,$lastp,$file,$path,$filesplit,$last,$fileext,$filename,$code,$linkfile,$hInstance,$localizedstring
        Local $objShell,$objFolder,$objFolderItem
        $clean = 0
        If Not FileExists($filepath) Or @OSBuild < 7600 Then Exit ; to arrange to your liking, SetError() & co

        ;split path, filename and extension
        $pathsplit = StringSplit($filepath, '\')
        $lastp = $pathsplit[0]
        $file = $pathsplit[$lastp]
        $path = StringReplace($filepath, $file, '')
        $path = StringTrimRight($path, 1)
        $filesplit = StringSplit($file, ".")
        $last = $filesplit[0]
        $fileext = $filesplit[$last]
        $filename = StringReplace($file, '.' & $fileext, '', 1)

        ;define code to use depending on action choosen
        Switch $action
                Case 'pin2SM', 'p2sm' ;pin to Start Menu
                        $code = 5381
                Case 'unpinFromSM', 'up2sm' ;unpin from Start Menu
                        $code = 5382
                Case 'pin2TB', 'p2tb' ;pin to Task Bar
                        $code = 5386
                Case 'unpinFromTB', 'up2tb' ;unpin from Task Bar
                        $code = 5387
        EndSwitch

        ;if arguments, make a shortcut, pin it then mark it for deletion
        If $arguments <> '' And $code <> 5382 And $code <> 5387 Then
                $linkfile = @DesktopDir & '\' & $filename & '.lnk'
                FileCreateShortcut($filepath, $linkfile, $path, $arguments, $filename & ' ' & $arguments, $filepath)
                $path = @DesktopDir
                $file = $filename & '.lnk'
                $clean = 1
        EndIf

        ;retrieve Localized text for action
        $hInstance = _WinAPI_LoadLibraryEx('shell32.dll', $LOAD_LIBRARY_AS_DATAFILE)
        If $hInstance Then
                $localizedstring = _WinAPI_LoadString($hInstance, $code)
                ;If @error Then MsgBox(0, "Error", _WinAPI_GetLastErrorMessage()) ;debug
                _WinAPI_FreeLibrary($hInstance)
        EndIf

        ;when unpining from Start Menu, use the shortcut that is effectively pinned to do so, if argument(s) they are ignored
        If $code == 5382 Then
                $path = @UserProfileDir & '\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu'
                $file = $filename & '.lnk'
        EndIf

        ;pin or unpin
        $objShell = ObjCreate('Shell.Application')
        $objFolder = $objShell.Namespace($path)
        $objFolderItem = $objFolder.ParseName($file)
        For $val In $objFolderItem.Verbs()
                If StringInStr($val(), $localizedstring) Then
                        
                        $val.DoIt()
                EndIf
        Next

        ;clean temporary shortcut
        If $clean Then
                FileDelete($linkfile)
        EndIf
EndFunc   ;==>_pinunpin
另一种方法简单
ShellExecute ($_TASKBAR_PATH&'\Internet Explorer.lnk', '','',"taskbarunpin" )
但是存在问题就是如果这个程序没有在任务栏锁定就会弹出错误消息
发表于 2015-7-7 23:04:33 | 显示全部楼层
告诉你一个方法,文件右键是有固定到任务栏的,你安装迅雷,爱奇艺,在安装目录下找vbs 右键编辑做参考,那个脚本是可以执行右键菜单项的,手机上回复!
发表于 2015-7-8 10:16:55 | 显示全部楼层
本帖最后由 wq1282 于 2015-7-8 10:25 编辑
On error resume next
set WshShell = WScript.CreateObject("WScript.Shell")
strWorkingDirectory = "C:\Users\Administrator\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"

Const CSIDL_COMMON_STARTMENU = &H16
Set objShell = CreateObject("Shell.Application")
Set objWorkingDirectory = objShell.NameSpace(strWorkingDirectory)

Set objFolder = objShell.Namespace(objWorkingDirectory) 
Set objFolderItem = objFolder.ParseName("百度浏览器.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
        If Replace(objVerb.name, "&", "") = "从任务栏脱离(K)" Then 
            objVerb.DoIt
    End If
Next
VBS代码测试有效,供参考,请自行转au3,相当于人工手动点快捷方式右键,从任务栏脱离。
你说的像PPS和百度浏览器,一样的道理,进入目录C:\Users\Administrator\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar,找到你要从任务栏解锁的图标右键,从任务栏脱离。然后
将上面脚本的objFolder.ParseName("百度浏览器.lnk")文件名改成实际文件名。
将C:\Users\Administrator\AppData\Roaming替换为@AppDataDir

我参考的原版脚本是来自"迅雷看看播放器"某版本目录下的 taskbar.vbs
奇艺影音\PStyle\PinItem.vbs 函数Function PinItem(strlPath, blnTaskbar, bUninst)更加详细
 楼主| 发表于 2015-7-15 23:58:01 | 显示全部楼层
VBS代码测试有效,供参考,请自行转au3,相当于人工手动点快捷方式右键,从任务栏脱离。
你说的像PPS和百度 ...
wq1282 发表于 2015-7-8 10:16



    一楼用的方法就是右键的方式
但是,不知道为什么 直接点右键就有脱离任务栏
但是用脚本就显示不了
不知道是为什么
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-3 01:17 , Processed in 0.075331 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表