Jump to content

store multiple values in variable


Recommended Posts

trying to store multiple values in variable something like this

Local $iLines = [[$iLine1],[$iLine2],[$iLine3],[$iLine4],[$iLine5]]
Local $Replace = ""
_FileWriteToLine ( $sFilePath, $iLines, $Replace, 1 )

I need it to delete the code on the line numbers

can anyone help me with this

thanks guys

Link to comment
Share on other sites

I'd like to direct you to the Arrays tutorial in the Wiki, as that is what you're trying to create here.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Iresolver, I'm not sure what you mean. What's in $iLine1$iLine2 etc? Line numbers? Strings that match lines in the file?

Also, what kind of file is it and how big is it? There may be better ways to handle this.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

I'm trying to delete multi lines of code in the Autoit script i'm running
 
I have a gui button that call's a func like this
 
#include <Array.au3>

Func Remove_All()

Local $iLine[3] = ["54", "55", "56"]

_FileWriteToLine ( $sFilePath, $iLine, "", 1 )

EndFunc

I want to Delete line 54 line 55 & line 56 the _FilewriteToLine works if $iLine has only one line number stored in it

Not shore why it not working?

Link to comment
Share on other sites

I want to Delete the code using a gui button from line 54 to 64

Here is the full script it is an Auto Email Login app

the func I need help on is at the top of the script

thanks for any help you can give me.

 
 
#RequireAdmin
#include <IE.au3>
#include <ComboConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiComboBoxEx.au3>
#include <GuiToolbar.au3>
#include <Array.au3>

;---------------------------------------------------- My Latest work in progress ------------------------------------------------------
;AutoItSetOption ( "GUIDataSeparatorChar", "" )
Opt("GUIOnEventMode", 1)
AutoItSetOption ( "TrayIconDebug", 1 )

Global $AutoEmail, $AutoReplace_GUI = 9999, $Gmail_Button, $Hotmail_Button, $AutoReplace_Button = 9999                             ; Predeclare the variables with dummy values to prevent firing the Case statements
Global $Gmail1_Button, $Gmail2_Button, $Hotmail1_Button, $Hotmail2_Button, $Input1, $Input2, $Input3, $Input4
Global $Gmail, $Hotmail, $cCombo, $cCombo2
Global $sFilePath = @ScriptDir & "\AutoEmail_Variables_TESTING.au3"
Global $iLine

Global $GDataCom

Global $Input_g1pass

Global $Reset_Script_Button
Global $Add_MoreEmails_Button
Global $MsgBoxReset

Global $Data1
Global $Data2
Global $n
Global $iText
Global $cCombo_AddNum
Global $USER_INPUT
Global $USER_PASS


Global $GmailAccount1, $GmailAccount2, $GmailAccount3, $GmailAccount4, $GmailAccount5, $GmailAccount6, $GmailAccount7, $GmailAccount8, $GmailAccount9, $GmailAccount10
Global $GmailPassword1, $GmailPassword2, $GmailPassword3, $GmailPassword4, $GmailPassword5, $GmailPassword6, $GmailPassword7, $GmailPassword8, $GmailPassword9, $GmailPassword10

Global $HotmailAccount1, $HotmailAccount2, $HotmailAccount3, $HotmailAccount4, $HotmailAccount5, $HotmailAccount6, $HotmailAccount7, $HotmailAccount8, $HotmailAccount9, $HotmailAccount10
Global $HotmailPassword1, $HotmailPassword2, $HotmailPassword3, $HotmailPassword4, $HotmailPassword5, $HotmailPassword6, $HotmailPassword7, $HotmailPassword8, $HotmailPassword9, $HotmailPassword10




;--------------------- Your Email Accounts Will Go Here ---------------------
Global $GmailAccount1 = "test1@gmail.com"
Global $GmailPassword1 = "test1"
Global $GmailPassword2 = "test2"
Global $GmailAccount3 = "test3@gmail.com"
Global $GmailPassword3 = "test3"

Global $HotmailAccount1 = "test1@hotmail.com"
Global $HotmailPassword1 = "test1"

Global $HotmailAccount2 = "test2@hotmail.com"
Global $HotmailPassword2 = "test2"





;-----------------------------   This is where I Need Help   -----------------------------------------------------

Func Remove_All()

Local $iLine[3] = ["54", "55", "56"]

