返回列表 发帖
回复 28# jack2020


    同样是win10,运行环境差这么大
26楼重新修改了。调整了切换框框的顺序,这次应该没问题吧。

TOP

回复 30# 77七


    可以用 但是F1-F10键盘失效了  哥咋还原呀  有的时候要用F1-F10键的

TOP

回复 27# 77七


    用了这个代码  F1-F10被这个路径占了   有时候还是要用F-F10   咋还原成初系统始的呀

TOP

回复 32# jack2020


   桌面右下角找到ahk脚本,退出。
或者,既然都用到autohotkey了,可以自定义热键,避免与已有的冲突。
::111::E:\01_项目2024\15_广西2024\03_资料0914
::222::E:\02_项目2024\15_北京2024\03_资料0914
::333::E:\03_项目2024\15_西安2024\03_资料0914COPY


仍然是输入法英文状态下,输入 111按空格,会自动替换。详细可参考 11楼链接。
bat小白,请多指教!谢谢!

TOP

回复 34# 77七


    厉害

TOP

回复 31# ppll2030


    还是不跳框,都在F1,我用27楼代码可以实现了  还是谢谢大佬的代码呀,可能函数底层不同  不兼容呀

TOP

确实可以用bat替代这个软件,系统自带的命令行power
#@&cls&powershell "type '%~0'|out-string|iex"&pause&exit
$list=@(
'C:\01_项目AA2'
'C:\01_项目AA2'
'C:\01_项目AA2'
)
Add-Type -AssemblyName System.Windows.Forms
Add-Type @'
using System;
using System.Runtime.InteropServices;
public class HK
{
    [DllImport("user32.dll")]
    public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
    [DllImport("user32.dll")]
    public static extern bool GetMessage(ref MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
    [StructLayout(LayoutKind.Sequential)]
    public struct MSG
    {
public IntPtr hwnd;
public uint message;
public IntPtr wParam;
public IntPtr lParam;
public uint time;
public int x;
public int y;
    }
}
'@
$define = for($i=0x70; $i -le 0x79; $i++){
[void][HK]::RegisterHotKey(0, $i, 0x4000, $i)
"{0}{{scb '{1}'; {2}; break}}" -f $i, $list[$i-0x70], '[System.Windows.Forms.SendKeys]::SendWait("^v")'
}
$define='switch($msg.wParam){'+($define|out-string)+'}'
$msg = @{}
while([HK]::GetMessage([ref]$msg, 0, 0, 0) -ne 0){if($msg.message -eq 0x0312){iex $define}}COPY
1

评分人数

TOP

回复 37# idwma


    大神    能否写个使用说明  小白表示看不懂

TOP

回复 38# jack2020


