Jump to content

newbie help


jpam
 Share

Recommended Posts

hey everbody !

i am new here :">

am working on my second script with gui

but......i am stuck at the guicreatelist function

i want to select a nummer of the gui list and delete it with the del keybutton!

is there a script guru who show me a way how to handle this problem :(

here's the script

thanks in advance

#include <GUIConstants.au3>
#include <file.au3>
#include <Array.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode 
$mainwindow = GUICreate("Flits Info", 400, 400)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Selecteer de Provincie", 260, 70)
GUICtrlCreateLabel("Selecteer eerst de provincies daarna gsm nummer invoeren", 10, 20)
$accept = GUICtrlCreateButton("accept", 170, 97, 60)
GUICtrlSetOnEvent($accept, "Accept")
$del = GUICtrlCreateButton("del", 170, 180, 60)
GUICtrlSetOnEvent($del, "del")
GUISetState(@SW_SHOW)


$checkfr = GUICtrlCreateCheckbox ("Friesland", 280, 100, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checkgr = GUICtrlCreateCheckbox ("Groningen", 280, 120, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checkdr = GUICtrlCreateCheckbox ("Drente", 280, 140, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checkov = GUICtrlCreateCheckbox ("Overijssel", 280, 160, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checkfl = GUICtrlCreateCheckbox ("Flevoland", 280, 180, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checknh = GUICtrlCreateCheckbox ("Noord Holland", 280, 200, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checkzh = GUICtrlCreateCheckbox ("Zuid Holland", 280, 220, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checkut = GUICtrlCreateCheckbox ("Utrecht", 280, 240, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checkge = GUICtrlCreateCheckbox ("Gelderland", 280, 260, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checknb = GUICtrlCreateCheckbox ("Noord Brabant", 280, 280, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checkze = GUICtrlCreateCheckbox ("Zeeland", 280, 300, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checklb = GUICtrlCreateCheckbox ("Limburg", 280, 320, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$checkas = GUICtrlCreateCheckbox ("Alles", 280, 350, 120, 20)
GUISetState ()    ; will display an  dialog box with 1 checkbox

$exist = fileopen("c:\snelheidscontrole\num.txt", 0)
if $exist = -1 Then
    filewrite("c:\snelheidscontrole\num.txt", "")
    EndIf
Dim $aFile
$i = 1
_FileReadToArray ( "c:\snelheidscontrole\num.txt", $aFile )
GUICtrlCreatelist (StringReplace($aFile[1], @CR, ""), 10,180,150,200); create first item
Do
    $aFile[$i] = StringReplace($aFile[$i], @CR, "")
    GUICtrlSetData(-1, $aFile[$i]); add new items that were read from file
   $i = $i + 1
Until $i = $aFile[0] + 1




GUICtrlCreateLabel("GSM Nummers", 50, 155)
GUICtrlCreateLabel("Invoer GSM Nummer", 30, 70)
$input = GUICtrlCreateInput ("", 10,  100, 150, 20)  ; will not accept drag&drop files

While 1
  Sleep(1000) ; Idle around
WEnd


Func accept()
    GUICtrlRead($checkfr)
    If GUICtrlRead($checkfr) = $GUI_CHECKED Then
    $fr = " fr"  
Else
    $fr = ""
EndIf
    GUICtrlRead($checkgr)
    If GUICtrlRead($checkgr) = $GUI_CHECKED Then
    $gr = " gr"  
Else
    $gr = ""
EndIf
    GUICtrlRead($checkdr)
    If GUICtrlRead($checkdr) = $GUI_CHECKED Then
    $dr = " dr"  
else 
    $dr = ""
EndIf
    GUICtrlRead($checkov)
    If GUICtrlRead($checkov) = $GUI_CHECKED Then
    $ov = " ov"  
else 
    $ov = ""
EndIf
    GUICtrlRead($checkfl)
    If GUICtrlRead($checkfl) = $GUI_CHECKED Then
    $fl = " fl"  
else 
    $fl = ""
EndIf
    GUICtrlRead($checknh)
    If GUICtrlRead($checknh) = $GUI_CHECKED Then
    $nh = " nh"  
else 
    $nh = ""
EndIf
    GUICtrlRead($checkzh)
    If GUICtrlRead($checkzh) = $GUI_CHECKED Then
    $zh = " zh"  
else 
    $zh = ""
EndIf
    GUICtrlRead($checkut)
    If GUICtrlRead($checkut) = $GUI_CHECKED Then
    $ut = " ut"  
else 
    $ut = ""
EndIf
    GUICtrlRead($checkge)
    If GUICtrlRead($checkge) = $GUI_CHECKED Then
    $ge = " ge"  
else 
    $ge = ""
EndIf
    GUICtrlRead($checknb)
    If GUICtrlRead($checknb) = $GUI_CHECKED Then
    $nb = " nb"  
else 
    $nb = ""
EndIf
    GUICtrlRead($checkze)
    If GUICtrlRead($checkze) = $GUI_CHECKED Then
    $ze = " ze"  
else 
    $ze = ""
EndIf
    GUICtrlRead($checklb)
    If GUICtrlRead($checklb) = $GUI_CHECKED Then
    $lb = " lb"  
else 
    $lb = ""
EndIf
    GUICtrlRead($checkas)
    If GUICtrlRead($checkas) = $GUI_CHECKED Then
    $as = " alles"  
else 
    $as = ""
EndIf

    
    
    
    FileWrite("c:\snelheidscontrole\num.txt" , @crlf & GUICtrlRead($input) & $fr & $gr & $dr & $ov & $fl & $nh & $zh & $ut & $ge & $nb & $ze & $lb & $as)  
    MsgBox(0, "GSM nummer", "opgeslagen!")

  
Dim $aFile
$i = 1
_FileReadToArray ( "c:\snelheidscontrole\num.txt", $aFile )
GUICtrlCreatelist(StringReplace($aFile[1], @CR, ""), 10,180,150,200); create first item
Do
    $aFile[$i] = StringReplace($aFile[$i], @CR, "")
    GUICtrlSetData(-1, $aFile[$i]); add new items that were read from file
   $i = $i + 1
Until $i = $aFile[0] + 1
EndFunc



Func del()

;list item removve
$LVM_DELETEITEM = 0x1008
$ItemCount = ControlListView("listview items","",$aFile,"GetItemCount")
 
for $i = 0 To $ItemCount - 1
  MsgBox(0, "GUI Event", $ItemCount)
   MsgBox(0, "GUI Event", $afile)
  If ControlListView("listview items","",$aFile,"IsSelected",$i) Then 
  GuiCtrlSendMsg($aFile, $LVM_DELETEITEM,$i,0)
  $i = $i - 1
EndIf
Next

;FileWrite("c:\snelheidscontrole\num.txt", & $aFile)
 ;filedelete("c:\snelheidscontrole\num.txt")
 ;filewrite("c:\snelheidscontrole\num.txt","")
  MsgBox(0, "GUI Event", "bestanden zijn verwijderd !")
Dim $aFile
$i = 1
_FileReadToArray ( "c:\snelheidscontrole\num.txt", $aFile )
GUICtrlCreatelist (StringReplace($aFile[1], @CR, ""), 10,180,150,200); create first item
Do
    $aFile[$i] = StringReplace($aFile[$i], @CR, "")
    GUICtrlSetData(-1, $aFile[$i]); add new items that were read from file
   $i = $i + 1
Until $i = $aFile[0] + 1
EndFunc


Func CLOSEClicked()
  Exit
EndFunc
Edited by Larry
Link to comment
Share on other sites

Currently, the beta version has many User Defined functions which will do what your wanting to do I believe.

If you don't mind working with a beta version of AutoIt, you can get it here.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...