AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Listview select column and start EMAIL,URL,PROGRAM

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
garry



Joined: 19 Apr 2005
Posts: 1557
Location: switzerland

PostPosted: Mon Jul 18, 2005 8:50 pm    Post subject: Listview select column and start EMAIL,URL,PROGRAM Reply with quote

(thank you all for scripts and the nice program AHK)
Here an idea how to select column in listview and start program
doubleclick column3/4/5 starts URL, EMAIL,Program
once click see Name City (column1/2) below
to sort click column head
New Adress=Button AddNew
delete/change rows with text editor or in Excel
Code:
;-------- http://www.autohotkey.com/forum/topic4526.html&highlight=listview ---
;adress.ahk garry 2005-07-18
;doubleclick at column starts URL,EMAIL,PROGRAM
;one click see Name Adress below
#NoTrayIcon
F1=ADRESS.CSV
Gui, Color, 000000
Gui, Font,  S10 CDefault , FixedSys
ifnotexist,adress.csv
     {
     Fileappend,AUTOHOTKEYFORUM`;New York`;http://www.autohotkey.com/forum/`;Chris@1234ABCD.xy`;C:\program files\AutoHotkey\autohotkey.chm`r`n,%F1%
     Fileappend,SCOTTSERVER    `;Los Angeles`;http://www.scottserver.net/forum/`;scott@1234ABCD.xy`;`r`n,%F1%
     Fileappend,SLEEPY         `;Alabama`;http://sleepyssin.suddenlaunch3.com/`;sleepy@1234ABCD.xy`;`r`n,%F1%
     Fileappend,Streamripper   `;`;http://streamripper.sourceforge.net/`;`;`r`n,%F1%
     Fileappend,CANDLE         `;Oslo`;http://www.candles-weblog.us`;candle@1234ABCD.xy`;`r`n,%F1%
     Fileappend,WhizCat        `;Atlanta`;http://scottserver.net/whizware`;TOM@1234ABCD.xy`;`r`n,%F1%
     Fileappend,CORRUPT        `;Arkansas`;http://www.apps4apps.filetap.com/`;corrupt@1234ABCD.xy`;`r`n,%F1%
     }

T1=160       ;column1 width
T2=200       ;column2 width
T3=200       ;column3 width
T4=150       ;column4 width
T5=300       ;column5 width

T1A:=T1
T2A:=T1+T2
T3A:=T1+T2+T3
T4A:=T1+T2+T3+T4
T5A:=T1+T2+T3+T4+T5  ;listview width

T5B:=T5A+30          ;guishow width
T5C:=T5A-70          ;Position Button AddNew
T5D:=T5A-160         ;Position Button refresh

Gui,Add, ListView,grid r20 w%T5A% +hscroll altsubmit vMyListView gMyListView, Name|City|URL|EMAIL|Program
LV_ModifyCol(1,T1)
LV_ModifyCol(2,T2)
LV_ModifyCol(3,T3)
LV_ModifyCol(4,T4)
LV_ModifyCol(5,T5)

Gui, Font, S8 cwhite, Verdana
Gui, Add, Edit, x12 y355 w%T5A% h20 ReadOnly vC,
Gui,Add,Button, x%T5C% y378 w70 h20,AddNew
;Gui,Add,Button, x%T5D% y378 w70 h20,Refresh
gosub,LB1
Gui, Show, x2 y0 w%T5B% h400 ,LISTVIEW
return

LB1:
Gui,1:default
Gui,Listview,Mylistview
LV_Delete()
loop,read,%F1%
{
stringsplit,BX,A_LoopReadLine,`;,
LV_Add("",BX1,BX2,BX3,BX4,BX5)
}
return


buttonAddNew:
C1:=
C2:=
C3:=
C4:=
C5:=
GuiControl,,C1, %C1%
GuiControl,,C2, %C2%
GuiControl,,C3, %C3%
GuiControl,,C4, %C4%
GuiControl,,C5, %C5%
GuiControl,focus,C1

Gui,2:Font,  S10 CDefault , FixedSys

Gui,2:Add,Text, x1  y5   w80  h20,NAME
Gui,2:Add,Edit, x80 y5   w420 h20 vC1,%C1%


;Gui,2:Add,Text, x1  y35  w80  h20,CITY
;Gui,2:Add,Edit, x80 y35  w420 h20 vC2,%C2%

Gui,2:Add,Text, x1  y35  w80  h20,STATE
Gui,2:Add, DropDownList,x80 y35 w420 vC2, Arizona|Arkansas|Texas|Alabama|Oklahoma


Gui,2:Add,Text, x1  y65  w80  h20,URL
Gui,2:Add,Edit, x80 y65  w420 h20 vC3,%C3%

Gui,2:Add,Text, x1  y95  w80  h20,EMAIL
Gui,2:Add,Edit, x80 y95  w420 h20 vC4,%C4%

Gui,2:Add,Text, x1  y125 w80  h20,PROGRAM
Gui,2:Add,Edit, x80 y125 w420 h20 vC5,%C5%

Gui,2:Add, Button, x390 y150 w70 h25, CLEAR
Gui,2:Add, Button, x470 y150 w70 h25, CANCEL
Gui,2:Add, Button, x550 y150 w40 h25, OK
Gui,2:Show, x2 y402 w600 h180,ADRESS-INPUT
return
2ButtonOK:
2GuiClose:
2GuiEscape:
Gui,2:submit
IF C1=
{
Gui destroy
return
}
FILEAPPEND,%C1%;%C2%;%C3%;%C4%;%C5%`r`n,%F1%
gosub,LB1
2ButtonCancel:
Gui,2: destroy
return


2ButtonClear:
C1:=
C2:=
C3:=
C4:=
C5:=
GuiControl,,C1, %C1%
GuiControl,,C2, %C2%
GuiControl,,C3, %C3%
GuiControl,,C4, %C4%
GuiControl,,C5, %C5%
GuiControl,focus,C1
Return



ButtonRefresh:
LV_Delete()
loop,read,%F1%
{
stringsplit,BX,A_LoopReadLine,`;,
LV_Add("",BX1,BX2,BX3,BX4,BX5)
}
return


MyListView:
GuiControlGet, MyListView
if A_GuiEvent = Normal
{
LV_GetText(C1,A_EventInfo,1)
LV_GetText(C2,A_EventInfo,2)
GuiControl, ,C,%C1% %C2%
}