_FileWriteToLine ( $sFilePath, $iLine, "", 1 )

EndFunc

;-----------------------------------------------------------------------------------------------------------------









GUI_AutoEmail()



 Func GUI_AutoEmail()

     $AutoEmail = GUICreate("Auto Email", 386, 132, @DesktopWidth, @DesktopHeight)
     $aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd]", "")
     $aWin = WinGetPos($AutoEmail)
     WinMove($AutoEmail, "", @DesktopWidth - $aWin[2] - 4, @DesktopHeight - $aWin[3] - $aTaskbar[3] - 4)

     GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")
     $Gmail_Button = GUICtrlCreateButton("Gmail", 72, 16, 49, 41, $BS_ICON)
     GUICtrlSetImage(-1, "C:\Program Files\AutoEmail\gmail_icon.ico", 1)

     $Hotmail_Button = GUICtrlCreateButton("Hotmail", 263, 16, 49, 41, $BS_ICON)
     GUICtrlSetImage(-1, "C:\Program Files\AutoEmail\MSMail_icon.ico", 1)

     $iText = GUICtrlRead($cCombo)

     $cCombo = GUICtrlCreateCombo("", 16, 72, 161, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))

     If $GmailAccount10 Then GUICtrlSetData(-1, $GmailAccount10,$GmailAccount10)
     If $GmailAccount9 Then GUICtrlSetData(-1, $GmailAccount9,$GmailAccount9)
     If $GmailAccount8 Then GUICtrlSetData(-1, $GmailAccount8,$GmailAccount8)
     If $GmailAccount7 Then GUICtrlSetData(-1, $GmailAccount7,$GmailAccount7)
     If $GmailAccount6 Then GUICtrlSetData(-1, $GmailAccount6,$GmailAccount6)
     If $GmailAccount5 Then GUICtrlSetData(-1, $GmailAccount5,$GmailAccount5)
     If $GmailAccount4 Then GUICtrlSetData(-1, $GmailAccount4,$GmailAccount4)
     If $GmailAccount3 Then GUICtrlSetData(-1, $GmailAccount3,$GmailAccount3)
     If $GmailAccount2 Then GUICtrlSetData(-1, $GmailAccount2,$GmailAccount2)
     If $GmailAccount1 Then GUICtrlSetData(-1, $GmailAccount1,$GmailAccount1)


    $cCombo2 = GUICtrlCreateCombo("", 207, 72, 161, 25)

      If $HotmailAccount10 Then GUICtrlSetData(-1, $HotmailAccount10,$HotmailAccount10)
      If $HotmailAccount9 Then GUICtrlSetData(-1, $HotmailAccount9,$HotmailAccount9)
      If $HotmailAccount8 Then GUICtrlSetData(-1, $HotmailAccount8,$HotmailAccount8)
      If $HotmailAccount7 Then GUICtrlSetData(-1, $HotmailAccount7,$HotmailAccount7)
      If $HotmailAccount6 Then GUICtrlSetData(-1, $HotmailAccount6,$HotmailAccount6)
      If $HotmailAccount5 Then GUICtrlSetData(-1, $HotmailAccount5,$HotmailAccount5)
      If $HotmailAccount4 Then GUICtrlSetData(-1, $HotmailAccount4,$HotmailAccount4)
      If $HotmailAccount3 Then GUICtrlSetData(-1, $HotmailAccount3,$HotmailAccount3)
      If $HotmailAccount2 Then GUICtrlSetData(-1, $HotmailAccount2,$HotmailAccount2)
      If $HotmailAccount1 Then GUICtrlSetData(-1, $HotmailAccount1,$HotmailAccount1)




     GUICtrlSetOnEvent(3, "On_Button")

     GUICtrlSetOnEvent(4, "On_Button")

     GUICtrlSetOnEvent(-1, "On_Button")

     $AutoReplace_Button = GUICtrlCreateButton("Add Your Email", 18, 100, 80, 30)

     GUICtrlSetOnEvent(-1, "On_Button")
     GUISetState()


 EndFunc


 Func On_Button()

         Switch @GUI_CTRLID
         Case $Gmail_Button
              gmail()

         Case $Hotmail_Button
             hotmail()

         Case $AutoReplace_Button
             GUICtrlSetState($AutoReplace_Button, $GUI_DISABLE)

             GUI_AddEmail()



         Case $Gmail1_Button


         Case $Reset_Script_Button
             ;Reset_Script()
              Remove_All()


         Case $Add_MoreEmails_Button
                 Add_MultiEmail()

     EndSwitch

 EndFunc