    第4行这里按格式修改可以多加几行,保存为bat运行,和这个软件一样按f1-10

TOP

源码是易语言的,没钱用正版,不想用盗版,用C#弄了个差不多的
将下面代码保存为ANSI编码的bat然后运行,运行后会使用系统自带的C#编译器进行编译(有的话)
/*
@echo off&chcp 936&cls&setlocal
set "exename=单功能剪切板.exe"
if exist "%exename%" start "" "%exename%"&exit/b
for /f "delims=" %%a in ('dir /b /ad /o-n "%systemroot%\Microsoft.NET"') do (
for /f "delims=" %%b in ('dir /b /ad /o-n "%systemroot%\Microsoft.NET\%%a"') do (
for /f "delims=" %%r in ('dir /s /b /o-n "%systemroot%\Microsoft.NET\%%a\%%b\csc.exe"') do (
if "%%~xr"==".exe" (
set "csc=%%~fr"
goto :aaa)
)))
echo 找不到C#编译器csc.exe
goto :bbb
:aaa
"%csc%"  /target:winexe /out:"%exename%"  "%~f0"
echo,&timeout /t 1 1>nul
if exist "%exename%" (echo,编译成功,请重新运行此bat或%exename%) else (echo,编译失败)
:bbb
endlocal
echo,&pause&exit /b
*/
using System;
using System.Drawing;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WinFormsApp
{
public class Winapi{
public const int WM_DESTROY=0x0002;
public const int WM_HOTKEY=0x0312;
public const int MOD_NOREPEAT=0x4000;
[DllImport("user32.dll",ExactSpelling=true)]
[return:MarshalAs(UnmanagedType.Bool)]
public static extern bool RegisterHotKey(IntPtr hwnd,int id,uint fsmodifiers,uint vk);
[DllImport("user32.dll",ExactSpelling=true)]
[return:MarshalAs(UnmanagedType.Bool)]
public static extern bool UnregisterHotKey(IntPtr hwnd,int id);
}
public partial class Form999:Form{
private List<Label> lstlb;
private List<TextBox> lsttb;
private List<bool> lsbl;
private Button bt1;
private Button bt2;
private Label lb;
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing){
if (disposing && (components != null)){components.Dispose();}
base.Dispose(disposing);
}
public Form999(){Initial();}//this.bt2.PerformClick();}
public void Initial(){
this.lstlb=new List<Label>(10);
this.lsttb=new List<TextBox>(10);
this.lsbl=new List<bool>(10);
for(int t=0x70;t<0x7a;t++){
lsbl.Add(Winapi.RegisterHotKey(this.Handle,t,Winapi.MOD_NOREPEAT,(uint)t));
}
this.SuspendLayout();
int i=0;
for(int c=0;c<10;c++){
lstlb.Add(new Label());
if((c>4) && (0==i)){i+=1;}
lstlb[c].Size=new Size(30,70);
lstlb[c].Name="lable"+c;
if(c<5){lstlb[c].TextAlign=ContentAlignment.TopRight;}
lstlb[c].Text=String.Format("F{0}",c+1);
lstlb[c].Location=new Point(16+(8+150+60+30+8)*i,70*(c%5)+8*(c%5+1));
lsttb.Add(new TextBox());
if((c>4) && (0==i)){i+=1;}
lsttb[c].Size=new Size(150,70);
lsttb[c].Name="textbox"+c;
lsttb[c].TabIndex=i;
lsttb[c].BorderStyle=BorderStyle.FixedSingle;
lsttb[c].Multiline=true;
lsttb[c].Location=new Point(16+30+8+(150+60+30+8)*i,70*(c%5)+8*(c%5+1));
if(!lsbl[c]){lsttb[c].Enabled=false;lsttb[c].Text="快捷键注册失败";}
}
this.bt1=new Button();
this.bt1.Name="button1";
this.bt1.Size=new Size(100,24);
this.bt1.Location=new Point(16+30+8+24,480-16-20-32);
this.bt1.TabIndex=11;
this.bt1.Text="清空框框内容";
this.bt1.UseVisualStyleBackColor=true;
this.bt1.Click+=new EventHandler(this.bt1_Click);
this.bt2=new Button();
this.bt2.Name="button2";
this.bt2.Size=new Size(100,24);
this.bt2.Location=new Point(16+(30+8)*2+150+60+24,480-16-20-32);
this.bt2.TabIndex=12;
this.bt2.Text="重新加载配置";
this.bt2.UseVisualStyleBackColor=true;
this.bt2.Click+=new EventHandler(this.bt2_Click);
for(int t=0;t<10;t++){this.lstlb[t].TabIndex=t+13;}
this.lb=new Label();
this.lb.Location = new System.Drawing.Point(8, 480-16-8);
this.lb.Name = "label";
this.lb.Size = new System.Drawing.Size(480-8-8, 20);
this.lb.TabIndex = 23;
this.lb.TextAlign=ContentAlignment.TopCenter;
this.lb.Text="可将 123456.txt 作为配置文件,文件编码 utf8,一行一个,不想配置的可用空行代替";
this.bt2_Click(null,null);
this.ClientSize = new System.Drawing.Size(480, 480);
for(int t=0;t<10;t++){
this.Controls.Add(this.lstlb[t]);
this.Controls.Add(this.lsttb[t]);
}
this.Controls.Add(this.bt1);
this.Controls.Add(this.bt2);
this.Controls.Add(this.lb);
this.Name = "Form999";
this.Text = "单功能剪切版";
this.ResumeLayout(false);
this.PerformLayout();
}
protected override void WndProc(ref Message m)
{
int value=0;
switch(m.Msg){
case Winapi.WM_DESTROY:
for(int t=0;t<10;t++){
if(this.lsbl[t]){
Winapi.UnregisterHotKey(this.Handle,t+0x70);
}}
break;
case Winapi.WM_HOTKEY:
value=(int)m.WParam;
if((value>0x69)&&(value<0x7a)){
Clipboard.SetData("UnicodeText",this.lsttb[value-0x70].Text);
System.Threading.Thread.Sleep(0);
SendKeys.SendWait("^v");
}
break;
}
base.WndProc(ref m);
}
private void bt1_Click(object sender, EventArgs e){
for(int t=0;t<10;t++){
if(lsbl[t]){this.lsttb[t].Text="";}
}}
private void bt2_Click(object sender, EventArgs e){
string cfgfile="123456.txt";
string[] str;
if(File.Exists(cfgfile)){
str=File.ReadAllLines(cfgfile,Encoding.UTF8);
for(int t=0;(t<(str.Length-1))&&(t<10);t++){
if(this.lsbl[t]){this.lsttb[t].Text=str[t];}
}}}
}
static class Program{
[STAThread]
static void Main(){
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form999());
}}
}COPY
1