if A_GuiEvent = DoubleClick
{
MouseGetPos,x,y
 {

if x<%T1A%
return

if x<%T2A%
return

if x<%T3A%
  {
LV_GetText(C3,A_EventInfo,3)
run,%C3%
return
  }

if x<%T4A%
  {
DATES=%A_DD%-%A_MM%-%A_YYYY%
LV_GetText(C4,A_EventInfo,4)
stringsplit,CX,C4,`@,
run,mailto:%C4%?subject=Message Titel %DATES%&Body=Hallo %CX1%`%0a`%0dHow are you ?`%0AI send you this message now....`%0ANext line...
;run,mailto:%C4%?subject=Greetings&Body=Hallo %CX1%
return
  }

if x<%T5A%
  {
LV_GetText(C5,A_EventInfo,5)
run,%C5%
return
  }
 }
}
return

GuiClose:
ExitApp






===========================================================
2nd example:
-select Listbox (file)
-see in Listview (content)

;-- edit
; delete multiple marked rows
; add


Code:
;--------- script from Thalon / how to delete multiple marked rows  ---
;--------- LISTVIEW EXAMPLE -------------------------------------------
;-- edit
;   delete multiple marked rows
;   add
;----------------------------------------------------------------------

R3C=%A_scriptDir%\_CSV
ifnotexist,%R3C%
   FileCreateDir,%R3C%

RM1=%A_scriptDir%\_CSV\EX1.csv
  ifnotexist,%RM1%
   {
   fileappend,Mathe-01`,http://archives.math.utk.edu/popmath.html`,Mathematik Examples-1`r`n,%RM1%
   fileappend,Mathe-02`,http://www.cut-the-knot.org/index.shtml`,Mathematik Examples-2`r`n,%RM1%
   }

RM2=%A_scriptDir%\_CSV\EX2.csv
  ifnotexist,%RM2%
   {
   fileappend,Autohotkey`,http://www.autohotkey.com/forum/index.php`r`n,%RM2%
   fileappend,Puzzle games`,http://www.chiark.greenend.org.uk/~sgtatham/puzzles/`r`n,%RM2%
   }

Gui,1:Font,S13 CDefault,Lucida Console
Gui,1:Add, ListView,backgroundteal csilver grid r10 x110 y0 w480 +hscroll altsubmit gLW2, Name|URL1
 LV_ModifyCol()
Gui,1:Show,x0 y0 w600 h260,Listview_Example01                               Edit=F12            DELETE=Rightclick
Gui,1:add,Listbox,x5 y10 w100 h200 Sort vLB1 gLB
Loop,%R3C%\*.csv
    {
    FX=%A_LoopFileName%
    stringlen,L1,FX
    stringmid,FA,FX,1,L1-4
    GuiControl,,LB1,%FA%
    }
GuiControl, ChooseString, LB1, %FA%
Gui,1:Font,  S10 CDefault , FixedSys
Gui,1:Add,Button,gAddUrl x5 y230 w120 h20,AddUrl
;=============================================================================
LB:
Gui, 1:Default
Gui,1:Submit,nohide
LV_Delete()
LV_ModifyCol(1,220)
LV_ModifyCol(2,220)
F2=%R3C%\%LB1%.csv

loop,read,%F2%
  {
  BX1=
  BX2=
  stringsplit,BX,A_LoopReadLine,`,,
  LV_Add("",BX1,BX2)
  }
return
;==============================================================
AddUrl:
if LB1=
  {
  msgbox,select first a genre (EX1, EX2 ....)
  return
  }

GuiControl,2:Focus,Name
Gui,2:Font,  S10 CDefault , FixedSys
Gui,2:Add,Text, x1 y5 w80 h20, NAME
Gui,2:Add,Edit,   x80 y5 w500 h20 vA21, %A21%
Gui,2:Add,Text,   x1  y30 w80  h20, URL1
Gui,2:Add,Edit,   x80 y30 w500 h20 vA22, %A22%
Gui,2:Add, Button, x550 y80 w40 h25, OK
Gui,2:Show, x2 y385 w600 h100, URL-INPUT
return
;---------------------------------------
2GuiClose:
2GuiEscape:
return

2ButtonOK:
Gui,2:submit
if A21=
  {
  Gui,2: Destroy
  return
  }
FILEAPPEND, %A21%`,%A22%`r`n,%F2%
Gui,2: Destroy
GoSub, LB         ;update LV
return
;============================================================
LW2:
Gui, Submit,nohide
if A_GuiEvent = Normal
  {
  LV_GetText(C1,A_EventInfo,1)
  LV_GetText(C2,A_EventInfo,2)
  RN:=LV_GetNext("C")
  RF:=LV_GetNext("F")
  GC:=LV_GetCount()
  Goto,SK12
  }

;----------------------------
SK12:
if A_GuiEvent=K

{
GetKeyState,state,F12
if state=D
 {
if LB1=
   {
   msgbox,select first a genre (EX1 or EX2....)
   return
   }

GuiControl,3:Focus,Name
Gui,3:Font,  S10 CDefault , FixedSys
Gui,3:Add,Text, x1 y5 w80 h20, NAME
Gui,3:Add,Edit,  x80 y5 w500 h20 vA31, %C1%
Gui,3:Add,Text,  x1  y30 w80  h20, URL1
Gui,3:Add,Edit,   x80 y30 w500 h20 vA32, %C2%
Gui,3:Add, Button, x550 y80 w40 h25, OK
Gui,3:Show, x2 y385 w600 h100, URL-INPUT
return
;---------------------------------------
3GuiClose:
3GuiEscape:
Gui, 3:Destroy
return
3ButtonOK:
Gui,3:submit
if A31=
   {
   Gui,3: Destroy
   return
   }

FileRead, FileContent, %R3C%\%LB1%.csv
FileDelete, %R3C%\%LB1%.csv
StringReplace, FileContent, FileContent, %C1%`,%C2%, %A31%`,%A32%
FileAppend, %FileContent%, %R3C%\%LB1%.csv
GoSub, LB

Goto,3guiclose
 }
}


;============== PLAY =========
if A_GuiEvent = DoubleClick
   {
   run,%C2%
   return
   }
;--------- DELETE multiple marked rows ---------------------
if A_GuiEvent = RightClick
{
C1 =
RF = 0
RFL =
Loop
   {
   RF:=LV_GetNext(RF)
   if RF=0
      {
      ;msgbox,Select a row
      break
      }
   RFL = %RF%|%RFL%
   LV_GetText(C1_Temp, RF, 1)
   C1 = %C1%`n%C1_Temp%
  }

if C1 !=
 {
   MsgBox, 4, ,Want you really delete %C1% ?
   IfMsgBox,No
      Return
   Else
   {
      Loop, parse, RFL, |
       {
       LV_Delete(A_LoopField)
       }

     filedelete,%F2%
     Loop % LV_GetCount()
        {
        BX1=
        BX2=
        LV_GetText(BX1,A_INDEX,1)
        LV_GetText(BX2,A_INDEX,2)
        fileappend,%BX1%`,%BX2%`r`n,%F2%
       }

   }
      C1=
      C2=
 }
return
}

;----------------------------
return
GuiClose:
ExitApp






========= 3rd EXAMPLE MP3PLAY FWD/BACK SEARCH =================


Code:
;==============================================================
MODIFIED=20090103
NAME1   =TEST MP3PLAY LISTVIEW FWD/BACK SEARCH
;==============================================================

;F1=%A_scriptdir%\test55.txt
Gui,1:default
Gui,1:Font,S10 cDefault, Verdana

RF:=1

T1=500       ;column1 width
T2=0         ;column2 width
T3=70        ;column3 width
T4=50        ;column4 width

  Gui,1:Add ,  Edit,   x400  y570   w195 h20 vURLX gSEARCH1
  Gui,1:Add,Button,default x0  y0 w0   h0  gSEARCH1 ,

  ;Gui,1:Add ,  Edit,   x280  y570   w195 h20 vURLX gSEARCH2
  ;Gui,1:Add,Button,default x0  y0 w0   h0  gSEARCH2 ,

Gui,1:Add,Button,x10   y570  w70  h25  gBACKWARD ,<<
Gui,1:Add,Button,x90   y570  w70  h25  gFORWARD  ,>>

Gui,1:Add ,  Edit,   x200  y570  w70 h25 vTOT1 ,
Gui,1:Add ,  Edit,   x290  y570  w70 h25 vPOS1 ,


Gui,1:Add, ListView,x10 y10 h480 w660 grid +hscroll nosorthdr altsubmit vMLV1A gMLV1B, NAME|FULLPATH|SIZE|NR
  LV_ModifyCol(1,T1)
  LV_ModifyCol(2,T2)
  LV_ModifyCol(3,T3)
  LV_ModifyCol(4,T4)

gosub,SB

GuiControl,1:Text,TOT1,%GC%           ;show total
GuiControl,1:Text,POS1,%RF%           ;show position
Gui,1:Show, x2 y0 w680 h600,TEST MP3PLAY
return
;-------------------------------

SB:
Gui,1:ListView,MLV1A
LV_Delete()
I=0
Loop, %A_desktop%\*.mp3, 0, 1
  {
  I++
  ;Lv_Add("", A_LoopFileName,A_LoopFileSizeKB,A_LoopFileTimeModified,A_LoopFileTimeCreated, A_LoopFileTimeAccessed,A_LoopFileAttrib, A_LoopFileFullPath)
  Lv_Add("", A_LoopFileName,A_LoopFileFullPath,A_LoopFileSizeKB,I)
  }

  GC:=LV_GetCount()
  LV_ModifyCol(3,"integer")
  LV_ModifyCol(4,"integer")
  LV_Modify(LV_GetCount(), "Vis")
return

/*
LV_Delete()
  loop,read,%F1%
   {
  stringsplit,C,A_LoopReadLine,`;,
  LV_Add("",C1,C2,C3)
   }
return
*/

;=================================================


;================== FORWARD =======================
FORWARD:
Gui,1:submit,nohide
Gui,1: ListView,MLV1A

SoundPlay, Nonexistent.avi

       if (RF=(GC))
          {
          RF:=(GC)
          LV_GetText(C2,RF,2)
          SoundPlay,%C2%
          msgbox,,,PLAYS LAST,2
          return
          }

        LV_Modify(RF, "-Select -Focus")
        RF:=(RF+1)
        LV_Modify(RF, "+Select +Focus")
        LV_GetText(C2,RF,2)
        GuiControl,1:Text,POS1,%RF%
        SoundPlay,%C2%
return
;===================================================




;================== BACKWARD =======================
BACKWARD:
Gui,1:submit,nohide
Gui,1: ListView,MLV1A
 SoundPlay, Nonexistent.avi
       if RF=1
          {
          LV_Modify(1, "+Select +Focus")
          LV_GetText(C2,RF,2)
          SoundPlay,%C2%
          msgbox,,,PLAYS FIRST,2
          return
          }

        LV_Modify(RF, "-Select -Focus")
        RF:=(RF-1)
        LV_Modify(RF, "+Select +Focus")

        LV_GetText(C2,RF,2)
        GuiControl,1:Text,POS1,%RF%
        SoundPlay,%C2%

return
;===================================================



;---- SEARCH first example ---------------
SEARCH1:
Gui,1:submit,nohide
if URLX=
   gosub,SB
   RF:=LV_GetNext("F")
   RF:=1
   Loop % LV_GetCount()
      {
      LV_GetText(C1,RF,1)
      LV_GetText(C2,RF,2)
      LV_GetText(C3,RF,3)
      CX=%C1% %C2% %C3%
       ifinstring,CX,%URLX%
        {
        RF:=(RF+1)
        continue
         }
      LV_Delete(RF)
      }
 return


;--- second example reads a file ----
SEARCH2:
Gui,1:submit,nohide
LV_Delete()
loop,read,%F1%
  {
  LR=%A_loopreadline%
  stringsplit,C,LR,`;,
  CX=%C1% %C2% %C3%
  ifinstring,CX,%URLX%
       {
       LV_Add("",C1,C2,C3)
       }
  }
return

;-----------------------------------------------
MLV1B:
Gui,1:Submit,nohide
Gui,1:ListView,MLV1A

    RN:=LV_GetNext("C")
    RF:=LV_GetNext("F")
    GC:=LV_GetCount()

if A_GuiEvent=normal
{
    LV_GetText(C2,A_EventInfo,2)
    GuiControl,1:Text,POS1,%RF%
    soundplay,%C2%
    return
}
return
;================================================

Guiclose:
exitapp



================= 4th EXAMPLE =============================
4th Example Search in a TextFile ( and UP / DOWN )

Code:

;===============================================================
MODIFIED=20100310
;-- NAME1   =TEST LISTVIEW FWD/BACK SEARCH  File
;-- http://www.autohotkey.com/forum/topic4526.html   4th example
;===============================================================

NAME1=LV_TEST
F1=%A_scriptdir%\LV_TestFile.txt
F2=%A_scriptdir%\PrintListview.txt

Gui,1:default
Gui,1:Font,S10 cDefault, Verdana

;------- create a test-file ----
EF=`r
ifnotexist,%F1%
{
 AA=
(
Line1A;1AA;1AAA;1AAAA%EF%
Line2B;2BB;2CCC;2DDDD%EF%
Line3A;3BB;3TEST;3DDDD%EF%
Line4A;4BB;4TEST;4DDDD%EF%
Line5A;5BB;5CCC;5DDDD%EF%
)
Fileappend,%AA%`n,%F1%
}
;---------------------------------

RSSINI =%A_scriptdir%\LV_TEST_INI.txt
ifnotexist,%RSSINI%
   IniWrite,EMPTY    , %RSSINI%  ,srccfile  , KEY1

     ;--------------- SETTINGS MENU ----------------
     menu ,S1 ,Add,&Source          ,MH1
     menu, myMenuBar, Add, SELECT SOURCE FILE  ,:S1
gui,1:menu,MyMenuBar
;----------------------------------------------------


LSW:=(T1+T2+T3+T4+20)    ;Listview width
GSW:=(LSW+30)            ;GUI      width

Gui,1:Add ,  Edit,   x10  y430   w195 h20 vURLX gSEARCH2
Gui,1:Add,Button,default x0  y0 w0   h0  gSEARCH2 ,

Gui,1:Add,Button,x10   y470  w70  h25  g<<  ,<<
Gui,1:Add,Button,x90   y470  w70  h25  g>>  ,>>
Gui,1:Add,Button,x350  y430  w70  h25  gPrintlv  ,PrintLV


Gui,1:Add ,  Edit,   x200  y470  w70 h25 vTOT1 ,
Gui,1:Add ,  Edit,   x290  y470  w70 h25 vPOS1 ,


T1=200       ;column1 width
T2=100       ;column2 width
T3=100       ;column3 width
T4=100       ;column4 width

T1A:=T1
T2A:=T1+T2
T3A:=T1+T2+T3
T4A:=T1+T2+T3+T4

LSW:=(T1+T2+T3+T4+20)    ;Listview width
GSW:=(LSW+30)            ;GUI      width

IniRead,AA1,  %RSSINI%  ,SrccFile  , KEY1
Gui,1:Add,   Edit,   x10   y0  w%LSW%  h20  vSRC2  ,%aa1%        ;show selected file

Gui,1:Add, ListView,x10 y30 h380 w%LSW%  -hdr  grid +hscroll nosorthdr altsubmit vMLV1A gMLV1B, AA|BB|CC|DD
  LV_ModifyCol(1,T1)
  LV_ModifyCol(2,T2)
  LV_ModifyCol(3,T3)
  LV_ModifyCol(4,T4)

gosub,SB

Gui,1:Show, x2 y0 w%GSW% h510,%name1%
return
;-------------------------------

SB:
Gui,1:ListView,MLV1A
IniRead,F1,   %RSSINI%  ,SrccFile  , KEY1
GuiControl,1:text,src2,%F1%
R=0
LV_Delete()
  loop,read,%F1%
  {
  R++
  stringsplit,C,A_LoopReadLine,`;,
  LV_Add("",C1,C2,C3,C4)
  }

GC:=LV_GetCount()
LV_Modify(LV_GetCount(), "Vis")    ;jumps to last row
LV_Modify(GC, "+Select +Focus")    ;focus last row
GuiControl,1:Text,TOT1,%GC%
GuiControl,1:Text,POS1,%R%           ;show position
return

;=================================================



MH1:
MF=
FileSelectFile, MF, 3,%A_Scriptdir%, Bitte wählen Sie Katalog, Text Documents (*.csv; *.txt; *.doc)
if MF=
   return
IniWrite,%mf%    , %RSSINI%  ,srccfile      , KEY1
gosub,SB
return
;---------------------------------------------------------------------




;============== PRINTLV =========================
PRINTLV:
Gui,1:submit,nohide
Gui,1:ListView, A1
ifexist,%F2%
  filedelete,%F2%

RF:=1
GD:=LV_GetCount()

 loop,%gd%
 {
    I2++
     LV_GetText(C1,RF,1)
     LV_GetText(C2,RF,2)
     LV_GetText(C3,RF,3)
     LV_GetText(C4,RF,4)
     Fileappend,%C1%`;%C2%`;%C3%`;%C4%`r`n,%F2%
     RF:=(RF+1)
  }
run,%F2%
return
;=============== END PRINTLV ===================

;================== FORWARD =======================
>>:
Gui,1:submit,nohide
Gui,1: ListView,MLV1A
       if (RF=(GC))
          {
          RF:=(GC)
          LV_GetText(C1,RF,1)
          msgbox, 262208, Forward, Reached END`n%C1% , 2
          return
          }

        LV_Modify(RF, "-Select -Focus")
        RF:=(RF+1)
        LV_Modify(RF, "+Select +Focus")
        LV_GetText(C1,RF,1)
        GuiControl,1:Text,POS1,%RF%
return
;===================================================


;================== BACKWARD =======================
<<:
Gui,1:submit,nohide
Gui,1: ListView,MLV1A
       if RF=1
          {
          LV_Modify(1, "+Select +Focus")
          LV_GetText(C1,RF,1)
          msgbox, 262208, Backward, Reached FirstRow`n%C1% , 2
          return
          }

        LV_Modify(RF, "-Select -Focus")
        RF:=(RF-1)
        LV_Modify(RF, "+Select +Focus")
        LV_GetText(C1,RF,1)
        GuiControl,1:Text,POS1,%RF%
return
;===================================================


;--- second example reads a file ----
SEARCH2:
Gui,1:submit,nohide
LV_Delete()
loop,read,%F1%
  {
  LR=%A_loopreadline%
  stringsplit,C,LR,`;,
  CX=%C1% %C2% %C3% %C4%
  ifinstring,CX,%URLX%
       LV_Add("",C1,C2,C3,C4)
  LV_Modify(GC, "+Select +Focus")
  }
return

;-----------------------------------------------
MLV1B:
Gui,1:Submit,nohide
Gui,1:ListView,MLV1A
    RN:=LV_GetNext("C")
    RF:=LV_GetNext("F")
    GC:=LV_GetCount()

if A_GuiEvent=normal
    {
    LV_GetText(C1,A_EventInfo,1)
    GuiControl,1:Text,POS1,%RF%
    ;msgbox, 262208, NORMAL, %C1% , 2
    return
    }

 ; ARROW KEYS UP / DOWN
 if A_GuiEvent=K
 {
 If GetKeyState("UP","P")
    {
    LV_GetText(C1,RF,1)
    GuiControl,1:Text,POS1,%RF%
    if RF=1
      {
      msgbox, 262208, Backward, Reached FirstRow`n%C1% , 1
      return
      }
    msgbox, 262208, UP, %C1% , 1
    }

 If GetKeyState("DOWN","P")
    {
    LV_GetText(C1,RF,1)
    GuiControl,1:Text,POS1,%RF%
    if (RF=(GC))
       {
       RF:=(GC)
       msgbox, 262208, Forward, Reached LastLine`n%C1% , 1
       return
       }
    msgbox, 262208, DOWN, %C1% , 1
    }
 }


if A_GuiEvent = Doubleclick
{
if (RN=0 or RN="")
   return
MouseGetPos,x,y
 {
if x<%T1A%
   {
  LV_GetText(C1,A_EventInfo,1)
  LV_GetText(C2,A_EventInfo,2)
  LV_GetText(C3,A_EventInfo,3)
  LV_GetText(C4,A_EventInfo,4)
  if C1=
     return
  ControlGet, List, List, Selected, SysListView321,%name1%
  Loop, Parse, List, `;
    {
    Loop, Parse, A_LoopField, %A_Tab%
       {
        A=%A_INDEX%
        if A=1
            MsgBox, ROW=#%RN%  COL=#%A_Index%`nC1=%C1%`nC2=%C2%`nC3=%C3%`nC4=%C4%`nA_Loopfield=%A_LoopField%
        }
    }
  return
   }

if x<%T2A%
   {
  LV_GetText(C1,A_EventInfo,1)
  LV_GetText(C2,A_EventInfo,2)
  LV_GetText(C3,A_EventInfo,3)
  LV_GetText(C4,A_EventInfo,4)
   if C2=
     return
  ControlGet, List, List, Selected, SysListView321,%name1%
  Loop, Parse, List, `;
    {
    Loop, Parse, A_LoopField, %A_Tab%
       {
        A=%A_INDEX%
        if A=2
            MsgBox, ROW=#%RN%  COL=#%A_Index%`nC1=%C1%`nC2=%C2%`nC3=%C3%`nC4=%C4%`nA_Loopfield=%A_LoopField%
        }
    }
  return
   }