Func gmail()
Sleep(20)

GUICtrlRead($cCombo)
$GDataCom = GUICtrlRead($cCombo)
If $GDataCom = $GmailAccount1 Then
    gmail1()
Else
GUICtrlRead($cCombo)
$GDataCom = GUICtrlRead($cCombo)
If $GDataCom = $GmailAccount2 Then
    gmail2()
Else
GUICtrlRead($cCombo)
$GDataCom = GUICtrlRead($cCombo)
If $GDataCom = $GmailAccount3 Then
    gmail3()
EndIf


EndIf
EndIf
EndFunc

Func hotmail()
Sleep(20)
GUICtrlRead($cCombo2)
$GDataCom2 = GUICtrlRead($cCombo2)
If $GDataCom2 = $HotmailAccount1 Then
;MsgBox (0, "hbox1", "hotmail1")
hotmail1()

Else
Sleep(20)
GUICtrlRead($cCombo2)
$GDataCom2 = GUICtrlRead($cCombo2)
If $GDataCom2 = $HotmailAccount2 Then
;MsgBox (0, "hbox2", "hotmail2")
hotmail2()



EndIf
EndIf

EndFunc


Func gmail1()
Sleep(25)

ProcessClose("iexplore.exe")
ProcessWaitClose ( "iexplore.exe")



Local $oIE = _IECreate ("https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/")
Sleep(25)

    Local $removeAccounts = _IEGetObjById ($oIE, "edit-account-list")
    _IEAction ($removeAccounts, "click")
    Local $removeAccounts = _IEGetObjById ($oIE, "account-email-0")
    _IEAction ($removeAccounts, "click")
    Local $removeAccounts = _IEGetObjById ($oIE, "account-email-1")
    _IEAction ($removeAccounts, "click")
Sleep(100)
    Local $removeAccounts = _IEGetObjById ($oIE, "edit-account-list")
    _IEAction ($removeAccounts, "click")

    ;Local $staySignin = _IEGetObjById ($oIE, "PersistentCookie")
    ;_IEAction ($staySignin, "click")

Sleep(1000)
    local $username = _IEGetObjByName ($oIE, "Email")
    Local $password = _IEGetObjByName ($oIE, "Passwd")

    Local $Email_button = _IEGetObjByName ($oIE, "Email")
    Local $Signin_button = _IEGetObjByName ($oIE,"signIn")

    _IEFormElementSetValue ($username, $GmailAccount1)
    _IEFormElementSetValue ($password, $GmailPassword1)

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

EndFunc


Func gmail2()
Sleep(25)

ProcessClose("iexplore.exe")
ProcessWaitClose ( "iexplore.exe")

Local $oIE = _IECreate ("https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/")

    Local $removeAccounts = _IEGetObjById ($oIE, "edit-account-list")
    _IEAction ($removeAccounts, "click")
    Local $removeAccounts = _IEGetObjById ($oIE, "account-email-0")
    _IEAction ($removeAccounts, "click")
    Local $removeAccounts = _IEGetObjById ($oIE, "account-email-1")
    _IEAction ($removeAccounts, "click")
Sleep(100)
    Local $removeAccounts = _IEGetObjById ($oIE, "edit-account-list")
    _IEAction ($removeAccounts, "click")

Sleep(1000)
    local $username = _IEGetObjByName ($oIE, "Email")
    Local $password = _IEGetObjByName ($oIE, "Passwd")

    Local $Email_button = _IEGetObjByName ($oIE, "account-email")
    Local $Signin_button = _IEGetObjByName ($oIE,"signIn")

    _IEFormElementSetValue ($username, $GmailAccount2)
    _IEFormElementSetValue ($password, $GmailPassword2)

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

EndFunc

Func gmail3()
Sleep(25)

ProcessClose("iexplore.exe")
ProcessWaitClose ( "iexplore.exe")