评分人数

TOP

回复 40# Five66


win11x64系统下,测试成功。

代码能否修改下?实现:智能判断如果当前f1-f10框里面是空的内容,就还是用系统自带的按键功能。
比如运行单功能剪切板.exe软件里f2对应的内容是空的,鼠标点击某个文件名,再按f2按键就是修改文件名状态。

TOP

回复 41# ygqiang


   
试试删掉原来的,换成下面的,然后重新运行编译
因为不是通过取消快捷键来恢复的,不一定常常有效
/*
@echo off&chcp 936&cls&setlocal
set "exename=单功能剪切板.exe"
if exist "%exename%" start "" "%exename%"&endlocal&exit/b
for /f "delims=" %%a in ('dir /b /ad /o-n "%systemroot%\Microsoft.NET"') do (
for /f "delims=" %%b in ('dir /b /ad /o-n "%systemroot%\Microsoft.NET\%%a"') do (
for /f "delims=" %%r in ('dir /s /b /o-n "%systemroot%\Microsoft.NET\%%a\%%b\csc.exe"') do (
if "%%~xr"==".exe" (
set "csc=%%~fr"
goto :aaa)
)))
echo 找不到C#编译器csc.exe
goto :bbb
:aaa
"%csc%"  /target:winexe /out:"%exename%"  "%~f0"
echo,&timeout /t 1 1>nul
if exist "%exename%" (echo,编译成功,请重新运行此bat或%exename%) else (echo,编译失败)
:bbb
endlocal
echo,&pause&exit /b
*/
using System;
using System.Drawing;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WinFormsApp
{
public class Winapi{
public const int WM_DESTROY=0x0002;
public const int WM_HOTKEY=0x0312;
public const int WM_KEYDOWN=0x0100;
public const int WM_KEYUP=0x0101;//public const int WM_CHAR=0x0102;
public const int MOD_NOREPEAT=0x4000;
[DllImport("user32.dll",ExactSpelling=true)]
[return:MarshalAs(UnmanagedType.Bool)]
public static extern bool RegisterHotKey(IntPtr hwnd,int id,uint fsmodifiers,uint vk);
[DllImport("user32.dll",ExactSpelling=true)]
[return:MarshalAs(UnmanagedType.Bool)]
public static extern bool UnregisterHotKey(IntPtr hwnd,int id);
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll",ExactSpelling=true)]
[return:MarshalAs(UnmanagedType.Bool)]
public static extern bool PostMessageA(IntPtr hwnd, uint msg, int wparam, uint iparam);
}
public partial class Form999:Form{
private List<Label> lstlb;
private List<TextBox> lsttb;
private List<bool> lsbl;
private Button bt1;
private Button bt2;
private Label lb;
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing){
if (disposing && (components != null)){components.Dispose();}
base.Dispose(disposing);
}
public Form999(){Initial();}//this.bt2.PerformClick();}
public void Initial(){
this.lstlb=new List<Label>(10);
this.lsttb=new List<TextBox>(10);
this.lsbl=new List<bool>(10);
for(int t=0x70;t<0x7a;t++){
lsbl.Add(Winapi.RegisterHotKey(this.Handle,t,Winapi.MOD_NOREPEAT,(uint)t));
}
this.SuspendLayout();
int i=0;
for(int c=0;c<10;c++){
lstlb.Add(new Label());
if((c>4) && (0==i)){i+=1;}
lstlb[c].Size=new Size(30,70);
lstlb[c].Name="lable"+c;
if(c<5){lstlb[c].TextAlign=ContentAlignment.TopRight;}
lstlb[c].Text=String.Format("F{0}",c+1);
lstlb[c].Location=new Point(16+(8+150+60+30+8)*i,70*(c%5)+8*(c%5+1));
lsttb.Add(new TextBox());
if((c>4) && (0==i)){i+=1;}
lsttb[c].Size=new Size(150,70);
lsttb[c].Name="textbox"+c;
lsttb[c].TabIndex=i;
lsttb[c].BorderStyle=BorderStyle.FixedSingle;
lsttb[c].Multiline=true;
lsttb[c].Location=new Point(16+30+8+(150+60+30+8)*i,70*(c%5)+8*(c%5+1));
if(!lsbl[c]){lsttb[c].Enabled=false;lsttb[c].Text="快捷键注册失败";}
}
this.bt1=new Button();
this.bt1.Name="button1";
this.bt1.Size=new Size(100,24);
this.bt1.Location=new Point(16+30+8+24,480-16-20-32);
this.bt1.TabIndex=11;
this.bt1.Text="清空框框内容";
this.bt1.UseVisualStyleBackColor=true;
this.bt1.Click+=new EventHandler(this.bt1_Click);
this.bt2=new Button();
this.bt2.Name="button2";
this.bt2.Size=new Size(100,24);
this.bt2.Location=new Point(16+(30+8)*2+150+60+24,480-16-20-32);
this.bt2.TabIndex=12;
this.bt2.Text="重新加载配置";
this.bt2.UseVisualStyleBackColor=true;
this.bt2.Click+=new EventHandler(this.bt2_Click);
for(int t=0;t<10;t++){this.lstlb[t].TabIndex=t+13;}
this.lb=new Label();
this.lb.Location = new System.Drawing.Point(8, 480-16-8);
this.lb.Name = "label";
this.lb.Size = new System.Drawing.Size(480-8-8, 20);
this.lb.TabIndex = 23;
this.lb.TextAlign=ContentAlignment.TopCenter;
this.lb.Text="可将 123456.txt 作为配置文件,文件编码 utf8,一行一个,不想配置的可用空行代替";
this.bt2_Click(null,null);
this.ClientSize = new System.Drawing.Size(480, 480);
for(int t=0;t<10;t++){
this.Controls.Add(this.lstlb[t]);
this.Controls.Add(this.lsttb[t]);
}
this.Controls.Add(this.bt1);
this.Controls.Add(this.bt2);
this.Controls.Add(this.lb);
this.Name = "Form999";
this.Text = "单功能剪切板";
this.ResumeLayout(false);
this.PerformLayout();
}
protected override void WndProc(ref Message m)
{
int value=0;IntPtr ip;
switch(m.Msg){
case Winapi.WM_DESTROY:
for(int t=0;t<10;t++){
if(this.lsbl[t]){
Winapi.UnregisterHotKey(this.Handle,t+0x70);
}}
break;
case Winapi.WM_HOTKEY:
value=(int)m.WParam;
if((value>0x69)&&(value<0x7a)&&(!string.IsNullOrEmpty(this.lsttb[value-0x70].Text))){
Clipboard.SetData("UnicodeText",this.lsttb[value-0x70].Text);
System.Threading.Thread.Sleep(0);
SendKeys.SendWait("^v");
}else{
ip=Winapi.GetForegroundWindow();
if(ip != IntPtr.Zero){
Winapi.PostMessageA(ip,Winapi.WM_KEYDOWN,value,0x40000001);
Winapi.PostMessageA(ip,Winapi.WM_KEYUP,value,0xc0000001);
}}
break;
}
base.WndProc(ref m);
}
private void bt1_Click(object sender, EventArgs e){
for(int t=0;t<10;t++){
if(lsbl[t]){this.lsttb[t].Text="";}
}}
private void bt2_Click(object sender, EventArgs e){
string cfgfile="123456.txt";
string[] str;
if(File.Exists(cfgfile)){
str=File.ReadAllLines(cfgfile,Encoding.UTF8);
for(int t=0;(t<(str.Length-1))&&(t<10);t++){
if(this.lsbl[t]){this.lsttb[t].Text=str[t];}
}}}
}
static class Program{
[STAThread]
static void Main(){
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form999());
}}
}COPY

TOP

回复 42# Five66


谢谢。运行单功能剪切板.exe,f1按键绑定f1sdffds,f2按键空的,f3按键绑定f3df343,其他按键都是空的。
f1和f3按键功能正常,f2按键可以实现文件名重命名的功能。但是:新建一个txt文件并打开,f5按键没反应

如果单功能剪切板.exe退出,新建一个txt文件并打开,f5按键是添加时间日期功能。

这是什么原因?

TOP

回复 43# ygqiang


   
通过向前台主窗口发送消息来实现的(不然的话快捷键要不断一关一开,很容易出问题),有些窗口关系复杂的可能无效
而且uwp应用有winrt(windows runtime),某些情况下也可能无效
总之就是不一定有效

TOP

返回列表