Jump to content

Email Finder


Recommended Posts

So I am making a program that will read all of the text files specified, and return all email addresses found and put them in a different text file, I got a good headstart and I am working quite well, but I have run into a slight problem, What is wrong here:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Email = "@"
#Region ### START Koda GUI section ### Form=C:\Users\Isaiah Business\Desktop\Email Finder\Koda.kxf
$FileFinder = GUICreate("FileFinder", 615, 421, -1, -1)
GUISetIcon("C:\Windows\System32\imageres.dll", -29)
$FFText = GUICtrlCreateLabel("File Finder", 8, 8, 130, 36)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Progress1 = GUICtrlCreateProgress(0, 144, 617, 17)
$LFE = GUICtrlCreateButton("Look for Email", 128, 80, 321, 49)
$Help = GUICtrlCreateButton("Help", 528, 8, 81, 33)
$ChooseLoc = GUICtrlCreateButton("Choose Location", 152, 48, 273, 33)
$FI = GUICtrlCreateInput("File",250,200,200,20)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $ChooseLoc
   MsgBox(0,"","Choose where you want the Data to be stored, Must be Text Files")
   $FileSelect = FileOpenDialog("Choose your file:" , "Desktop","Text files (*.txt)")
   MsgBox(0,"Now...","Press the Start button")
  Case $LFE
   $FSF = FileSelectFolder("Choose your folder: ","",4,"")
   GUICtrlSetData($FI,$FSF)
   MsgBox(0,"Choose your files:","Choose your file." & @CRLF & "You can multi select files")
   $FileSelect2 = FileOpenDialog("Select File",$FSF,"All(*.*)",4,"")
   $FileRead = FileRead($FileSelect2)
   If $FileRead = $Email Then
    FileWriteLine($FileSelect, $FileRead)
    EndIf
EndSwitch
WEnd

First of all press the "Choose Location", and then click search for email.

Check out my new site!Current Projects:[list][*]Hunter Console - A Small Gadget[*]HunterPad - Basic Notepad aimed at Programmers[*]Betters UP! - Betting Game[/list]
Link to comment
Share on other sites

Check the data function FileOpenDialog returns when you select multiple files.

Your script doesn't handle this correctly.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

:) Dude, you have really got problems with your script... If I remember, you wanted to read e-mail addresses within a file. You assign $EMAIL = "@" and try to equate it with FileRead("your_file"). That is really making me sick. ;) Anyways, made some improvements to your script:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Email = "@"
#Region ### START Koda GUI section ### Form=C:\Users\Isaiah Business\Desktop\Email Finder\Koda.kxf
$FileFinder = GUICreate("FileFinder", 615, 421, -1, -1)
GUISetIcon("C:\Windows\System32\imageres.dll", -29)
$FFText = GUICtrlCreateLabel("File Finder", 8, 8, 130, 36)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Progress1 = GUICtrlCreateProgress(0, 144, 617, 17)
$LFE = GUICtrlCreateButton("Look for Email", 128, 80, 321, 49)
$Help = GUICtrlCreateButton("Help", 528, 8, 81, 33)
$ChooseLoc = GUICtrlCreateButton("Choose Location", 152, 48, 273, 33)
$FI = GUICtrlCreateInput("File",250,200,200,20)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $ChooseLoc
   MsgBox(0,"","Choose where you want the Data to be stored, Must be Text Files")
   $FileSelect = FileOpenDialog("Choose your file:" , "Desktop","Text files (*.txt)")
   If @error then
            donothing()
            else
            MsgBox(0,"Now...","Press the Start button")
            EndIf
  
  Case $LFE
   $FSF = FileSelectFolder("Choose your folder: ","",4,"")
   GUICtrlSetData($FI,$FSF)
   MsgBox(0,"Choose your files:","Choose your file." & @CRLF & "You can multi select files")
   $FileSelect2 = FileOpenDialog("Select File",$FSF,"All(*.*)",4,"")
   If @error then
            donothing()
            else
            $FILENAME = StringSplit($FileSelect2, "|")
            For $x = 1 to $FILENAME[0]
            $FileRead = FileRead($FILENAME[$x])
   If StringInStr($FileRead, $Email) <> 0  Then
    FileWriteLine($FileSelect, $FileRead)
    Next
    EndIf
            EndIf
  
EndSwitch
WEnd
Func donothing()
EndFunc

This modified script can handle errors (related to File Dialogs). Also, I suggest you go and read the String Management section of help file properly. Also, check fileread examples on the forum and in help file. You will come to know of the mess you created :)

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

I'm curious as to how you're picking up these text files and why you're scraping them for e-mail addresses.

My Dad wants me to make it, as he runs a business and needs to get his contacts together.
Check out my new site!Current Projects:[list][*]Hunter Console - A Small Gadget[*]HunterPad - Basic Notepad aimed at Programmers[*]Betters UP! - Betting Game[/list]
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...