Local $oIE = _IECreate ("https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/")

    Local $removeAccounts = _IEGetObjById ($oIE, "edit-account-list")
    _IEAction ($removeAccounts, "click")
    Local $removeAccounts = _IEGetObjById ($oIE, "account-email-0")
    _IEAction ($removeAccounts, "click")
    Local $removeAccounts = _IEGetObjById ($oIE, "account-email-1")
    _IEAction ($removeAccounts, "click")
Sleep(100)
    Local $removeAccounts = _IEGetObjById ($oIE, "edit-account-list")
    _IEAction ($removeAccounts, "click")

Sleep(1000)
    local $username = _IEGetObjByName ($oIE, "Email")
    Local $password = _IEGetObjByName ($oIE, "Passwd")

    Local $Email_button = _IEGetObjByName ($oIE, "account-email")
    Local $Signin_button = _IEGetObjByName ($oIE,"signIn")

    _IEFormElementSetValue ($username, $GmailAccount3)
    _IEFormElementSetValue ($password, $GmailPassword3)

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

EndFunc



Func hotmail1()
Sleep(25)

ProcessClose("iexplore.exe")
ProcessWaitClose ( "iexplore.exe")

Local $oIE = _IECreate ("https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=12&ct=1428617583&rver=6.4.6456.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fmail.live.com%2Fdefault.aspx%3Frru%3Dinbox&lc=1033&id=64855&mkt=en-us&cbcxt=mai")

    Local $username = _IEGetObjByName ($oIE, "login")
    Local $password = _IEGetObjByName ($oIE, "passwd")
    Local $Signin_button = _IEGetObjByName ($oIE,"SI")

    _IEFormElementSetValue ($username, $HotmailAccount1)
    _IEFormElementSetValue ($password, $HotmailPassword1)
    _IEAction ($Signin_button, "click")

EndFunc


Func hotmail2()
Sleep(25)
ProcessClose("iexplore.exe")
ProcessWaitClose ( "iexplore.exe")

Local $oIE = _IECreate ("http://www.live.com")

    Local $username = _IEGetObjByName ($oIE, "login")
    Local $password = _IEGetObjByName ($oIE, "passwd")
    Local $Signin_button = _IEGetObjByName ($oIE,"SI")

    _IEFormElementSetValue ($username, $HotmailAccount2)
    _IEFormElementSetValue ($password, $HotmailPassword2)
    _IEAction ($Signin_button, "click")

EndFunc


Func hotmail3()
Sleep(25)
ProcessClose("iexplore.exe")
ProcessWaitClose ( "iexplore.exe")

Local $oIE = _IECreate ("http://www.live.com")

    Local $username = _IEGetObjByName ($oIE, "login")
    Local $password = _IEGetObjByName ($oIE, "passwd")
    Local $Signin_button = _IEGetObjByName ($oIE,"SI")

    _IEFormElementSetValue ($username, $HotmailAccount3)
    _IEFormElementSetValue ($password, $HotmailPassword3)
    _IEAction ($Signin_button, "click")

EndFunc


Func On_Close()
     Switch @GUI_WINHANDLE
         Case $AutoEmail
             Exit
        Case $AutoReplace_GUI
             GUIDelete($AutoReplace_GUI)
             GUICtrlSetState($AutoReplace_Button, $GUI_ENABLE)
     EndSwitch
 EndFunc

Func MsgReset_Close()

        Switch @GUI_WinHandle
            Case $MsgBoxReset
                Exit
     EndSwitch

EndFunc


Func GUI_AddEmail()

$AutoReplace_GUI = GUICreate("Auto Add Email", 508, 334, -1, -1)
$Input1 = GUICtrlCreateInput("", 24, 56, 457, 21)
$Input_g1pass = GUICtrlCreateInput("", 24, 120, 457, 21)

GUICtrlSetTip(-1, "Click To Remove All Emails")

$cCombo_AddNum = GUICtrlCreateCombo("", 304, 144, 33, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))

GUICtrlSetData(-1, "1")
GUICtrlSetData(-1, "2")
GUICtrlSetData(-1, "3")
GUICtrlSetData(-1, "4")
GUICtrlSetData(-1, "5")
GUICtrlSetData(-1, "6")
GUICtrlSetData(-1, "7")
GUICtrlSetData(-1, "8")
GUICtrlSetData(-1, "9")
GUICtrlSetData(-1, "10")

