[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 28# jack2020


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

TOP

回复 30# 77七


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

TOP

回复 27# 77七


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

TOP

回复 32# jack2020


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


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

TOP

回复 34# 77七


    厉害

TOP

回复 31# ppll2030


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

TOP

确实可以用bat替代这个软件,系统自带的命令行power
  1. #@&cls&powershell "type '%~0'|out-string|iex"&pause&exit
  2. $list=@(
  3. 'C:\01_项目AA2'
  4. 'C:\01_项目AA2'
  5. 'C:\01_项目AA2'
  6. )
  7. Add-Type -AssemblyName System.Windows.Forms
  8. Add-Type @'
  9. using System;
  10. using System.Runtime.InteropServices;
  11. public class HK
  12. {
  13.     [DllImport("user32.dll")]
  14.     public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
  15.     [DllImport("user32.dll")]
  16.     public static extern bool GetMessage(ref MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
  17.     [StructLayout(LayoutKind.Sequential)]
  18.     public struct MSG
  19.     {
  20. public IntPtr hwnd;
  21. public uint message;
  22. public IntPtr wParam;
  23. public IntPtr lParam;
  24. public uint time;
  25. public int x;
  26. public int y;
  27.     }
  28. }
  29. '@
  30. $define = for($i=0x70; $i -le 0x79; $i++){
  31. [void][HK]::RegisterHotKey(0, $i, 0x4000, $i)
  32. "{0}{{scb '{1}'; {2}; break}}" -f $i, $list[$i-0x70], '[System.Windows.Forms.SendKeys]::SendWait("^v")'
  33. }
  34. $define='switch($msg.wParam){'+($define|out-string)+'}'
  35. $msg = @{}
  36. while([HK]::GetMessage([ref]$msg, 0, 0, 0) -ne 0){if($msg.message -eq 0x0312){iex $define}}
复制代码
1

评分人数

TOP

回复 37# idwma


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

TOP

回复 38# jack2020


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

TOP

源码是易语言的,没钱用正版,不想用盗版,用C#弄了个差不多的
将下面代码保存为ANSI编码的bat然后运行,运行后会使用系统自带的C#编译器进行编译(有的话)
  1. /*
  2. @echo off&chcp 936&cls&setlocal
  3. set "exename=单功能剪切板.exe"
  4. if exist "%exename%" start "" "%exename%"&exit/b
  5. for /f "delims=" %%a in ('dir /b /ad /o-n "%systemroot%\Microsoft.NET"') do (
  6. for /f "delims=" %%b in ('dir /b /ad /o-n "%systemroot%\Microsoft.NET\%%a"') do (
  7. for /f "delims=" %%r in ('dir /s /b /o-n "%systemroot%\Microsoft.NET\%%a\%%b\csc.exe"') do (
  8. if "%%~xr"==".exe" (
  9. set "csc=%%~fr"
  10. goto :aaa)
  11. )))
  12. echo 找不到C#编译器csc.exe
  13. goto :bbb
  14. :aaa
  15. "%csc%"  /target:winexe /out:"%exename%"  "%~f0"
  16. echo,&timeout /t 1 1>nul
  17. if exist "%exename%" (echo,编译成功,请重新运行此bat或%exename%) else (echo,编译失败)
  18. :bbb
  19. endlocal
  20. echo,&pause&exit /b
  21. */
  22. using System;
  23. using System.Drawing;
  24. using System.Collections.Generic;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Threading.Tasks;
  28. using System.Text;
  29. using System.Windows.Forms;
  30. using System.Runtime.InteropServices;
  31. namespace WinFormsApp
  32. {
  33. public class Winapi{
  34. public const int WM_DESTROY=0x0002;
  35. public const int WM_HOTKEY=0x0312;
  36. public const int MOD_NOREPEAT=0x4000;
  37. [DllImport("user32.dll",ExactSpelling=true)]
  38. [return:MarshalAs(UnmanagedType.Bool)]
  39. public static extern bool RegisterHotKey(IntPtr hwnd,int id,uint fsmodifiers,uint vk);
  40. [DllImport("user32.dll",ExactSpelling=true)]
  41. [return:MarshalAs(UnmanagedType.Bool)]
  42. public static extern bool UnregisterHotKey(IntPtr hwnd,int id);
  43. }
  44. public partial class Form999:Form{
  45. private List<Label> lstlb;
  46. private List<TextBox> lsttb;
  47. private List<bool> lsbl;
  48. private Button bt1;
  49. private Button bt2;
  50. private Label lb;
  51. private System.ComponentModel.IContainer components = null;
  52. protected override void Dispose(bool disposing){
  53. if (disposing && (components != null)){components.Dispose();}
  54. base.Dispose(disposing);
  55. }
  56. public Form999(){Initial();}//this.bt2.PerformClick();}
  57. public void Initial(){
  58. this.lstlb=new List<Label>(10);
  59. this.lsttb=new List<TextBox>(10);
  60. this.lsbl=new List<bool>(10);
  61. for(int t=0x70;t<0x7a;t++){
  62. lsbl.Add(Winapi.RegisterHotKey(this.Handle,t,Winapi.MOD_NOREPEAT,(uint)t));
  63. }
  64. this.SuspendLayout();
  65. int i=0;
  66. for(int c=0;c<10;c++){
  67. lstlb.Add(new Label());
  68. if((c>4) && (0==i)){i+=1;}
  69. lstlb[c].Size=new Size(30,70);
  70. lstlb[c].Name="lable"+c;
  71. if(c<5){lstlb[c].TextAlign=ContentAlignment.TopRight;}
  72. lstlb[c].Text=String.Format("F{0}",c+1);
  73. lstlb[c].Location=new Point(16+(8+150+60+30+8)*i,70*(c%5)+8*(c%5+1));
  74. lsttb.Add(new TextBox());
  75. if((c>4) && (0==i)){i+=1;}
  76. lsttb[c].Size=new Size(150,70);
  77. lsttb[c].Name="textbox"+c;
  78. lsttb[c].TabIndex=i;
  79. lsttb[c].BorderStyle=BorderStyle.FixedSingle;
  80. lsttb[c].Multiline=true;
  81. lsttb[c].Location=new Point(16+30+8+(150+60+30+8)*i,70*(c%5)+8*(c%5+1));
  82. if(!lsbl[c]){lsttb[c].Enabled=false;lsttb[c].Text="快捷键注册失败";}
  83. }
  84. this.bt1=new Button();
  85. this.bt1.Name="button1";
  86. this.bt1.Size=new Size(100,24);
  87. this.bt1.Location=new Point(16+30+8+24,480-16-20-32);
  88. this.bt1.TabIndex=11;
  89. this.bt1.Text="清空框框内容";
  90. this.bt1.UseVisualStyleBackColor=true;
  91. this.bt1.Click+=new EventHandler(this.bt1_Click);
  92. this.bt2=new Button();
  93. this.bt2.Name="button2";
  94. this.bt2.Size=new Size(100,24);
  95. this.bt2.Location=new Point(16+(30+8)*2+150+60+24,480-16-20-32);
  96. this.bt2.TabIndex=12;
  97. this.bt2.Text="重新加载配置";
  98. this.bt2.UseVisualStyleBackColor=true;
  99. this.bt2.Click+=new EventHandler(this.bt2_Click);
  100. for(int t=0;t<10;t++){this.lstlb[t].TabIndex=t+13;}
  101. this.lb=new Label();
  102. this.lb.Location = new System.Drawing.Point(8, 480-16-8);
  103. this.lb.Name = "label";
  104. this.lb.Size = new System.Drawing.Size(480-8-8, 20);
  105. this.lb.TabIndex = 23;
  106. this.lb.TextAlign=ContentAlignment.TopCenter;
  107. this.lb.Text="可将 123456.txt 作为配置文件,文件编码 utf8,一行一个,不想配置的可用空行代替";
  108. this.bt2_Click(null,null);
  109. this.ClientSize = new System.Drawing.Size(480, 480);
  110. for(int t=0;t<10;t++){
  111. this.Controls.Add(this.lstlb[t]);
  112. this.Controls.Add(this.lsttb[t]);
  113. }
  114. this.Controls.Add(this.bt1);
  115. this.Controls.Add(this.bt2);
  116. this.Controls.Add(this.lb);
  117. this.Name = "Form999";
  118. this.Text = "单功能剪切版";
  119. this.ResumeLayout(false);
  120. this.PerformLayout();
  121. }
  122. protected override void WndProc(ref Message m)
  123. {
  124. int value=0;
  125. switch(m.Msg){
  126. case Winapi.WM_DESTROY:
  127. for(int t=0;t<10;t++){
  128. if(this.lsbl[t]){
  129. Winapi.UnregisterHotKey(this.Handle,t+0x70);
  130. }}
  131. break;
  132. case Winapi.WM_HOTKEY:
  133. value=(int)m.WParam;
  134. if((value>0x69)&&(value<0x7a)){
  135. Clipboard.SetData("UnicodeText",this.lsttb[value-0x70].Text);
  136. System.Threading.Thread.Sleep(0);
  137. SendKeys.SendWait("^v");
  138. }
  139. break;
  140. }
  141. base.WndProc(ref m);
  142. }
  143. private void bt1_Click(object sender, EventArgs e){
  144. for(int t=0;t<10;t++){
  145. if(lsbl[t]){this.lsttb[t].Text="";}
  146. }}
  147. private void bt2_Click(object sender, EventArgs e){
  148. string cfgfile="123456.txt";
  149. string[] str;
  150. if(File.Exists(cfgfile)){
  151. str=File.ReadAllLines(cfgfile,Encoding.UTF8);
  152. for(int t=0;(t<(str.Length-1))&&(t<10);t++){
  153. if(this.lsbl[t]){this.lsttb[t].Text=str[t];}
  154. }}}
  155. }
  156. static class Program{
  157. [STAThread]
  158. static void Main(){
  159. Application.EnableVisualStyles();
  160. Application.SetCompatibleTextRenderingDefault(false);
  161. Application.Run(new Form999());
  162. }}
  163. }
复制代码
1

评分人数

TOP

回复 40# Five66


win11x64系统下,测试成功。

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

TOP

回复 41# ygqiang


   
试试删掉原来的,换成下面的,然后重新运行编译
因为不是通过取消快捷键来恢复的,不一定常常有效
  1. /*
  2. @echo off&chcp 936&cls&setlocal
  3. set "exename=单功能剪切板.exe"
  4. if exist "%exename%" start "" "%exename%"&endlocal&exit/b
  5. for /f "delims=" %%a in ('dir /b /ad /o-n "%systemroot%\Microsoft.NET"') do (
  6. for /f "delims=" %%b in ('dir /b /ad /o-n "%systemroot%\Microsoft.NET\%%a"') do (
  7. for /f "delims=" %%r in ('dir /s /b /o-n "%systemroot%\Microsoft.NET\%%a\%%b\csc.exe"') do (
  8. if "%%~xr"==".exe" (
  9. set "csc=%%~fr"
  10. goto :aaa)
  11. )))
  12. echo 找不到C#编译器csc.exe
  13. goto :bbb
  14. :aaa
  15. "%csc%"  /target:winexe /out:"%exename%"  "%~f0"
  16. echo,&timeout /t 1 1>nul
  17. if exist "%exename%" (echo,编译成功,请重新运行此bat或%exename%) else (echo,编译失败)
  18. :bbb
  19. endlocal
  20. echo,&pause&exit /b
  21. */
  22. using System;
  23. using System.Drawing;
  24. using System.Collections.Generic;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Threading.Tasks;
  28. using System.Text;
  29. using System.Windows.Forms;
  30. using System.Runtime.InteropServices;
  31. namespace WinFormsApp
  32. {
  33. public class Winapi{
  34. public const int WM_DESTROY=0x0002;
  35. public const int WM_HOTKEY=0x0312;
  36. public const int WM_KEYDOWN=0x0100;
  37. public const int WM_KEYUP=0x0101;//public const int WM_CHAR=0x0102;
  38. public const int MOD_NOREPEAT=0x4000;
  39. [DllImport("user32.dll",ExactSpelling=true)]
  40. [return:MarshalAs(UnmanagedType.Bool)]
  41. public static extern bool RegisterHotKey(IntPtr hwnd,int id,uint fsmodifiers,uint vk);
  42. [DllImport("user32.dll",ExactSpelling=true)]
  43. [return:MarshalAs(UnmanagedType.Bool)]
  44. public static extern bool UnregisterHotKey(IntPtr hwnd,int id);
  45. [DllImport("user32.dll")]
  46. public static extern IntPtr GetForegroundWindow();
  47. [DllImport("user32.dll",ExactSpelling=true)]
  48. [return:MarshalAs(UnmanagedType.Bool)]
  49. public static extern bool PostMessageA(IntPtr hwnd, uint msg, int wparam, uint iparam);
  50. }
  51. public partial class Form999:Form{
  52. private List<Label> lstlb;
  53. private List<TextBox> lsttb;
  54. private List<bool> lsbl;
  55. private Button bt1;
  56. private Button bt2;
  57. private Label lb;
  58. private System.ComponentModel.IContainer components = null;
  59. protected override void Dispose(bool disposing){
  60. if (disposing && (components != null)){components.Dispose();}
  61. base.Dispose(disposing);
  62. }
  63. public Form999(){Initial();}//this.bt2.PerformClick();}
  64. public void Initial(){
  65. this.lstlb=new List<Label>(10);
  66. this.lsttb=new List<TextBox>(10);
  67. this.lsbl=new List<bool>(10);
  68. for(int t=0x70;t<0x7a;t++){
  69. lsbl.Add(Winapi.RegisterHotKey(this.Handle,t,Winapi.MOD_NOREPEAT,(uint)t));
  70. }
  71. this.SuspendLayout();
  72. int i=0;
  73. for(int c=0;c<10;c++){
  74. lstlb.Add(new Label());
  75. if((c>4) && (0==i)){i+=1;}
  76. lstlb[c].Size=new Size(30,70);
  77. lstlb[c].Name="lable"+c;
  78. if(c<5){lstlb[c].TextAlign=ContentAlignment.TopRight;}
  79. lstlb[c].Text=String.Format("F{0}",c+1);
  80. lstlb[c].Location=new Point(16+(8+150+60+30+8)*i,70*(c%5)+8*(c%5+1));
  81. lsttb.Add(new TextBox());
  82. if((c>4) && (0==i)){i+=1;}
  83. lsttb[c].Size=new Size(150,70);
  84. lsttb[c].Name="textbox"+c;
  85. lsttb[c].TabIndex=i;
  86. lsttb[c].BorderStyle=BorderStyle.FixedSingle;
  87. lsttb[c].Multiline=true;
  88. lsttb[c].Location=new Point(16+30+8+(150+60+30+8)*i,70*(c%5)+8*(c%5+1));
  89. if(!lsbl[c]){lsttb[c].Enabled=false;lsttb[c].Text="快捷键注册失败";}
  90. }
  91. this.bt1=new Button();
  92. this.bt1.Name="button1";
  93. this.bt1.Size=new Size(100,24);
  94. this.bt1.Location=new Point(16+30+8+24,480-16-20-32);
  95. this.bt1.TabIndex=11;
  96. this.bt1.Text="清空框框内容";
  97. this.bt1.UseVisualStyleBackColor=true;
  98. this.bt1.Click+=new EventHandler(this.bt1_Click);
  99. this.bt2=new Button();
  100. this.bt2.Name="button2";
  101. this.bt2.Size=new Size(100,24);
  102. this.bt2.Location=new Point(16+(30+8)*2+150+60+24,480-16-20-32);
  103. this.bt2.TabIndex=12;
  104. this.bt2.Text="重新加载配置";
  105. this.bt2.UseVisualStyleBackColor=true;
  106. this.bt2.Click+=new EventHandler(this.bt2_Click);
  107. for(int t=0;t<10;t++){this.lstlb[t].TabIndex=t+13;}
  108. this.lb=new Label();
  109. this.lb.Location = new System.Drawing.Point(8, 480-16-8);
  110. this.lb.Name = "label";
  111. this.lb.Size = new System.Drawing.Size(480-8-8, 20);
  112. this.lb.TabIndex = 23;
  113. this.lb.TextAlign=ContentAlignment.TopCenter;
  114. this.lb.Text="可将 123456.txt 作为配置文件,文件编码 utf8,一行一个,不想配置的可用空行代替";
  115. this.bt2_Click(null,null);
  116. this.ClientSize = new System.Drawing.Size(480, 480);
  117. for(int t=0;t<10;t++){
  118. this.Controls.Add(this.lstlb[t]);
  119. this.Controls.Add(this.lsttb[t]);
  120. }
  121. this.Controls.Add(this.bt1);
  122. this.Controls.Add(this.bt2);
  123. this.Controls.Add(this.lb);
  124. this.Name = "Form999";
  125. this.Text = "单功能剪切板";
  126. this.ResumeLayout(false);
  127. this.PerformLayout();
  128. }
  129. protected override void WndProc(ref Message m)
  130. {
  131. int value=0;IntPtr ip;
  132. switch(m.Msg){
  133. case Winapi.WM_DESTROY:
  134. for(int t=0;t<10;t++){
  135. if(this.lsbl[t]){
  136. Winapi.UnregisterHotKey(this.Handle,t+0x70);
  137. }}
  138. break;
  139. case Winapi.WM_HOTKEY:
  140. value=(int)m.WParam;
  141. if((value>0x69)&&(value<0x7a)&&(!string.IsNullOrEmpty(this.lsttb[value-0x70].Text))){
  142. Clipboard.SetData("UnicodeText",this.lsttb[value-0x70].Text);
  143. System.Threading.Thread.Sleep(0);
  144. SendKeys.SendWait("^v");
  145. }else{
  146. ip=Winapi.GetForegroundWindow();
  147. if(ip != IntPtr.Zero){
  148. Winapi.PostMessageA(ip,Winapi.WM_KEYDOWN,value,0x40000001);
  149. Winapi.PostMessageA(ip,Winapi.WM_KEYUP,value,0xc0000001);
  150. }}
  151. break;
  152. }
  153. base.WndProc(ref m);
  154. }
  155. private void bt1_Click(object sender, EventArgs e){
  156. for(int t=0;t<10;t++){
  157. if(lsbl[t]){this.lsttb[t].Text="";}
  158. }}
  159. private void bt2_Click(object sender, EventArgs e){
  160. string cfgfile="123456.txt";
  161. string[] str;
  162. if(File.Exists(cfgfile)){
  163. str=File.ReadAllLines(cfgfile,Encoding.UTF8);
  164. for(int t=0;(t<(str.Length-1))&&(t<10);t++){
  165. if(this.lsbl[t]){this.lsttb[t].Text=str[t];}
  166. }}}
  167. }
  168. static class Program{
  169. [STAThread]
  170. static void Main(){
  171. Application.EnableVisualStyles();
  172. Application.SetCompatibleTextRenderingDefault(false);
  173. Application.Run(new Form999());
  174. }}
  175. }
复制代码

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

返回列表