Jump to content
Sign in to follow this  
Dasttann777

Email Finder

Recommended Posts

Dasttann777

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]

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Blue_Drache

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


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
stormbreaker

:) 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

Share this post


Link to post
Share on other sites
Dasttann777

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]

Share this post


Link to post
Share on other sites
Dasttann777

So you guys are saying I should rebuild my script?

I am new to this, so help is appreciated. ;):) :) ;):D


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

Share this post


Link to post
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
Sign in to follow this  

×