if x<%T3A%
   {
  LV_GetText(C1,A_EventInfo,1)
  LV_GetText(C2,A_EventInfo,2)
  LV_GetText(C3,A_EventInfo,3)
  LV_GetText(C4,A_EventInfo,4)
  if C3=
     return
  ControlGet, List, List, Selected, SysListView321,%name1%
  Loop, Parse, List, `;
    {
    Loop, Parse, A_LoopField, %A_Tab%
       {
        A=%A_INDEX%
        if A=3
            MsgBox, ROW=#%RN%  COL=#%A_Index%`nC1=%C1%`nC2=%C2%`nC3=%C3%`nC4=%C4%`nA_Loopfield=%A_LoopField%
        }
    }
  return
   }



if x<%T4A%
   {
  LV_GetText(C1,A_EventInfo,1)
  LV_GetText(C2,A_EventInfo,2)
  LV_GetText(C3,A_EventInfo,3)
  LV_GetText(C4,A_EventInfo,4)
  if C4=
     return
  ControlGet, List, List, Selected, SysListView321,%name1%
  Loop, Parse, List, `;
    {
    Loop, Parse, A_LoopField, %A_Tab%
       {
        A=%A_INDEX%
        if A=4
            MsgBox, ROW=#%RN%  COL=#%A_Index%`nC1=%C1%`nC2=%C2%`nC3=%C3%`nC4=%C4%`nA_Loopfield=%A_LoopField%
        }
    }
  return
   }


 }
}
return
;================================================

