其它命令汇总

1.随机获取一张图片,可选择手机端还是pc端。

var https = require("https")

function loadPage(url) {

    var pm = new Promise(function(resolve, reject) {
        https.get(url, function(res) {
            var html = '';
            res.on('data', function(d) {
                html += d.toString()
            });
            res.on('end', function() {
                resolve(html);
            });
        }).on('error', function(e) {
            reject(e)
        });
    });
    return pm;
}

quickcommand.showSelectList(['PC', 'Mobile'])
    .then((x) => {
        var htmlurl = 'https://img.xjh.me/random_img.php?type=bg&ctype=nature&302&device=pc'
        if (x.id == 1) {
            htmlurl = 'https://img.xjh.me/random_img.php?type=bg&ctype=nature&302&device=mobile'
        }
        console.log(htmlurl)
        loadPage(htmlurl).then(function(d) {
            // console.log(d);
            var imgurl = 'https:' + quickcommand.htmlParse(d).querySelector('img').alt
            var idmpath = process.env['UtoolsCoreAssets'] + '/IDM/App/IDMan.exe'
            child_process.exec(`${idmpath} /d "${imgurl}"`)

            quickcommand.showMessageBox('解析成功!')
            quickcommand.setTimeout(() => {
                utools.outPlugin()
            }, 1500)
        });
    })

2.随机获取一个头像。

utools.setExpendHeight(100)
var imgurl = 'https://api.uomg.com/api/rand.avatar'
var idmpath = process.env['UtoolsCoreAssets'] + '/IDM/App/IDMan.exe'
child_process.exec(`${idmpath} /d "${imgurl}"`)

quickcommand.showMessageBox('解析成功!')
quickcommand.setTimeout(() => {
    utools.outPlugin()
}, 1500)

3.将程序添加到开机启动。
powershell脚本


$exePath = "{{MatchedFiles[0].path}}"
$exeFilename = [System.IO.Path]::GetFileNameWithoutExtension($exePath)
$linkFilename = $exeFilename + ".lnk"
$shell = New-Object -ComObject WScript.Shell
$startUpFolder = "$Env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup"

$shortcut = $shell.CreateShortcut("$startUpFolder/$linkFilename")
$shortcut.TargetPath = $exePath
$shortcut.IconLocation = "shell32.dll,23"
$shortcut.Save()

Write-Host "Success Add: " + $exeFilename

4.打开应用所在目录。

import os

app_fullpath = r'{{WindowInfo.appPath}}'
dir = os.path.dirname(app_fullpath)
os.startfile(dir)

5.移除当前目录或子目录指定文件。
powershell脚本
输入正则来删除文件


$pattern = Read-Host "输入正则"
$contain_child = Read-Host "is Recurse?1 yes 2 no"

function RemoveFile($obj,$is_recurse) {
    $fullname = $obj.FullName
    if($fullname -match $pattern){
    	if($is_recurse){
            Remove-Item $fullname -Recurse
        }
        else{
            Remove-Item $fullname
        }
        Write-Host "removed " + $fullname
    }
}

$dir = '{{WindowInfo.title}}'
Write-Host $dir
if($contain_child -eq "1"){
    Get-ChildItem -path $dir -Recurse | ForEach-Object {
        RemoveFile($_,$True)
    }
}
elseif($contain_child -eq "2") {
    Get-ChildItem -path $dir | ForEach-Object {
    	RemoveFile($_,$False)
    }
}

6.使用IDM下载。
指定使用idm进行下载,使用超级面板启动。

import os
import subprocess

url = r'{{input}}'
idm_path = os.environ['UtoolsCoreAssets'] + '/IDM/App/IDMan.exe'
subprocess.call([idm_path,'/d',url])

7.随机一键轮播视频。

import os
import json
import subprocess

mpc_path = '%s/%s' % (os.environ['UtoolsCoreAssets'],'MPC-HC/mpc-hc64.exe')
data_path = '%s/%s' % (os.environ['UtoolsCoreData'],'Data/Path.json')
with open(data_path,'r') as dat:
    lunbo_path = json.loads(dat.read())['lunbo']
    subprocess.call([mpc_path,lunbo_path,'/randomize','/fullscreen'])

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值