当前位置: 首页 > news >正文

大余做网站公司厦门人才网个人登录

大余做网站公司,厦门人才网个人登录,建设互联网站,惠州建设网站1、准备ico格式图标 star_bethlehem_icon 文件名改为star.ico 2、安装VSCode 如何下载安装VSCode 扩展:PowerShell扩展 3、创建项目 1、运行PowerShell命令 mkdir trayicon_ps1;cd trayicon_ps1;New-Item trayicon.ps1;code .2、将star.ico放入trayicon_ps1文…

1、准备ico格式图标

star_bethlehem_icon
在这里插入图片描述
文件名改为star.ico

2、安装VSCode

如何下载安装VSCode
扩展:PowerShell扩展

3、创建项目

1、运行PowerShell命令

mkdir trayicon_ps1;cd trayicon_ps1;New-Item trayicon.ps1;code .

2、将star.ico放入trayicon_ps1文件夹

4、修改trayicon.ps1的编码

选择文件trayicon.ps1
点击右下角UTF-8
在这里插入图片描述
选择通过编码保存
在这里插入图片描述
选择UTF-8 with BOM
在这里插入图片描述

5、编辑trayicon.ps1

# 脚本文件编码为UTF8 with BOM才能支持中文# 加载WinForms程序集
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName PresentationFramework# 图标文件路径要使用完整的路径。
$iconPath = "$(Get-Location)/star.ico"
$tooltip = "这是文字"# 右键菜单
$contextMenu = [System.Windows.Forms.ContextMenuStrip]::new()$menuItemMsg = [System.Windows.Forms.ToolStripMenuItem]::new()
$menuItemMsg.Text = "弹出消息框"
$menuItemMsg.add_Click({ [System.Windows.MessageBox]::Show('这是消息框') })
$null = $contextMenu.Items.Add($menuItemMsg)$menuItemExit = [System.Windows.Forms.ToolStripMenuItem]::new()
$menuItemExit.Text = "退出"
$menuItemExit.add_Click({ $script:done = $true }) # 单击菜单项时,将$done设置为$true。
$null = $contextMenu.Items.Add($menuItemExit)# 构造NotifyIcon对象。
$notifyIcon = [System.Windows.Forms.NotifyIcon]::new()
$notifyIcon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($iconPath)
$notifyIcon.Text = $tooltip
$notifyIcon.Visible = $true
$notifyIcon.ContextMenuStrip = $contextMenu
$notifyIcon.add_Click({ param($evtSender, $evtArgs)if ($evtArgs.Button -eq [System.Windows.Forms.MouseButtons]::Left){[System.Windows.MessageBox]::Show("单击了图标")}
})# 定义一个变量,该变量表示是否应退出脚本,并从add_Click()事件处理程序设置为$true。
$done = $falseWrite-Verbose -Verbose @"
Adding a PowerShell icon to notification area (system tray).
Use the icon's context menu to quit this script, 
or press Ctrl-C in the console window.
"@# Loop
try {while (-not $done) {# 使WinForms处理其事件。[System.Windows.Forms.Application]::DoEvents()# 睡一会儿,保持用户界面的响应。# 理论上可以在这里执行其他任务,只要它们快速完成,以便仍然允许足够频繁的DoEvents()调用。Start-Sleep -MilliSeconds 100}
}
finally {# 处理通知图标,删除图标。$notifyIcon.Dispose()Write-Verbose -Verbose 'Exiting.'
}

6、最终效果

点击右上角三角图标运行脚本
在这里插入图片描述
鼠标悬浮效果
在这里插入图片描述
鼠标单击效果
在这里插入图片描述
鼠标右键效果
在这里插入图片描述
弹出消息框按钮效果
在这里插入图片描述
退出按钮就是退出,没啥效果

7、不显示powershell窗口的方式

新建start.vbs

set ws=createobject("wscript.shell")
ws.Run "powershell.exe .\trayicon.ps1" , 0, False

双击运行即可

http://www.tj-hxxt.cn/news/11851.html

相关文章:

  • 提供秦皇岛网站建设哪家好做外贸怎么推广
  • 西宁企业网站建设公司网络营销是做什么
  • wordpress怎么滚动图片石狮seo
  • 家具网站模板云浮网站设计
  • 有创意做网站找投资sem工资
  • 网站宣传海报营销策略理论
  • 手机网站制作哪家好好的竞价推广外包公司
  • 网店美工岗位要求神马移动排名优化
  • 十八把网站做扇子天津放心站内优化seo
  • 专门做爬虫的网站营业推广的概念
  • 中山网站建设文化策划书app推广注册从哪里接单
  • 网站建设与开发试题与答案新的网站怎么推广
  • 公司做网站的费用劳动局免费培训项目
  • 北京专业网站制作介绍网络建站工作室
  • 一蓝网站建设seo教程优化
  • 网站怎么防k电脑优化软件哪个好用
  • 贵州网站开发制作公司12345浏览器网址大全
  • 支付网站建设费用做账怎么上百度推广产品
  • 哪些动物可以做网站名病毒营销案例
  • 微信开发app网站内容seo
  • 有专门学做衣服网站有哪些谷歌搜索引擎入口2022
  • 手机ppt在哪个网站做搜索网站
  • 长沙企业建站销售电话新网站百度seo如何做
  • 做爰视频高潮免费网站外贸网站制作推广
  • 平台网站建设源码文件外链
  • 策划设计网站搜索引擎优化是免费的吗
  • 做金融在那个网站上找工作aso优化排名推广
  • 制作手机的游戏上首页的seo关键词优化
  • 新闻资讯网站怎么做优化seo
  • 网站开发需要干什么软文广告推广