Guiclose:
exitapp
;======================= ENDE =======================


5th example
Listview adress order

-adress listview
-product listview

create adress, click column order, check what you want
quick change quantity > doubleclick,overwrite,enter
create an order file

-modify
-addnew
-delete

Code:

MODIFIED=20100315
CREATED =20100313

;===================================================================
/*
TAG=2Listview Listview Edit Add Delete Multiple Lines

-- no CELL EDIT but quick change Quantity (doubleclick, overwrite, enter)

-adress    1st Listview
-product   2nd Listview

-AddNew
-Modify
-Delete multiple marked lines

*/
;===================================================================


#NoTrayIcon
autotrim,off
setworkingdir, %A_scriptdir%
SetBatchlines -1
SendMode Input

;-------------- BLOCK GUI-1 SHOW --------------------------
Filename1=LV_ADRESS     [Rightclick column to EDIT]
setformat,float,0.2

Gui,1:default
Gui,1:Color, 000000
Gui,1:Font,  S10 CDefault , FixedSys

F1=%A_scriptdir%\Adress.txt
F2=%A_scriptdir%\Adress_checked.txt

transform,S,chr,32
VARN00=%S%
VARN01=PRIVAT
VARN02=FIRMA1
VARN03=FIRMA2


;----- for test ----
;Filedelete,%F1%
ifnotexist,%f1%
{
e4=
(
2010-03-10;%varn01%;20100310141522;Meier Walter Herr;Berlin,Dammstrasse 12;Bezahlt;;0`r
2010-03-07;%varn02%;20100307220947;Muller Werner Herr;Frankfurt,Mainstrasse 97;;;1`r
2010-03-09;%varn03%;20100309104534;Schmutz Harry Herr;Luedenscheid,Erfurtestrasse 4;;;0`r
2010-03-08;%varn01%;20100308175255;Hohler Franz Herr;Hamburg,Hafenstrasse 18;Bezahlt;;1`r
2010-03-07;%varn02%;20100307190712;Merkel Franziska Frau;CH-8000 Zurich,Bahnhofstrasse 48;;;0`r
)
Fileappend,%e4%`n,%F1%
}


T1=120       ; DATE
T2=130       ; Privat
T3=150       ; KDNR
T4=100       ; Name
T5=100       ; City
T6=60        ; Bezahlt
T7=100       ; Order
T8=0         ; Checked

T1A:=T1
T2A:=T1+T2
T3A:=T1+T2+T3
T4A:=T1+T2+T3+T4
T5A:=T1+T2+T3+T4+T5
T6A:=T1+T2+T3+T4+T5+T6
T7A:=T1+T2+T3+T4+T5+T6+T7
T8A:=T1+T2+T3+T4+T5+T6+T7+T8


LSW:=(T1+T2+T3+T4+T5+T6+T7+T8+20)
GSW:=(LSW+35)
Gui,1:Add, ListView,grid r17 w%LSW% +hscroll altsubmit checked vMLV1 gMLV2, DATE|FIRMA|KDNR-[X]|Name|City|Bezahlt|Order-[X]|Checked
  LV_ModifyCol(1,T1)
  LV_ModifyCol(2,T2)
  LV_ModifyCol(3,T3)
  LV_ModifyCol(4,T4)
  LV_ModifyCol(5,T5)
  LV_ModifyCol(6,T6)
  LV_ModifyCol(7,T7)
  LV_ModifyCol(8,T8)

  ;LV_ModifyCol(1,"Integer")

  Gui,1:Font, S8 cwhite,FixedSys
  Gui,1:Add, Edit, x12 y325 w%LSW% h20 ReadOnly vC,

  Gui,1:Add, Edit, cBlue x12 y350 w200 h20  vSEARCH1 gSEARCH1,
  Gui,1:Font, S8 cDefault,Verdana

  ;Gui,1:Add,Button, x400    y350 w120  h20 gALLE1      ,SHOWALL
  Gui,1:Add,Button, x400    y380 w120  h20 gPrintCK1   ,PRINT-Checked
  Gui,1:Add,Button, x400    y410 w120  h20 gPrintLV1   ,PRINT-LV
  ;Gui,1:Add,Button, x400    y440 w120  h20 g2ndLV      ,2ND-LV


  Gui,1:Add,Text  , x20    y380 w50 h20 cWhite, Alle
  Gui,1:Add,Text  , x70    y380 w50 h20 cWhite, Checked
  Gui,1:Add,Text  , x140   y380 w50 h20 cWhite, Bezahlt
  Gui,1:Add,Edit  , x10    y405 w50 h20 vIX1 cBlack right,     ;I alle
  Gui,1:Add,Edit  , x70    y405 w50 h20 vIX2 cBlack right,     ;I checked
  Gui,1:Add,Edit  , x130   y405 w50 h20 vIX3 cBlack right,     ;I bezahlt


  Gui,1:Add,Button, x1      y500 w90   h20 gAddNew1 vAddNew1 ,AddNew
  Gui,1:Add,Button, x100    y500 w90   h20 gDelete1 vDelete1 ,Delete

  Gui,1:Add,Button, x230    y500 w90   h20 gSelectall        ,Selectall
  Gui,1:Add,Button, x330    y500 w90   h20 gDeSelectall      ,DeSelectall
  ;Gui,1:Add,Button, x430    y500 w120  h20 gSaveChecked vSaveChecked1   ,Save-Checked

  ;Gui,1:Add,Button, x690    y465 w90 h20 gClearBez        ,CLRBEZ    ;clear alle bezahlte


  ; Gui,1:Add, MonthCal ,x10   y495 w190 h160 ,
  ;Gui,1:Add,DateTime    ,x10   y495 w110 h22 vMydate2 gDatecalc,
gosub,LB
;GSW:=800
Gui,1:Show, x2 y0 w%GSW% h560,%filename1%
return
;-------------- END BLOCK GUI-1 SHOW --------------------------

;------------------ BLOCK READ LV-1 adress -------------------
LB:
Gui,1:default
Gui,1:submit,nohide
GuiControl,1:Enable,AddNew1
GuiControl,1:Enable,Delete1
;GuiControl,1:Enable,SaveChecked1
I1=0
I3=0
LV_Delete()
  loop,read,%F1%
   {
   stringsplit,C,A_LoopReadLine,`;,

   VarOut := C6
     if VarOut is not space        ;bezahlt
       I3++

   I1++
   LV_Add("",C1,C2,C3,C4,C5,C6,C7,C8)

   LV_GetText(B8,I1,8)
   if B8=1
        LV_Modify(I1, "check")
   }

;LV_ModifyCol(1, "SortAsc")
;LV_ModifyCol(1, "Logical SortAsc")
;LV_ModifyCol(1,"integer")
LV_ModifyCol(1, "Sort")
LV_Modify(LV_GetCount(), "Vis")
GuiControl,1:,IX1,%I1%
GuiControl,1:,IX3,%I3%
return
;------------------ END BLOCK READ LV-1 adress ------------------------


;----------------- BLOCK GUI-1 close -----------
Guiclose:
gosub,savechecked
exitapp
;----------------- END BLOCK GUI-1 close -------


;-------------- BLOCK SELECT DESELECT ----------
SELECTALL:
LV_Modify(0, "check")
I2  =0
RNM =0
Loop % LV_GetCount()
    {
    RNM := LV_GetNext(RNM,"checked")
    if not RNM
        break
    I2++
    }
GuiControl,1:,IX2,%I2%
return



DESELECTALL:
LV_Modify(0, "-check")
GuiControl,1:,IX2,0
return
;-------------- END BLOCK SELECT DESELECT ----------


;---------------- read all not used ---------
ALLE1:
VARX=
gosub,lb
return
;---------------------------------------------



;============ BLOCK LISTVIEW-1 adress =========================
MLV2:
   GuiControlGet,MLV1
   Gui,1:Submit,nohide

     RN:=LV_GetNext("C")
     RF:=LV_GetNext("F")
     GC:=LV_GetCount()


   I2  =0
   RNM =0
   Loop
      {
      RNM := LV_GetNext(RNM,"checked")
      if not RNM
         break
      I2++
      }
    GuiControl,1:,IX2,%I2%


   if A_GuiEvent=Normal
     {
     if (RN="" OR RN=0)
         return
    MouseGetPos,x,y
        {
       if x<%T1A%
          return

       if x<%T2A%
          return

       if x<%T3A%
          {
          LV_GetText(C1,A_EventInfo,1)
          LV_GetText(C3,A_EventInfo,3)
          LV_GetText(C4,A_EventInfo,4)
          Q1=
          Q2=
          Q3=
          stringsplit,Q,C4,%s%,
          FOLD2=%A_scriptdir%\KUNDEN\%c3%_%q1%
          ifexist,%fold2%
              run,%fold2%
          return
          }

       if x<%T4A%
          return

       if x<%T5A%
          return

       if x<%T6A%
          return

       if x<%T7A%
          {
          LV_GetText(C1,A_EventInfo,1)
          LV_GetText(C2,A_EventInfo,2)
          LV_GetText(C3,A_EventInfo,3)
          LV_GetText(C4,A_EventInfo,4)
          LV_GetText(C5,A_EventInfo,5)
          LV_GetText(C6,A_EventInfo,6)
          LV_GetText(C7,A_EventInfo,7)
          LV_GetText(C8,A_EventInfo,8)
          Q1=
          Q2=
          Q3=
          stringsplit,Q,C4,%s%,
          F11=%A_scriptdir%\KUNDEN\%c3%_%q1%\%c3%_%A_now%.txt
          ifnotexist,%f11%
            gosub,2ndLV
          else
            run,%f11%
          return
          }


       if x<%T8A%
          return

        }
    }


   if A_GuiEvent = RightClick
      {
     LV_GetText(C1,A_EventInfo,1)
     LV_GetText(C2,A_EventInfo,2)
     LV_GetText(C3,A_EventInfo,3)
     LV_GetText(C4,A_EventInfo,4)
     LV_GetText(C5,A_EventInfo,5)
     LV_GetText(C6,A_EventInfo,6)
     LV_GetText(C7,A_EventInfo,7)
     LV_GetText(C8,A_EventInfo,8)

     goto, Edit1
     return
      }
return
;============ END BLOCK LISTVIEW-1 adress ==============




;------------- BLOCK SEARCH LV-1 adress -------------------
SEARCH1:
Gui,1:submit,nohide
gosub,lb
GuiControl,1:Disable,AddNew1
GuiControl,1:Disable,Delete1
;GuiControl,1:Disable,SaveChecked1
GuiControl,1:Text,Edit1,%NOTHING%

if search1=
  goto,lb

LV_Delete()
I=0
  loop,read,%F1%
 {
  LR=%A_loopReadLine%
  C1  =
  C2  =
  C3  =
  C4  =
  C5  =
  C6  =
  C7  =
  C8  =
  if (search1<>"")
     {
     if LR contains %search1%
         {
         stringsplit,C,A_LoopReadLine,`;,
         I++
         LV_Add("",C1,C2,C3,C4,C5,C6,C7,C8)
         }
      }
  else
  continue
   }

  LV_Modify(LV_GetCount(), "Vis")     ;scrollt nach unten
