garry
Joined: 19 Apr 2005 Posts: 1497 Location: switzerland
|
Posted: Mon Jul 18, 2005 7:50 pm Post subject: Listview select column and start EMAIL,URL,PROGRAM |
|
|
(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=20090927
NAME1 =TEST LISTVIEW FWD/BACK SEARCH File
;==============================================================
F1=%A_scriptdir%\test55.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;3CCC;3DDDD%EF%
Line4A;4BB;4CCC;4DDDD%EF%
Line5A;5BB;5CCC;5DDDD%EF%
)
Fileappend,%AA%`n,%F1%
}
;---------------------------------
RF:=1
T1=200 ;column1 width
T2=100 ;column2 width
T3=100 ;column3 width
T4=100 ;column4 width
LSW:=(T1+T2+T3+T4+20) ;Listview width
GSW:=(LSW+30) ;GUI width
Gui,1:Add , Edit, x10 y530 w195 h20 vURLX gSEARCH2
Gui,1:Add,Button,default x0 y0 w0 h0 gSEARCH2 ,
Gui,1:Add,Button,x10 y570 w70 h25 g<< ,<<
Gui,1:Add,Button,x90 y570 w70 h25 g>> ,>>
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 w%LSW% 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
GuiControl,1:Text,TOT1,%GC% ;show total
GuiControl,1:Text,POS1,%RF% ;show position
Gui,1:Show, x2 y0 w%GSW% h610,TEST FILEREAD
return
;-------------------------------
SB:
Gui,1:ListView,MLV1A
LV_Delete()
loop,read,%F1%
{
stringsplit,C,A_LoopReadLine,`;,
LV_Add("",C1,C2,C3,C4)
}
GC:=LV_GetCount()
LV_Modify(LV_GetCount(), "Vis") ;jumps to last row
GuiControl,1:Text,TOT1,%GC%
LV_Modify(GC, "+Select +Focus") ;focus last row
return
;=================================================
;================== 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
}
}
return
;================================================
Guiclose:
exitapp
|
Last edited by garry on Sun Sep 27, 2009 7:54 pm; edited 6 times in total |
|