Text Preview Scipt Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
realdeal599
Posts: 5
Joined: 13 Dec 2016, 08:35

Text Preview Scipt

13 Dec 2016, 22:49

I am looking for an existing ahk script that has the ability to preview file contents.

Seems pretty straight forward so didn't want to recreate it but...

My goal is to have a dynamically fed list of files in a left pane. When a file in that list is selected the contents are displayed in a right pane.

Seems straight forward and didn't want to re-invent the wheel on that portion if it already exists. I searched and could not find one but...

Thanks...
garry
Posts: 1710
Joined: 22 Dec 2013, 12:50

Re: Text Preview Scipt  Topic is solved

14 Dec 2016, 03:22

an example with listbox and edit

Code: Select all

;-- select text-file and show / modify / save / run
modified=20161214
;created=20110626
setworkingdir,%A_scriptdir%
;--- for test ---------------------
fl1=%A_scriptdir%\test11.txt
fl2=%A_scriptdir%\test12.txt
ifnotexist,%fl1%
  fileappend,File_%fl1%`r`n,%fl1%
ifnotexist,%fl2%
  fileappend,File_%fl2%`r`n,%fl2%
;---------------------------------

Gui,2: Add, ListBox, x10   y10   w200 h250   vA1x gA1,
Gui,2:Font,,FixedSys
Gui,2: Add, Edit   , x220  y10   w650 h250   vA2x    ,
Gui,2: Add, Button , x10   y270  w100 h22    gSave1  ,SAVE
Gui,2: Add, Button , x120  y270  w100 h22    gRun1   ,RUN
Gui,2: Add, Button , x240  y270  w100 h22    gOpen1  ,OPEN

extensions1:="txt,bas,ini,ahk,csv"
Loop,*.*
   {
   x:=a_loopfilefullpath
   SplitPath,x, nameNos, dir, ext, name_no_ext, drive
   if ext in %Extensions1%
      GuiControl,2:,A1x,%A_LoopFileName%
   }
Gui,2: Show, w900 h300, %modified%
Return

2Guiclose:
exitapp

A1:
Gui,2: Submit,nohide
Fileread,a,%a1x%
GuiControl,2: ,A2x, %a%
return

save1:
Gui,2: Submit,nohide
GuiControlGet,C,,A2x
F1=%A_scriptdir%\%A1x%
filedelete,%f1%
stringreplace,C,C,`n,`r`n,all
Fileappend,%c%`r`n,%f1%
msgbox, 262208,Message,File %A1x% is saved
return

RUN1:
Gui,2: Submit,nohide
F1=%A_scriptdir%\%A1x%
if F1=
   return
SplitPath, F1, name, dir, ext, name_no_ext, drive
if ext=ahk
   {
   run,%f1%
   return
   }
if ext in %Extensions1%
   run,notepad %f1%
return

OPEN1:
Gui,2: Submit,nohide
F1=%A_scriptdir%\%A1x%
run,notepad %f1%
return
;========================== end script =============================

realdeal599
Posts: 5
Joined: 13 Dec 2016, 08:35

Re: Text Preview Scipt

31 Dec 2016, 07:53

Thank you garry...you point me in the right direction!
BoBo
Posts: 2517
Joined: 13 May 2014, 17:15

Re: Text Preview Scipt

12 Jun 2017, 03:48

[slightlyOT]
Just for the records. Want to use Explorers preview pane to display files with another/new file extension (eg. AHK files)?!!
:arrow: https://autohotkey.com/boards/viewtopic.php?f=6&t=32988
[/slightlyOT]

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot] and 83 guests