return
;------------- END BLOCK SEARCH LV-1 adress -------------------





;---------------- BLOCK ADDNEW LV-1 adress -------------------
AddNew1:
Name2=AddNew
IfWinExist, %Name2%
return

    {
    C1=
    C2=
    C3=
    C4=
    C5=
    C6=
    C7=
    C8=
    }

     Gui,4:Font,  S10 CDefault , FixedSys
     Gui,4:Add,DateTime,x80  y5  w180 h20 vTB ,%A41%

     Gui,4:Add,Text,        x1  y35  w80  h20,Firma
     Gui,4:Add,DropDownList,x80 y35  w420  vA42, %VARN00%|%VARN01%|%VARN02%|%VARN03%

     ;Gui,4:Add,Text,        x1  y65  w80  h20,KDNR
     ;Gui,4:Add,Edit, x80 y65   w420 h20 vA43 readonly,%C3%

     Gui,4:Add,Text, x1  y95   w80  h20,Name
     Gui,4:Add,Edit, x80 y95   w420 h20 vA44,%C4%

     Gui,4:Add,Text, x1  y125  w80  h20,City
     Gui,4:Add,Edit, x80 y125  w420 h20 vA45,%C5%


     ;Gui,4:Add,Text, x1  y155  w80  h20,BEZAHLT
     ;Gui,4:Add,Edit, x80 y155  w420 h20 vA46 readonly,%C6%

     ;Gui,4:Add,Text, x1  y185  w80  h20,ORDER
     ;Gui,4:Add,Edit, x80 y185  w420 h20 vA47 readonly,%C7%

     ;Gui,4:Add,Text, x1  y215  w80  h20,CHECKED
     ;Gui,4:Add,Edit, x80 y215  w420 h20 vA48 readonly ,%C8%


   ;Gui,4:Add, Button, x510 y130 w85 h25 gBEZAHLT4,<Bezahlt


   Gui,4:Add, Button, x550 y180 w40 h25 gOK4, OK
   Gui,4:Show, x2 y110 w600 h210,%name2%
   Guicontrol,4:choosestring,A42,%varn01%
   return
;-----------------------------------------------


   ;-----------
   4GuiClose:
   4GuiEscape:
   Gui,4:Destroy
   Gui,1:Default
   return
   ;-----------

   ;Bezahlt4:
   ;GuiControl,4:Text,A45,Bezahlt

   OK4:
   Gui,4:submit

stringmid,YR4,TB,1,4
stringmid,MN2,TB,5,2
stringmid,DY2,TB,7,2
TDS=%YR4%-%MN2%-%DY2%
TDS2=%DY2%.%MN2%%YR4%
A43=%tb%

   FileAppend,%TDS%;%A42%;%A43%;%A44%;%A45%;%A46%;%A47%;0`r`n,%F1%
   Gui,4:Destroy
   Gui,1:Default
   A41=
   Gosub,LB
return
;---------------- END BLOCK ADDNEW LV-1 adress -------------------





;----------- BLOCK EDIT LV-1 adress  --------------------------
Edit1:
Gui,1:submit,nohide
Name3=Edit1
IfWinExist, %Name3%
return


  Gui,6:Font,  S10 CDefault , FixedSys

  Gui,6:Add,Text, x1  y5   w80  h20,DATE
  Gui,6:Add,Edit, x80 y5   w420 h20 vA61,%C1%

  Gui,6:Add,DropDownList,x80  y35  w420 r20 vA62, %VARN00%|%VARN01%|%VARN02%|%VARN03%

  Gui,6:Add,Text, x1  y65  w80  h20,KDNR
  Gui,6:Add,Edit, x80 y65  w420 h20 vA63 readonly,%C3%

  Gui,6:Add,Text, x1  y95  w80  h20,Name
  Gui,6:Add,Edit, x80 y95  w420 h20 vA64,%C4%

  Gui,6:Add,Text, x1  y125  w80  h20,City
  Gui,6:Add,Edit, x80 y125  w420 h20 vA65,%C5%

  Gui,6:Add,Text, x1  y155  w80  h20,BEZAHLT
  Gui,6:Add,Edit, x80 y155  w420 h20 vA66 readonly,%C6%

  Gui,6:Add,Text, x1  y185  w80  h20,ORDER
  Gui,6:Add,Edit, x80 y185  w420 h20 vA67 readonly,%C7%

  Gui,6:Add,Text, x1  y215  w80  h20,Checked
  Gui,6:Add,Edit, x80 y215  w420 h20 vA68 readonly,%C8%

  Gui,6:Add, Button, x510 y155 w85  h25 gBEZAHLT6    ,<Bezahlt
  Gui,6:Add, Button, x605 y155 w65  h25 gBEZAHLT6clr ,<Clear

  Gui,6:Add, Button, x550 y200 w40 h25 gOK6, OK
  GuiControl,6:Choose,A62,%C2%
  GuiControl,6:Choose,A63,%C3%
  Gui,6:Show, x2 y110 w670 h260,%Name3%
  return
  ;-----------
  6GuiClose:
  6GuiEscape:
  Gui,6:Destroy
  Gui,1:Default
  return
  ;-----------


  Bezahlt6:
  GuiControl,6:Text,A66,Bezahlt
  goto,OK6

  Bezahlt6clr:
  GuiControl,6:Text,A66,

  OK6:
  Gui,6:submit,nohide

  ;if A62=
  ;   A62=%C2%

   FileRead,AA,%F1%
   FileDelete,%F1%
   StringReplace,BB,AA,%C1%;%C2%;%C3%;%C4%;%C5%;%C6%;%C7%;%c8%,%A61%;%A62%;%A63%;%A64%;%A65%;%A66%;%A67%;%A68%
   FileAppend,%BB%,%F1%
  Gui,6:Destroy
  Gui,1:Default
  gosub,LB
  GuiControl,1:Text,Search1,%NOTHING%
return
;----------- END BLOCK EDIT LV-1 adress  --------------------------