$Label_Num = GUICtrlCreateLabel("You Must Select a Type of Account Before you Submit", 24, 146, 272, 17)
$Add_MoreEmails_Button = GUICtrlCreateButton("Add More Emails", 376, 150, 105, 41)
$Reset_Script_Button = GUICtrlCreateButton("Remove All", 376, 272, 105, 41)
$Label_AddGmail1 = GUICtrlCreateLabel("Enter a Gmail or Hotmail Account", 24, 32, 243, 17)
$Label_AddPass1 = GUICtrlCreateLabel("Enter the Password for that Account", 24, 96, 249, 17)

$Label1 = GUICtrlCreateLabel("1 = Primary", 168, 176, 56, 17)
$Label2 = GUICtrlCreateLabel("2 = Secoundary", 256, 176, 79, 17)
$Label3 = GUICtrlCreateLabel("This will remove All Accounts from the script", 144, 288, 210, 17)



GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")

     GUICtrlSetOnEvent(-1, "On_Button")

     GUICtrlSetOnEvent(9, "On_Button")

     GUICtrlSetOnEvent(12, "On_Button")
     GUICtrlSetOnEvent(13, "On_Button")

     GUISetState()
EndFunc

;Local $iText = StringRegExp($iText, "..*@gmail.com")
; Global $aReg[4][2] = [["386"],["3g2"],["acl"],["aac"]]


Func Reset_Script()
$MsgBoxReset = MsgBox(4, "Reset Script", "Do You want to Reset the Script")
If $MsgBoxReset == 7 Then MsgReset_Close()
If $MsgBoxReset == 6 Then

FileCopy ("AutoEmail_Reset.au3", @ScriptFullPath, $FC_OVERWRITE )

EndIf

EndFunc



;If StringRegExp($sText, ".*\..*@gmail.com") Then

Func Add_MultiEmail()
$iText = GUICtrlRead($Input1)
$n = GUICtrlRead($cCombo_AddNum)


If StringRegExp($iText, "..*@gmail.com") Then
If $n = 1 Then MsgBox($MB_SYSTEMMODAL, "Gmail1", "You Added "& $iText)
If $n = 2 Then MsgBox($MB_SYSTEMMODAL, "Gmail2", "You Added "& $iText)
If $n = 3 Then MsgBox($MB_SYSTEMMODAL, "Gmail3", "You Added "& $iText)
If $n = 4 Then MsgBox($MB_SYSTEMMODAL, "Gmail4", "You Added "& $iText)
Add_MoreGmail()
;MsgBox($MB_SYSTEMMODAL, "Gmail End", "Gmail End"& $iText)
EndIf



If StringRegExp($iText, "..*@hotmail.com") Then
If $n = 1 Then MsgBox($MB_SYSTEMMODAL, "Hotmail1", "You Added "& $iText)
If $n = 2 Then MsgBox($MB_SYSTEMMODAL, "Hotmail2", "You Added "& $iText)
If $n = 3 Then MsgBox($MB_SYSTEMMODAL, "Hotmail3", "You Added "& $iText)
If $n = 4 Then MsgBox($MB_SYSTEMMODAL, "Hotmail4", "You Added "& $iText)
Add_MoreHotmail()
;MsgBox($MB_SYSTEMMODAL, "Hotmail End", "Hotmail End"& $iText)
EndIf
EndFunc


Func Add_MoreGmail()


Local $n = GUICtrlRead($cCombo_AddNum)
;Local Const $sFilePath = @ScriptDir & "\AutoEmail_Variables_TESTING.au3"

If $n = 1 Then Local $iLine = "61"
If $n = 2 Then Local $iLine = "63"
If $n = 3 Then Local $iLine = "65"
If $n = 4 Then Local $iLine = "67"
If $n = 5 Then Local $iLine = "69"
If $n = 6 Then Local $iLine = "71"
If $n = 7 Then Local $iLine = "73"
If $n = 8 Then Local $iLine = "75"
If $n = 9 Then Local $iLine = "77"
If $n = 10 Then Local $iLine = "79"


$Data1 = GUICtrlRead($Input1)
$Data2 = GUICtrlRead($Input_g1pass)

$USER_INPUT = "Global $GmailAccount"&($n)& " = "  & '"' & ($Data1) & '"'
$USER_PASS = "Global $GmailPassword"&($n)& " = "  & '"' & ($Data2) & '"'

