Advertisement
Najeebsk

CMD-AUTOHOTKEY.ahk

Jul 8th, 2022
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODIFIED=20110813
  2. Filename1=NajeebDosConsole_20110813
  3. ;-- works tested XP ---------
  4. ;-- use DropDownList & Enter
  5.  
  6.  
  7. #NoEnv                       ; Recommended for performance and compatibility with future AutoHotkey releases.
  8. SendMode Input               ; Recommended for new scripts due to its superior speed and reliability.
  9. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  10. #SingleInstance, off
  11. AutoTrim, on
  12.  
  13. transform,u ,chr,129  ;ue
  14. transform,u2,chr,154  ;Ue
  15. transform,a ,chr,132  ;ae
  16. transform,a2,chr,142  ;Ae
  17. transform,o ,chr,148  ;oe
  18. transform,o2,chr,153  ;Oe
  19. transform,s ,chr,225  ;ss
  20. transform,sp,chr,32   ;space
  21.  
  22. F11=test55.txt
  23. ifexist,%f11%
  24.    filedelete,%f11%
  25.  
  26. gosub,e4xx
  27.  
  28.  
  29. gui,3: +resize
  30. Gui,3:Font,,FixedSys
  31. ;Gui,3:Add,Text,cgreen  x10    y10     h20   w105               ,DOS-Command
  32.  
  33. cmd1=ver
  34. Gui,3:Add,Edit,cRed     x10   y5      h20   w450  vCommandline ,%cmd1%
  35. Gui,3:Add,Edit,cRed     x465  y5      h20   w400  vSelectedPath ,
  36.  
  37. Gui,3:Add,DropDownList,x470   y30     h600  w250  vInput gRefresh +Choose1 , %e4x%
  38.  
  39. Gui,3:Add,Edit,cBlack   x10   y70 -wrap  readonly vEditcontrol1 multi  ,
  40.  
  41. Gui,3:add,button, x350  y30 h20 w100  gSave1  vSave2, Save-Text
  42. Gui,3:add,button, x12 y30 h20 w100  gTest11 , Run Test
  43. Gui,3:add,button, x760 y30 h20 w100  gFileselect1 ,FileSelect
  44.  
  45. Gui,3:add,button, hidden default gRunDos,ok
  46.  
  47. Gui,3:Show,            x50   y2    h700  w900 ,%filename1%
  48. ;GuiControl,3:,Commandline,date /t
  49. Guicontrol,3:focus,Commandline
  50. GuiControl,3: Disable,Save2
  51. return
  52.  
  53.  
  54.  
  55. 3Guiclose:
  56. 3GuiEscape:
  57. exitapp
  58.  
  59.  
  60.  
  61. test11:
  62. FileDelete, tmpbatch.cmd
  63. FileAppend,
  64. (
  65. ver
  66. dir
  67. date /t
  68. time /t
  69. ), tmpbatch.cmd
  70. ;RunWait %comspec% /k tmpbatch.cmd
  71. ;FileDelete, tmpbatch.cmd
  72. RunWait, %comspec% /c tmpbatch.cmd %selectedpath% >%f11%,,UseErrorLevel Hide
  73. aa=
  74. FileRead,aa, %f11%
  75. if aa=
  76.    aa=Wrong DOS-Command or [No text found]
  77.  
  78. ;-- replace german Umlaut -----
  79. stringreplace,aa,aa,%o% ,oe,all
  80. stringreplace,aa,aa,%o2%,Oe,all
  81. stringreplace,aa,aa,%a% ,ae,all
  82. stringreplace,aa,aa,%a2%,Ae,all
  83. stringreplace,aa,aa,%u% ,ue,all
  84. ;stringreplace,aa,aa,%,Ue,all
  85. stringreplace,aa,aa,%s% ,ss,all
  86.  
  87. GuiControl,3:,Editcontrol1,%aa%`r`n
  88. ;GuiControl,3:,Commandline,%x2%
  89. Guicontrol,3:focus,Commandline
  90. GuiControl,3: Enable,Save2
  91. return
  92.  
  93.  
  94.  
  95.  
  96. refresh:
  97. gui,3:submit,nohide
  98. GuiControl,3:,Selectedpath,
  99. x1=
  100. x2=
  101. x3=
  102. stringsplit,x,input,%sp%
  103. commandline=%x2%%sp%%x3%
  104. GuiControl,3:,Commandline,%commandline%
  105. gosub,rundos
  106. return
  107.  
  108.  
  109.  
  110. Fileselect1:
  111.   FileSelectFile,File,,::{20d04fe0-3aea-1069-a2d8-08002b30309d},, (*.txt)
  112.    if file=
  113.       return
  114. GuiControl,3:,Selectedpath,"%file%"
  115. return
  116.  
  117.  
  118.  
  119.  
  120. RunDos:
  121. gui,3:submit,nohide
  122. Rundos1:
  123. GuiControl,3: Disable,Save2
  124. ifexist,%f11%
  125.    filedelete,%f11%
  126. ;msgbox,%commandline%
  127. ;return
  128. RunWait, %comspec% /c %CommandLine% %selectedpath% >%f11%,,UseErrorLevel Hide
  129. aa=
  130. FileRead,aa, %f11%
  131. if aa=
  132.    aa=Wrong DOS-Command or [No text found]
  133.  
  134. ;-- replace german Umlaut -----
  135. stringreplace,aa,aa,%o% ,oe,all
  136. stringreplace,aa,aa,%o2%,Oe,all
  137. stringreplace,aa,aa,%a% ,ae,all
  138. stringreplace,aa,aa,%a2%,Ae,all
  139. stringreplace,aa,aa,%u% ,ue,all
  140. ;stringreplace,aa,aa,%,Ue,all
  141. stringreplace,aa,aa,%s% ,ss,all
  142.  
  143. GuiControl,3:,Editcontrol1,%aa%`r`n
  144. ;GuiControl,3:,Commandline,%x2%
  145. Guicontrol,3:focus,Commandline
  146. GuiControl,3: Enable,Save2
  147. return
  148.  
  149.  
  150.  
  151. Save1:
  152. FileSelectFile, FileName,S 16,%a_Desktop%, Select location to Save - Saves as xy.txt , *.txt
  153. if errorlevel
  154.     return
  155. FileAppend, %aa%, %FileName%.txt
  156. return
  157.  
  158. 3GuiSize:
  159. guicontrol,3: move, Editcontrol1, % "w" A_GUIWidth-20 "h" A_GUIHeight-30
  160. return
  161.  
  162.  
  163.  
  164.  
  165.  ;-- ctrl+alt+d = DOSCOMMANDHERE:  ---------------
  166.  ^!d::
  167.  ID := WinExist("A")
  168.  WinGetClass, Class, ahk_id %ID%
  169.  ControlGetText,ePath, Edit1, ahk_id %ID%
  170.  if epath=
  171.     epath=%A_desktop%
  172.  ;msgbox,%epath%
  173.  Run, %comspec%, %epath%
  174. return
  175.  
  176.  
  177. e4xx:
  178. e4x=
  179. (Ltrim join|
  180. DOSHelp= help
  181. version= ver
  182. date= date /t
  183. time= time /t
  184. Volume= vol
  185. ModeStatus= mode
  186. Assoc= assoc /?
  187. AtTimeCommands= at /?
  188. Append= append /?
  189. Attrib= attrib /?
  190. Break= break /?
  191. Cacls= cacls /?
  192. Call= call /?
  193. ChangeDir= cd /?
  194. CodePage= chcp /?
  195. CheckDisk= chkdsk /?
  196. CheckNTFS= chkntfs /?
  197. ClearScreen= cls /?
  198. CMD= cmd /?
  199. CommandCom= command /?
  200. Color= color /?
  201. Compare= comp /?
  202. Compact= compact /?
  203. Convert= convert /?
  204. Copy= copy /?
  205. Debug= debug /?
  206. Defrag= defrag /?
  207. Delete= del /?
  208. Directory= dir /?
  209. Diskcompare= diskcomp /?
  210. Diskcopy= diskcopy /?
  211. Diskpart= diskpart /?
  212. Doskey= doskey /?
  213. Echo= echo /?
  214. Editor= edit /?
  215. Endlocal= endlocal /?
  216. Erase= erase /?
  217. Exit= exit /?
  218. Expand= expand /?
  219. FileCompare= fc /?
  220. Find= find /?
  221. FindSTR= findstr /?
  222. For= for /?
  223. FormatDisk= format /?
  224. Ftype= ftype /?
  225. Goto= goto /?
  226. Graphics= graphics /?
  227. Graftabl= graftabl /?
  228. If= if /?
  229. Label= label /?
  230. LoadfixStartOldie= loadfix /?
  231. MakeDirectory= md /?
  232. Memory= mem /?
  233. Mode= mode /?
  234. ModeStatus= mode
  235. More= more /?
  236. Move= move /?
  237. Path= path /?
  238. Pause= pause /?
  239. Popd= popd /?
  240. Print= print /?
  241. Prompt= prompt /?
  242. Pushd= pushd /?
  243. RemoveDirEmpty= rd /?
  244. Recover= recover /?
  245. Remark= rem /?
  246. Rename= ren /?
  247. Replace= replace /?
  248. Set= set /?
  249. Setlocal= setlocal /?
  250. Setver= setver /?
  251. Shift= shift /?
  252. Sort= sort /?
  253. Start= start /?
  254. Subst= subst /?
  255. Title= title /?
  256. Tree= tree /?
  257. Type= type /?
  258. VerifyCopy= verify
  259. Volume= vol
  260. xcopy= xcopy /?
  261. )
  262. return
  263. ;===================== END script =====================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement