Jump to content

Script problem


Bert
 Share

Recommended Posts

yes i see! lol free Bug my ...! ok sorry guys! i think i need to sleep!

ok i've tested it a little more and found some bug! when a | come to the begening! and sometime it delete the trail "|"

then i've completely remake! the DelData function! i've tested it with some stange text string! and everything work fine!

and now he must pass your test! this is the updated code

#Region Option Declaration
Opt("CaretCoordMode", 1)       ;1=absolute, 0=relative
Opt("ColorMode", 0)         ;0 = Colors are defined as RGB 1 = Colors are defined as BGR (0xBBGGRR)
Opt("ExpandEnvStrings", 0)   ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 0)  ;Changes how literal strings and variable/macro ($ and @) symbols are interpreted 0=Default
Opt("FtpBinaryMode" , 1)    ;Binary=1 AscII=0
Opt("GUICloseOnESC", 0)     ; 0=Default
Opt("GUICoordMode",1)       ; 0=relative to CTRL 1=absolute To Box(default) 2= Cell Positioning
Opt("GUIDataSeparatorChar","|"); default "|"
Opt("GUIOnEventMode",0)     ;Default =0
Opt("GUIResizeMode",0)      ;Default=0 See Resize mode
Opt("GUIEventCompatibilityMode",0); default=0  1= Absolute 2=Client Area
Opt("MouseClickDelay", 10)   ;10 milliseconds
Opt("MouseClickDownDelay", 10) ;10 milliseconds
Opt("MouseClickDragDelay", 250);250 milliseconds
Opt("MouseCoordMode",0)     ;Default=0
Opt("MustDeclareVars", 0)     ;0=no, 1=require pre-declare
Opt("OnExitFunc","OnAutoItExit");Default=OnAutoItExit
Opt("PixelCoordMode", 1)       ;1=absolute, 0=relative
Opt("RunErrorsFatal", 0)       ;1=fatal, 0=silent set @error
Opt("SendAttachMode", 0)       ;0=don't attach, 1=do attach
Opt("SendCapslockMode", 1)   ;1=store and restore, 0=don't
Opt("SendKeyDelay", 8)       ;5 milliseconds
Opt("SendKeyDownDelay", 1)   ;1 millisecond
Opt("TCPTimeout",100)       ;Default=100
Opt("TrayAutoPause",0)      ;Default=1
Opt("TrayIconDebug", 1)     ;0=no info, 1=debug line info
Opt("TrayIconHide", 0)       ;0=show, 1=hide tray icon
Opt("TrayMenuMode",0)       ;2=User 1=Disable
Opt("TrayOnEventMode",0)    ;Default=0
Opt("WinDetectHiddenText", 0)  ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
Opt("WinTextMatchMode",1)   ;Default=1 2=modeFast
Opt("WintitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=...
Opt("WinWaitDelay", 250)       ;250 milliseconds
#endregion

#region Declaration Variables et Include files
#include <GuiConstants.au3>
#include <File.au3>
#Include <GuiCombo.au3>
Global Const $DataFile = "data.dbit"
Global Const $DataPath = @ScriptDir
Dim $Datas
Dim $sData
Dim $AddButtonCancel
Dim $DelButtonCancel
Dim $MainAddGui
Dim $MainDelGui
Dim $DelCombo
Dim $AddButtonOk
Dim $AddInput
Dim $DelButtonRemove

#endregion

FileCheck()


;Main Gui Add Menu
$MainAddGui = GUICreate("Add entry to QuickText", 520, 65, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018)
GUISetState(@SW_HIDE)
$AddInput = GUICtrlCreateInput("Enter Text To Add", 10, 5, 500, 20)
;~ GUICtrlSetState(-1, $GUI_ACCEPTFILES)
;~ GUICtrlSetStyle(-1,-1,$WS_EX_ACCEPTFILES) 
$AddButtonOk = GUICtrlCreateButton("Ok", 10, 30, 60, 20)
$AddButtonCancel = GUICtrlCreateButton("Cancel", 90, 30, 60, 20)
 
;main Gui Delete Menu
$MainDelGui = GUICreate("Remove entry from QuickText", 520, 65, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
GUISetState(@SW_HIDE)
$DelCombo = GUICtrlCreateCombo("", 10, 5, 500, 20)
;~ GUICtrlSetState(-1, $GUI_ACCEPTFILES)
;~ GUICtrlSetStyle(-1,-1,$WS_EX_ACCEPTFILES)
$DelButtonRemove = GUICtrlCreateButton("Remove", 10, 30, 60, 20)
$DelButtonCancel = GUICtrlCreateButton("Cancel", 90, 30, 60, 20)


;-----------------------------
$MainGui = GUICreate("QuickText 1.0", 600, 100,-1,-1,$GUI_SS_DEFAULT_GUI+$WS_CLIPCHILDREN)
$MainCombo = GUICtrlCreateCombo("Make Your Selection", 20, 5, 500, 80)
LoadData(-1)
$Buttonpaste = GUICtrlCreateButton("Paste", 530, 5, 60, 20)
$ButtonCancel = GUICtrlCreateButton("Cancel", 530, 32, 60, 20)
$ButtonAdd = GUICtrlCreateButton("Add", 20, 32, 60, 20)
$ButtonRemove = GUICtrlCreateButton("Remove", 100, 32, 60, 20)
$Buttonhelp = GUICtrlCreateButton("Help", 180, 32, 60, 20)
$ButtonAbout = GUICtrlCreateButton("About", 260, 32, 60, 20)
; Run the GUI until it is closed
GUISetState(@SW_SHOW,$MainGui)






While 1
    $msg = GUIGetMsg(1)
    Select
        Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $MainGui or $msg[0] = $ButtonCancel
                Exit
        Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $MainAddGui or $msg[0] = $AddButtonCancel
            GUISetState(@SW_SHOW,$MainGui)
            GUISetState(@SW_HIDE, $MainAddGui)
        Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $MainDelGui or $msg[0] = $DelButtonCancel
            GUISetState(@SW_SHOW,$MainGui)
            GUISetState(@SW_HIDE, $MainDelGui)
    ;When button1 is pressed, label text is copied to the clipboard
        Case $msg[0] = $Buttonpaste
             $sData = GUICtrlRead($MainCombo)
             ClipPut($sData)
             $sData = ""
             Sleep(200)
            ;Exit
           ;---------------------------------------
           ;this will open a sub GUI window to allow for adding or removing data
        Case $msg[0] = $ButtonAdd
            LoadData(-2)
            GUISetState(@SW_HIDE,$MainGui)
            GUISetState(@SW_SHOW, $MainAddGui)
        ; this will add data to the quicktest.ini file. It will make the file if it is missing
        Case $msg[0] = $AddButtonOk
            AddData(GUICtrlRead($AddInput))
            GUICtrlSetData($AddInput,"")
            LoadData($MainCombo)
            LoadData($DelCombo)
           ;----------------------------------------
           ;this will open a window that will remove a entry selected from the drop down list.
        Case $msg[0] = $ButtonRemove
            GUISetState(@SW_HIDE,$MainGui)
             LoadData($DelCombo)
            GUISetState(@SW_SHOW, $MainDelGui)           
        Case $msg[0] = $DelButtonRemove; this will remove an entry from the quicktest.ini file.
            DeleteData(GUICtrlRead($DelCombo))
            LoadData(-2)
            LoadData($MainCombo)
            LoadData($DelCombo)
        Case $msg[0] = $Buttonhelp
            MsgBox(0 + 64, "How to use QuickType", "- To select what you want pasted to your current work, use the " & @CRLF _
                    & "  dropdown to select the item you want. Once selected, click OK." & @CRLF _
                    & "" & @CRLF _ 
                    & "- To enter a new item in the list, click ADD" & @CRLF _                  
                    & "  Type in what you want to have entered, then click OK." & @CRLF _
                    & "" & @CRLF _    
                    & "- To remove a entry, click on REMOVE" & @CRLF _
                    & "  Select from the dropdown what you wish to delete, then click OK." & @CRLF _
                    & "" & @CRLF _ 
                    & "- You can click CANCEL to back out if needed.")
             
          Case $msg[0] = $ButtonAbout
            MsgBox(0 + 64, "AboutQuickType 1.0", "Designed and written by Volly" & @CRLF _
                    & "   XXXXXXXXXXXXXXXXXX" & @CRLF _
                    & "" & @CRLF _                  
                    & " To report a bug, call STnet XXX-XXXX")
    EndSelect
WEnd
Exit


;Add Specific Data To Data Files
Func AddData($AddedData)
    Local $fHandle
    LoadData(-2)
    $Datas = $Datas&$AddedData&"|"
    $fHandle=FileOpen($DataPath&"\"&$Datafile, 2)
    FileWriteLine($fHandle, $Datas)
    FileClose($fHandle)
    LoadData(-2)
EndFunc



;Erase specific data ($removabledata) from Database File
Func DeleteData($removabledata)
    Local $fHandle
    Local $tDatas
    LoadData(2)
    $tDatas = StringSplit($Datas,$removabledata,1)
    if IsArray($tDatas) And StringRight($tDatas[1],1) = "|" and StringLeft($tDatas[2],1) = "|" Then
        $Datas = $tDatas[1]&StringTrimLeft($tDatas[2],1)
        if StringRight($Datas,1) <> "|" then 
            $Datas = $Datas&"|"
        ElseIf StringLeft($Datas,1) = "|" Then
            $Datas = StringTrimLeft($Datas,1)
        EndIf
    ElseIf IsArray($tDatas) Then        
        $Datas =$tDatas[1]&$tDatas[2]
        if StringRight($Datas,1) <> "|" then 
            $Datas = $Datas&"|"
        ElseIf StringLeft($Datas,1) = "|" Then
            $Datas = StringTrimLeft($Datas,1)
        EndIf
    Else
        $Datas = $tDatas
        if StringRight($Datas,1) <> "|" then 
            $Datas = $Datas&"|"
        ElseIf StringLeft($Datas,1) = "|" Then
            $Datas = StringTrimLeft($Datas,1)
        EndIf
        Return 0
    EndIf
    $fHandle = FileOpen($DataPath&"\"&$Datafile,2)  
    FileWriteLine($fHandle,$Datas)
    FileClose($fHandle)
    if @error then
        return 0
    else 
        return 1
    EndIf
EndFunc



;Load Data to $Datas and set the data to combobox ID if -2 is combobox ID the Only $Datas Is updated
Func LoadData($ComboBoxID=-1)
    Local $fHandle
    Local $fRead
    $fHandle=FileOpen($DataPath&"\"&$Datafile,0)
    $fRead=FileReadLine($fHandle)
    $Datas=$fRead
    FileClose($fHandle)
    if $ComboBoxID <> -2 then
        GUICtrlSetData($ComboBoxID,"|")
        GUICtrlSetData($ComboBoxID,$Datas)
    EndIf
    Return $Datas
EndFunc;==>_LoadData


;Check If The file Exist if not create and check for file have no more than 1 line if not script exit
Func FileCheck()
    Local $fHandle
    Local $Check
    if not FileExists($DataPath&"\"&$Datafile) Then
        $fHandle=FileOpen($DataPath&"\"&$Datafile,2)
        FileClose($fHandle)
    Else
        $Check =_FileCountLines($DataPath&"\"&$Datafile) 

        if $check >= 2 or $check <= -1 then
            MsgBox(0,"QuickText 1.0","Error When Checking File: "&@CRLF&"   "&$DataPath&"\"&$Datafile&@CRLF&"You Should Check The File." )
            Exit
        endif
    EndIf
    Return 1
EndFunc
Edited by Greenseed

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

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...