_FileWriteToLine($sFilePath, $iLine, $USER_PASS)
_FileWriteToLine($sFilePath, $iLine, $USER_INPUT)

GUICtrlSetData($input1,"")                   ;This Clears the input1 box
GUICtrlSetData($Input_g1pass,"")             ;This Clears the input1 pass box

EndFunc

Func Add_MoreHotmail()

$n = GUICtrlRead($cCombo_AddNum)
;Local Const $sFilePath = @ScriptDir & "\AutoEmail_Variables_TESTING.au3"

If $n = 1 Then Local $iLine = "82"
If $n = 2 Then Local $iLine = "84"
If $n = 3 Then Local $iLine = "86"
If $n = 4 Then Local $iLine = "88"
If $n = 5 Then Local $iLine = "90"
If $n = 6 Then Local $iLine = "92"
If $n = 7 Then Local $iLine = "94"
If $n = 8 Then Local $iLine = "96"
If $n = 9 Then Local $iLine = "98"
If $n = 10 Then Local $iLine = "100"


$Data1 = GUICtrlRead($Input1)
$Data2 = GUICtrlRead($Input_g1pass)

$USER_INPUT = "Global $HotmailAccount"&($n)& " = "  & '"' & ($Data1) & '"'
$USER_PASS = "Global $HotmailPassword"&($n)& " = "  & '"' & ($Data2) & '"'

_FileWriteToLine($sFilePath, $iLine, $USER_PASS)
_FileWriteToLine($sFilePath, $iLine, $USER_INPUT)

GUICtrlSetData($input1,"")                ;This Clears the input1 box
GUICtrlSetData($Input_g1pass,"")          ;This Clears the input1 pass box

EndFunc

;------------------------------- This Auto Saves the Script Every 3 sec  ---------------------------
While 1
    Sleep(3000)

If  WinActive ("[CLASS:SciTEWindow]") Then
WinMenuSelectItem("[CLASS:SciTEWindow]", "", "&File", "&Save")

EndIf
WEnd
;---------------------------------------------------------------------------------------------------

AutoEmail_Variables_TESTING.au3

Edited by iresolver
Link to comment
Share on other sites

Thanks for clarifying and sharing code.

I didn't read the whole script, but if I saw correctly you are deleting hardcoded lines from a config file, one that looks like it contains actual sensitive credentials. Are you sure that is what you want to do? If anything changes in that file you may delete the wrong lines. You may want to look into nice prefab functionality for this, like a simple ini file or the _SQLite functions. Much less chance of something going wrong and more flexibility in working with your data.

As to your actual question, it doesn't work because _FileWriteToLine expects an integer line number to write to. It doesn't know what to do with the array you are pusing in. So:
 

Func Remove_All()

    Local $iLine[3] = ["54", "55", "56"]

    For $i = 0 To UBound($iLine) - 1 ; will loop through the indices in the array we just created, in this case: 0, 1, 2
        $lineNumber = $iLine[$i]
        _FileWriteToLine($sFilePath, $lineNumber, "", 1)
    Next

EndFunc   ;==>Remove_All

By the way, if you're using the full SciTE autoit editor, try pressing Ctrl+T (or "tidy" in the Tools menu). It is extremely useful. It will do things like autoindent your code, standardise the cases (as in capital/lowercase) in your keywords and warn you for unbalanced nestings (not that you currently have any, but still :) ). In general it will make your code easier to read and to debug.

BTW2: if you're using Hungarian notation, change $iLine to $aLine. I for one consider the whole concept of HN unsavory, even in weakly typed languages, but that's a question of opinion :)

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

iresolver,

I knocked this together as an example of externalizing your logon data.  I used message loop mode because I find event mode clumsy for multiple gui's.  Note, this is a bare bones example showing the use of an INI file...

#RequireAdmin
#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <array.au3>

Local $INIFileName = @ScriptDir & '\autoemail.ini'

Local $gui010 = GUICreate('AutoEmail', 200, 200)
Local $cmb010 = GUICtrlCreateCombo('', 10, 10, 180, 200)
Local $logon = GUICtrlCreateButton('Logon', 10, 140, 180, 20)
Local $btn010 = GUICtrlCreateButton('Add Email Account/User', 10, 170, 180, 20)