;--------- BLOCK DELETE MULTIPLELINES LV-1 adress -----------------
Delete1:
C4 =
RF = 0      ;First line
RFL =
Loop
 {
   RF:=LV_GetNext(RF)
   if RF=0
      break
   RFL = %RF%|%RFL%
   LV_GetText(C4_Temp, RF, 4)
   C4 = %C4%`n%C4_Temp%
 }

if C4 !=
 {
   MsgBox, 4, ,Want you really delete %C4% ?
   IfMsgBox,No
      Return
   Else
    {
      Loop, parse, RFL, |
             LV_Delete(A_LoopField)

     filedelete,%F1%
     Loop % LV_GetCount()
       {
        BX1=
        BX2=
        BX3=
        BX4=
        BX5=
        BX6=
        BX7=
        BX8=
        LV_GetText(BX1,A_INDEX,1)
        LV_GetText(BX2,A_INDEX,2)
        LV_GetText(BX3,A_INDEX,3)
        LV_GetText(BX4,A_INDEX,4)
        LV_GetText(BX5,A_INDEX,5)
        LV_GetText(BX6,A_INDEX,6)
        LV_GetText(BX7,A_INDEX,7)
        LV_GetText(BX8,A_INDEX,8)

        e5=%e5%%BX1%;%BX2%;%BX3%;%BX4%;%BX5%;%BX6%;%BX7%;%BX8%`r`n
        }
     Fileappend,%e5%,%f1%
    }
 }
C4 =
RF = 0
RFL =
e5=
Gosub,LB
return
;--------- END BLOCK DELETE MULTIPLELINES LV-1 adress -----------------



;--------- BLOCK PRINTLISTVIEW-1 print what you see -------------
Printlv1:
Gui,1:submit,nohide
Gui,1:ListView, MLV1

TAB1 =10
TAB2 =18
TAB3 =20
TAB4 =12
TAB5 =12
TAB6 =10
TAB7 =10
TAB8 =10

Filedelete,%F2%
RF:=1
GD:=LV_GetCount()
I2=0

 loop,%gd%
 {
  I2++
     LV_GetText(C1,RF,1)
     LV_GetText(C2,RF,2)
     LV_GetText(C3,RF,3)
     LV_GetText(C4,RF,4)
     LV_GetText(C5,RF,5)
     LV_GetText(C6,RF,6)
     LV_GetText(C7,RF,7)
     LV_GetText(C8,RF,8)

     C1 := LP(C1,TAB1,S,"R")
     C2 := LP(C2,TAB2,S,"R")
     C3 := LP(C3,TAB3,S,"R")
     C4 := LP(C4,TAB4,S,"R")
     C5 := LP(C5,TAB5,S,"R")
     C6 := LP(C6,TAB6,S,"R")
     C7 := LP(C7,TAB7,S,"R")
     C8 := LP(C8,TAB8,S,"R")

     Fileappend,%C1% %C2% %C3% %C4% %C5% %C6% %C7% %C8%`r`n,%F2%
     RF:=(RF+1)
 }
run,%F2%
RF=0
return
;--------- END BLOCK PRINTLISTVIEW-1 print what you see -------------





;--------- BLOCK PRINTLISTVIEW-1 print CHECKED -------------
PrintCK1:
Gui,1:submit,nohide
Gui,1:ListView, MLV1

TAB1 =10
TAB2 =18
TAB3 =20
TAB4 =12
TAB5 =12
TAB6 =12
TAB7 =12
TAB8 =10

Filedelete,%F2%
RF:=1
GD:=LV_GetCount()
I2=0

 loop,%gd%
 {
  I2++
     LV_GetText(C1,RF,1)
     LV_GetText(C2,RF,2)
     LV_GetText(C3,RF,3)
     LV_GetText(C4,RF,4)
     LV_GetText(C5,RF,5)
     LV_GetText(C6,RF,6)
     LV_GetText(C7,RF,7)
     LV_GetText(C8,RF,8)

     C1 := LP(C1,TAB1,S,"R")
     C2 := LP(C2,TAB2,S,"R")
     C3 := LP(C3,TAB3,S,"R")
     C4 := LP(C4,TAB4,S,"R")
     C5 := LP(C5,TAB5,S,"R")
     C6 := LP(C6,TAB6,S,"R")
     C7 := LP(C7,TAB7,S,"R")
     C8 := LP(C8,TAB8,S,"R")

     if C8=1
     Fileappend,%C1% %C2% %C3% %C4% %C5% %C6% %C7%`r`n,%F2%
     RF:=(RF+1)
 }
run,%F2%
RF=0
return
;--------- END BLOCK PRINTLISTVIEW-1 print CHECKED -------------



;------------ BLOCK LV-1 checked 0/1 speichern ---------------------------
SaveChecked:
     K1=0
     K2=0
     filedelete,%F1%
     Loop % LV_GetCount()
       {
        K1++
        BX1=
        BX2=
        BX3=
        BX4=
        BX5=
        BX6=
        BX7=

        LV_GetText(BX1,A_INDEX,1)
        LV_GetText(BX2,A_INDEX,2)
        LV_GetText(BX3,A_INDEX,3)
        LV_GetText(BX4,A_INDEX,4)
        LV_GetText(BX5,A_INDEX,5)
        LV_GetText(BX6,A_INDEX,6)
        LV_GetText(BX7,A_INDEX,7)

        if K1=1
          K2 := LV_GetNext(K2,"checked")
        if (K1=K2)
          {
          Fileappend,%BX1%;%BX2%;%BX3%;%BX4%;%BX5%;%BX6%;%BX7%;1`r`n,%F1%
          K2 := LV_GetNext(K2,"checked")
          }
        else
          Fileappend,%BX1%;%BX2%;%BX3%;%BX4%;%BX5%;%BX6%;%BX7%;0`r`n,%F1%
        }
return
;------------ END BLOCK LV-1 checked 0/1 speichern ---------------------------













;======================== 2ND LISTVIEW-2 Products ============================
;----------------- BLOCK GUI SHOW LV-2 ---------------
2NDLV:
Gui,1:submit,nohide
FilenameLV2=Artikel  [DELETE=Mark lines and then Rightclick]  [EDIT=doubleclick]
IfWinExist, %FilenameLV2%
return

;Gui,2:Color, 000000
Gui,2:Font,  S10 CDefault , FixedSys

setformat,float,0.2

F3=%A_scriptdir%\Artikel.txt
F4=%A_scriptdir%\Artikel_Checked.txt

;----- for test ----
;Filedelete,%F3%
ifnotexist,%f3%
{
e5=
(
1;Auto Ford Taunus 1970;100.00;USED;0`r
1;Radio Grundig Concert Boy 1968;20.00;USED;1`r
1;Photocamera Panasonic DMC-TZ7;10.00;NEU;0`r
1;Sharp Basic Rechner PC-1201;30.00;USED;1`r
1;Television Sony 70-cm;10.00;NEU;0`r
)
Fileappend,%e5%`n,%F3%
}
e5=


Gui,2:default

L1:=60        ;Anzahl
L2:=240       ;Product
L3:=100       ;Preis
L4:=70        ;ART
L5:=50        ;Checked

LSW2:=(L1+L2+L3+L4+L5+20)
GSW2:=(LSW2+50)
; logical
Gui,2:Add, ListView,grid r17 w%LSW2% +hscroll altsubmit checked v2MLV1 g2MLV2, Anzahl|Product|Preis|Zustand|Checked
  LV_ModifyCol(1,L1)
  LV_ModifyCol(2,L2)
  LV_ModifyCol(3,L3)
  LV_ModifyCol(4,L4)
  LV_ModifyCol(5,L5)

  LV_ModifyCol(1,"Integer")
  LV_ModifyCol(3,"Integer")

  Gui,2:Add,Edit  , x10    y320 w280  h20 vSearch2 gSearch2 cBlack ,           ;Search2

  Gui,2:Add,Edit  , x310   y320 w120 h20 vTotal1 cRed right,     ;Total

  Gui,2:Add,Text  , x20    y360 w50 h20 cWhite, Alle
  Gui,2:Add,Text  , x70    y360 w50 h20 cWhite, Checked
  Gui,2:Add,Edit  , x10    y385 w50 h20 v2IX1 cBlack right,     ;I alle
  Gui,2:Add,Edit  , x70    y385 w50 h20 v2IX2 cBlack right,     ;I checked

  Gui,2:Add,Button, x10     y405 w120   h20 g2Selectall   v2Selectall      ,Selectall
  Gui,2:Add,Button, x150    y405 w120   h20 g2DeSelectall v2DeSelectall    ,DeSelectall

  Gui,2:Add,Edit  , x10     y430 w370  h20 vKDNR1 cBlue ,        ;Kunde
  Gui,2:Add,Button, x390    y430 w90   h20 g2SaveChecked vSaveChecked2   ,<--OK--

  Gui,2:Add,Button, x10     y450 w90   h20 gAddNew2 vAddNew2 ,AddNew2


gosub,2LB
Gui,2:Show, x200 y10 w%GSW2% h500,%FilenameLV2%
return
;----------------- END BLOCK GUI SHOW LV-2 ---------------


2Guiclose:
Gui,1:default
Gui,2:destroy
return

;------------ BLOCK LV-2 READ ------------------
2LB:
Gui,2:submit,nohide
Gui,2:default
Gui, 2:ListView,2MLV1

I1=0
I2=0

; A_INDEX
LV_Delete()
  loop,read,%F3%
   {
   stringsplit,H,A_LoopReadLine,`;,
   I1++
   LV_Add("",H1,H2,H3,H4,H5)
   LV_GetText(B5,I1,5)
   if B5=1
      {
      I2++
      LV_Modify(I1, "check")
      }
   }