; populate combo box
Local $aINI = IniReadSectionNames($INIFileName)
GUICtrlSetData($cmb010, _ArrayToString($aINI, '|', 1), $aINI[1])

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $logon
            $EName = GUICtrlRead($cmb010)
            $EPswd = IniRead($INIFileName, $EName, 'pswd', 'NONE')
            If $EPswd = 'NONE' Then _Add_Email()
            If StringInStr($EName, 'gmail') Then gmail($EName, $EPswd)
            If StringInStr($EName, 'hotmail') Then hotmail($EName, $EPswd)
        Case $btn010
            _Add_Email()
    EndSwitch

WEnd

Func gmail($uid, $pwd)

    Local $oIE = _IECreate("https://accounts.google.com/ServiceLogin?sacu=1&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fpc%3Dtopnav-about-en&hl=en&service=mail", 1)

    Local $username = _IEGetObjByName($oIE, "Email")
    Local $password = _IEGetObjByName($oIE, "Passwd")

    Local $Email_button = _IEGetObjByName($oIE, "account-email")
    Local $Signin_button = _IEGetObjByName($oIE, "signIn")

    _IEFormElementSetValue($username, $uid)
    _IEFormElementSetValue($password, $pwd)

    _IEAction($Email_button, "click")
    _IEAction($Signin_button, "click")

EndFunc   ;==>gmail

Func hotmail($uid, $pwd)

    Local $oIE = _IECreate("http://www.live.com", 1)

    Local $username = _IEGetObjByName($oIE, "login")
    Local $password = _IEGetObjByName($oIE, "passwd")
    Local $Signin_button = _IEGetObjByName($oIE, "SI")

    _IEFormElementSetValue($username, $uid)
    _IEFormElementSetValue($password, $pwd)
    _IEAction($Signin_button, "click")

EndFunc   ;==>hotmail

Func _Add_Email()

    Local $AddGui = GUICreate('Add Email', 200, 100)
    GUICtrlCreateLabel('Email', 10, 10, 50, 20)
    Local $N_Email = GUICtrlCreateInput($EName, 60, 10, 100, 20)
    GUICtrlCreateLabel('Password', 10, 30, 50, 20)
    Local $N_pswd = GUICtrlCreateInput('', 60, 30, 100, 20)
    Local $ADD = GUICtrlCreateButton('ADD Account', 10, 70, 80, 20)
    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete($AddGui)
                Return
            Case $ADD
                IniWriteSection($INIFileName, guictrlread($N_Email), 'pswd=' & guictrlread($N_pswd) & @LF)
                If @error Then Exit MsgBox(0, 'INI WRITE ERROR', 'Section = ' & guictrlread($N_Email) & @CRLF & 'pswd = ' & guictrlread($N_pswd))
                ; re - populate combo box
                Local $aINI = IniReadSectionNames($INIFileName)
                GUICtrlSetData($cmb010, '|' & _ArrayToString($aINI, '|', 1), $aINI[1])

                guidelete($AddGui)
                return
        EndSwitch

    WEnd

EndFunc   ;==>_Add_Email

This is an example of the INI file used in this code autoemail.txt

Just rename it to an INI file.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

I Found a way to Delete Line inside the script it's not the best but it works

I know I should use an array but can't seam to get that to work

here is my way

#RequireAdmin
#include <File.au3>






;----------------------------------- This is the test files that Will be deleted -----------------------------------------------------------



;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;this is the Lines that will be deleted
;-------------------------------------------------------------------------------------------------------------------------------------------
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
Del_Lines()

Func Del_Lines()
    Global $sFilePath = @ScriptDir & "\Del_Lines.au3"
    Local $Del = ""
    Local $Lines

    Local $Start = 11 ; Starting Line Number
    Local $End = 18 ; Ending Line Number
    For $Lines = $Start To $End
        $Write = _FileWriteToLine($sFilePath, $Lines, $Del, 1)
    Next

    Del_MoreLines()
    Del_MoreLines()
    Del_MoreLines()
    Del_MoreLines()

EndFunc   ;==>Del_Lines

Func Del_MoreLines()
    Local $Del = ""
    Local $Lines

    Local $Start = 10
    Local $End = 18
    For $Lines = $Start To $End
        $Write = _FileWriteToLine($sFilePath, $Lines, $Del, 1)

    Next

EndFunc   ;==>Del_MoreLines
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...