;LV_ModifyCol(1, "SortAsc")
;LV_ModifyCol(1, "Logical SortAsc")
;LV_ModifyCol(1,"integer")
;LV_ModifyCol(1, "Sort")

LV_Modify(LV_GetCount(), "Vis")
GuiControl,2:,2IX1,%I1%
GuiControl,2:,2IX2,%I2%
GuiControl,2:,KDNR1,Bestellung für KUNDE=%c3%-%c4%
return
;------------ END BLOCK LV-2 READ ------------------






;---------  try ---- BLOCK SEARCH LV-2 product -------------------
SEARCH2:
Gui,2:submit,nohide
gosub,2lb
GuiControl,2:Disable,AddNew2

if search2=
  goto,2lb

LV_Delete()
I=0
  loop,read,%F3%
 {
  LR=%A_loopReadLine%
  r1  =
  r2  =
  r3  =
  r4  =
  r5  =
  if (search2<>"")
     {
     if LR contains %search2%
         {
         stringsplit,R,A_LoopReadLine,`;,
         I++
         LV_Add("",r1,r2,r3,r4,r5)
         }
      }
  else
  continue
   }

  LV_Modify(LV_GetCount(), "Vis")     ;scrollt nach unten
return
;------------- END BLOCK SEARCH LV-2 products  -------------------















;===========  BLOCK LV-2 ============================
2MLV2:
   ;GuiControlGet,2MLV1
   Gui,2:Submit,nohide
   Gui, 2:ListView,2MLV1

     RN:=LV_GetNext("C")
     RF:=LV_GetNext("F")
     GC:=LV_GetCount()

   I2  =0
   2RNM =0
   P3:=0
   Y3:=0

   Loop
      {
      2RNM := LV_GetNext(2RNM,"checked")
      if not 2RNM
         break
      I2++
      LV_GetText(P1,2RNM,1)   ;Anzahl
      LV_GetText(P3,2RNM,3)   ;Preis
      PR:=(P1*P3)
      Y3:=(PR+Y3)             ;Addiere Preis column3 which is checked
      }
    GuiControl,2:,2IX2,%I2%
    GuiControl,2:,total1,%Y3%


   if A_GuiEvent = Normal
      {
      return
      }

   if A_GuiEvent = DoubleClick
      {
     LV_GetText(H1,A_EventInfo,1)
     LV_GetText(H2,A_EventInfo,2)
     LV_GetText(H3,A_EventInfo,3)
     LV_GetText(H4,A_EventInfo,4)
     LV_GetText(H5,A_EventInfo,5)
     gosub,editLV2
     return
      }

   if A_GuiEvent = Rightclick
      {
     gosub,delete2
     return
      }


return
;===========  END BLOCK LV-2 ============================


;------------- BLOCK SELECT DESELECT LV-2 ------------
2SELECTALL:
LV_Modify(0, "check")
I2  =0
2RNM =0
   P3:=0
   Y3:=0

Loop % LV_GetCount()
    {
    2RNM := LV_GetNext(2RNM,"checked")
    if not 2RNM
        break
    I2++
    LV_GetText(P3,2RNM,3)
    Y3:=(P3+Y3)             ;Addiere Preis column3 which is checked
    }
GuiControl,2:,2IX2,%I2%
GuiControl,2:,total1,%Y3%
return


;---------------------
2DESELECTALL:
LV_Modify(0, "-check")
GuiControl,2:,2IX2,0
GuiControl,2:,total1,0
return
;------------- END BLOCK SELECT DESELECT LV-2 ------------



;---------------------- 2 write checked  not used ------------
2WriteChecked:
     filedelete,%F3%
     Loop % LV_GetCount()
       {
        K1++
        CX1=
        CX2=
        CX3=
        CX4=

        LV_GetText(CX1,A_INDEX,1)
        LV_GetText(CX2,A_INDEX,2)
        LV_GetText(CX3,A_INDEX,3)
        LV_GetText(CX4,A_INDEX,4)

        if K1=1
          K2 := LV_GetNext(K2,"checked")
        if (K1=K2)
          {
          Fileappend,%CX1%;%CX2%;%cx3%;%cx4%;1`r`n,%F3%
          K2 := LV_GetNext(K2,"checked")
          }
        else
          Fileappend,%CX1%;%CX2%;%cx3%;%cx4%;0`r`n,%F3%
        }
return
;------------------------ END save checked not used --------------------






;------------ BLOCK LV-2  checked 0/1 speichern and write ---------------------------
2SaveChecked:
Gui,1:submit,nohide
q1=
q2=
q3=
stringsplit,Q,C4,%s%,
FOLD1=%A_scriptdir%\KUNDEN\%c3%_%q1%
ifnotexist,%fold1%
     FileCreateDir,%fold1%
sleep,500

TB=%A_now%
stringmid,YR4,TB,1,4
stringmid,MN2,TB,5,2
stringmid,DY2,TB,7,2
TDS=%YR4%-%MN2%-%DY2%

w1=
w2=
stringsplit,W,C5,`,,

q1=
q2=
q3=
stringsplit,Q,C4,%s%,


TABLM =5                   ;--Left margin
LMM := LP(LMM,TABLM,S,"R")


TABL1=42

DL1:="Datum    = " . tds
DL2:="Absender = Uwe Mayer"
DL3:="City     = Mannheim"
DL4:="Strasse  = Neckarstrasse 17"

DR1:="Kundennummer = " . c3
DR2:="Name         = " . q1 " " . q2
DR3:="City         = " . w1
DR4:="Strasse      = " . w2


DL1 := LP(DL1,TABL1,S,"L")   ;reserve space TABL1 (Left1-48)
DL2 := LP(DL2,TABL1,S,"L")
DL3 := LP(DL3,TABL1,S,"L")
DL4 := LP(DL4,TABL1,S,"L")


e21=
(
`r
%lmm%%dl1%%dr1%`r
%lmm%%dl2%%dr2%`r
%lmm%%dl3%%dr3%`r
%lmm%%dl4%%dr4%`r
`r
`r
`r
%lmm%Guten Tag %q3% %q1% ,`r
%lmm%Anbei ihre Bestellung vom %tds%`r
`r
`r
`r
)

Fileappend,%e21%`n,%f11%


TAB1 =4   ;Anzahl
TAB2 =40  ;Product
TAB3 =10  ;Preis
TAB4 =8   ;Zustand

TABPR=11  ;Preis Anzahl*product
TABY3=11  ;Preis Total

     K1=0
     K2=0
     PR:=0
     Y3:=0





;--- reads Listview,  in case search dont overwrite F3 -------------
     ;filedelete,%F3%
     Loop % LV_GetCount()
       {
        K1++
        BX1=
        BX2=
        BX3=
        BX4=

        CX1=
        CX2=
        CX3=
        CX4=

        LV_GetText(BX1,A_INDEX,1)
        LV_GetText(BX2,A_INDEX,2)
        LV_GetText(BX3,A_INDEX,3)
        LV_GetText(BX4,A_INDEX,4)

        LV_GetText(CX1,A_INDEX,1)
        LV_GetText(CX2,A_INDEX,2)
        LV_GetText(CX3,A_INDEX,3)
        LV_GetText(CX4,A_INDEX,4)


        BX1 := LP(BX1,TAB1,S,"R")
        BX2 := LP(BX2,TAB2,S,"L")
        BX3 := LP(BX3,TAB3,S,"R")
        BX4 := LP(BX4,TAB4,S,"R")
        stringmid,bx2,bx2,1,tab2

        if K1=1
          K2 := LV_GetNext(K2,"checked")

        ;-- 1; or cx1;
        if (K1=K2)
          {
          ;Fileappend,1;%CX2%;%cx3%;%cx4%;1`r`n,%F3%
            LV_GetText(P1,A_INDEX,1)
            LV_GetText(P3,A_INDEX,3)
            PR:=(P1*P3)
            Y3:=(PR+Y3)             ; Multiply Preis column3
            PR := LP(PR,TABPR,S,"R")

          Fileappend,%LMM%%BX1%  %BX2%  %bx3%%bx4%%PR%`r`n,%F11%       ;write to ORDER
          K2 := LV_GetNext(K2,"checked")
          }
        ;else
          ;Fileappend,1;%CX2%;%cx3%;%cx4%;0`r`n,%F3%
        }


   FileRead,AA,%F1%
   FileDelete,%F1%
   StringReplace,BB,AA,%C1%`;%C2%`;%C3%`;%C4%`;%C5%`;%C6%`;%C7%`;%C8%,%C1%`;%C2%`;%C3%`;%C4%`;%C5%`;%C6%`;ORDED`;%C8%
   FileAppend,%BB%,%F1%

TABPR2:=(TAB1+TAB2+TAB3+TAB4+TABPR+4)
Y3:=LP(Y3,TABPR2,S,"R")

ifexist,%f11%
   {
   Fileappend,%LMM%-----------------------------------------------------------------------------`r`n%LMM%%Y3%`r`n,%f11%
   Fileappend,`r`n`r`n          Mit freundlichen Grüssen`r`n                    Uwe`r`n,%f11%
   run,%f11%
   }
gosub,LB
gui,2:destroy
return
;------------ END BLOCK LV-2  checked 0/1 speichern and write ---------------------------






;---------------- BLOCK ADDNEW2 LV-2 product -------------------
AddNew2:
Name9=AddNew2
IfWinExist, %Name9%
return

    {
    H1=
    H2=
    H3=
    H4=
    H5=
    }

VARP01=NEU
VARP02=USED
A93 :=0


     Gui,9:Font,  S10 CDefault , FixedSys

     ;Gui,9:Add,Text, x1  y5   w80  h20,Anzahl
     ;Gui,9:Add,Edit, x80 y5   w420 h20 vA91 readonly,%H1%

     Gui,9:Add,Text, x1  y35  w80  h20,Product
     Gui,9:Add,Edit, x80 y35  w420 h20 vA92,%H2%

     Gui,9:Add,Text, x1  y65  w80  h20,Preis
     Gui,9:Add,Edit, x80 y65  w420 h20 vA93,%H3%

     Gui,9:Add,Text,        x1  y95  w80  h20,ZUSTAND
     Gui,9:Add,DropDownList,x80 y95  w420  vA94, %VARP01%|%VARP02%

     ;Gui,9:Add,Text, x1  y125  w80  h20,CHECKED
     ;Gui,9:Add,Edit, x80 y125  w420 h20 vA95 readonly ,%H5%


   Gui,9:Add, Button, x550 y180 w40 h25 gOK9, OK
   Gui,9:Show, x2 y110 w600 h210,%name9%
   Guicontrol,9:choosestring,A94,%varp01%
   return
;-----------------------------------------------


   ;-----------
   9GuiClose:
   9GuiEscape:
   Gui,9:Destroy
   Gui,2:Default
   return
   ;-----------


   OK9:
   Gui,9:submit

   if A93 =
      A93 :=0

      A93 +=0.00


   FileAppend,1;%A92%;%A93%;%A94%;0`r`n,%F3%
   Gui,9:Destroy
   Gui,2:Default
   A91=
   Gosub,2LB
return
;---------------- END BLOCK ADDNEW2 LV-2 product -------------------







;--------- BLOCK DELETE MULTIPLELINES LV-2 product -----------------
Delete2:
C2 =
RF = 0      ;First line
RFL =
Loop
 {
   RF:=LV_GetNext(RF)
   if RF=0
      break
   RFL = %RF%|%RFL%
   LV_GetText(C2_Temp, RF, 2)
   C2 = %C2%`n%C2_Temp%
 }

e9=
if C2 !=
 {
   MsgBox, 4, ,Want you really delete %C2% ?
   IfMsgBox,No
      Return
   Else
    {
      Loop, parse, RFL, |
             LV_Delete(A_LoopField)

     filedelete,%F3%
     Loop % LV_GetCount()
       {
        BX1=
        BX2=
        BX3=
        BX4=
        BX5=
        LV_GetText(BX1,A_INDEX,1)
        LV_GetText(BX2,A_INDEX,2)
        LV_GetText(BX3,A_INDEX,3)
        LV_GetText(BX4,A_INDEX,4)
        LV_GetText(BX5,A_INDEX,5)

        e9=%e9%%BX1%;%BX2%;%BX3%;%BX4%;%BX5%`r`n
        }
     Fileappend,%e9%,%f3%
    }
 }
C2 =
RF = 0
RFL =
e9=
Gosub,2LB
return
;--------- END BLOCK DELETE MULTIPLELINES LV-1 adress -----------------







;------------ BLOCK EDIT LV-2 ---------------------------------
EDITLV2:
   Gui,2:Submit,nohide
   Gui, 2:ListView,2MLV1

Name4=EditLV2
IfWinExist, %Name4%
return

A73 :=0
VARP01=NEU
VARP02=USED

  Gui,7:Font,  S10 CDefault , FixedSys

  Gui,7:Add,Text, x1  y5   w80  h20,ANZAHL
  Gui,7:Add,Edit, x80 y5   w420 h20 vA71,%H1%

  Gui,7:Add,Text, x1  y35   w80  h20,PRODUCT
  Gui,7:Add,Edit, x80 y35   w420 h20 vA72,%H2%

  Gui,7:Add,Text, x1  y65  w80  h20,PREIS
  Gui,7:Add,Edit, x80 y65  w420 h20 vA73,%H3%

  Gui,7:Add,Text,        x1  y95  w80  h20,ART
  Gui,7:Add,DropDownList,x80 y95  w420  vA74, %VARP01%|%VARP02%

  Gui,7:Add,Text, x1  y125  w80  h20,CHECKED
  Gui,7:Add,Edit, x80 y125  w420 h20 vA75 readonly,%H5%

  Gui,7:Add, Button, x550 y200 w40 h25 default gOK7, OK
  Gui,7:Show, x2 y110 w600 h240,%Name4%
  GuiControl,7:Focus,A71
  ;Guicontrol,7:choosestring,A74,%varp01%
  GuiControl,7:Choose,A74,%H4%

  return
  ;-----------
  7GuiClose:
  7GuiEscape:
  Gui,7:Destroy
  Gui,1:Default
  return
  ;-----------


;--------------- 7-OK ------------
  OK7:
  Gui,7:submit,nohide

  Gui,2:default
  Gui,2:ListView,2MLV1


         if A73 =
            A73 :=0

       A73 +=0.00




P1:=0
P3:=0
Gui +LastFound      ; needs for SendMessage
     e5=
     Loop % LV_GetCount()
       {
        B1=
        B2=
        B3=
        B4=
        B5=

        LV_GetText(B1,A_INDEX,1)
        LV_GetText(B2,A_INDEX,2)
        LV_GetText(B3,A_INDEX,3)
        LV_GetText(B4,A_INDEX,4)
        LV_GetText(B5,A_INDEX,5)

        SendMessage, 4140, A_INDEX - 1, 0xF000, SysListView321   ;show if it is checked
        IsChecked := (ErrorLevel >> 12) - 1
        if IsChecked=0
           b5=0
        else
           b5=1
         e5=%e5%%B1%;%B2%;%B3%;%b4%;%b5%`r`n
        }


new1=
LV_Delete()

Loop, Parse,e5, `n
    {
    new1=%a_loopfield%
    if new1=
       break
    stringreplace,new1,new1,%H1%`;%H2%`;%H3%`;%H4%,%A71%`;%A72%`;%A73%`;%A74%
    stringsplit,M,new1,`;,
    stringreplace,M5,M5,`r,
    LV_Add("",M1,M2,M3,M4,M5)
    }
new1=
e5=


I2=0
Y3:=0
P1:=0
P3:=0
Loop % LV_GetCount()
    {
    B5=
    LV_GetText(B5,A_INDEX,5)
    if B5=1
       {
       I2++
       LV_Modify(A_INDEX, "check")
       LV_GetText(P1,A_INDEX,1)        ;Anzahl
       LV_GetText(P3,A_INDEX,3)        ;Preis
       PR:=(P1*P3)
       Y3:=(PR+Y3)             ;Total Addiere Preis column3 which is checked
       }
    }


  Gui,7:Destroy
  ;Gui,2:Default
  ;gosub,LB2
e5=
e6=
return
;------------ END BLOCK EDIT LV-2 ---------------------------------




;####################### FUNCTION PLACE KEEPER LinePadding BoBo ##################
/*
LinePadding("Text",20,A_Space,"L")

1. Parameter: Text/Wert welcher in der Zeile übergeben wird, hier das Wort Text
2. Parameter: Die Gesamtlänge der Zeile, hier 20 Zeichen
3. Parameter: Füllzeichen, hier A_Space (das Leerzeichen)
4. Parameter: Die Ausrichtung, hier L (heisst Linksbündig)
*/

;A:= LP(A,TAB1,S,"R")
;B:= LP(B,TAB1,S,"R")

;Line := LinePadding("TestString",20,A_Space,"L")
;MsgBox |%Line%| ; zu Testzwecken

LP(String,FieldLen,ToAppend,Justification)
 {
   StringLen, StringLen, String ; Anzahl Zeichen der Zeichenkette ermitteln
   LCnt := FieldLen-StringLen ; Anzahl Füllzeichen ermitteln
   Loop, % LCnt
     Appended := (Appended . ToAppend) ; Auffüllen
   If Justification = R
      Return (Appended . String) ; Linksbündig
   If Justification = L
         Return (String . Appended) ; Rechtsbündig
 }
;======================== ENDE ==================================================
;####################################################################################




Last edited by garry on Mon Mar 15, 2010 8:49 pm; edited 9 times in total
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10667

PostPosted: Mon Jul 18, 2005 9:02 pm    Post subject: Reply with quote

It looks interesting; thanks for sharing it.

ListViews in XP and beyond have the ability to select columns, but I forget exactly how to enable it. If it can't be enabled through SendMessage, perhaps it can be built into the program someday.
Back to top
View user's profile Send private message Send e-mail
rootey



Joined: 06 Sep 2009
Posts: 19

PostPosted: Sun Sep 27, 2009 1:49 pm    Post subject: Reply with quote

Hi garry, I really like this stuff; can you post your test55.txt for Example 3 please?
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 1557
Location: switzerland

PostPosted: Sun Sep 27, 2009 8:55 pm    Post subject: Reply with quote

hello rootey
added 4th example to search in a text file
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group