Jump to content
Sign in to follow this  
ashley

FileWriteLine HTML and __IENavigate

Recommended Posts

ashley

ok i have another problem...

as you may know i making a program called 'SimpleSearch'... well when a file is found it wrights that filw to a html file then shows it...

But it refreshes everytime it finds one...

I dont want it to... i want to go to Search.htm untill its done then show Files.htm

heres my code:

;
; Author: Ashley
; E-mail: ashww@aol.com
;
; Program: SimpleSearch V.1.3 Build 3
; Purpose: To search for files
; Date   : 26th August 2007
;
; ----------------------------------------------------------------------------

#include <GUIConstants.au3>
#include <file.au3>
#include <Array.au3>
#include <ie.au3>
$all = @HomeDrive
$version = "1.3, 'Build 3'"
Opt("GUICloseOnEsc", 1)     

Global $pn
Global $pl[10]
Global $opt
Global $title = "SimpleSearch | Ashley"
Global $Store=@ProgramFilesDir&"\SimpleSearch"
Global $Slider1, $Form2
;delete files
FileDelete(@TempDir&"\files.htm")
FileDelete(@TempDir&"\start.htm")
FileDelete(@TempDir&"\startmain.htm")
FileDelete(@TempDir&"\search.htm")
;open files
$index=FileOpen($Store & "\Index.htm",1)
$filesHtml=FileOpen(@TempDir&"\files.htm",1)
$StartmainHtml=FileOpen(@TempDir&"\startmain.htm",1)
$search=FileOpen(@TempDir&"\search.htm",1)
;Write file
FileWriteLine($StartmainHtml,"<p><font size=2><Center><b>Welcome to 'SimpleSearch' Version: " & $version & "." &"</b></font></p><p></p>")
FileWriteLine($StartmainHtml,"<p><font size=2><Center><b> To Search type in the search box lables 'Type here to search your pc for files' </b></font></p><p></p>")
FileWriteLine($StartmainHtml,"<p><font size=2><Center><b> To exit press 'ESC' </b></font></p><p></p>")
FileWriteLine($StartmainHtml,"<Br><Br><Br><Br><Br><Br><Br><Br><Br><Br><Br><Br><Br><Br><Br><Font Size=4 Color=0X0080Ff><Center><B>To Begin, Type In The Search Box</B></Center></Font>")
FileClose($StartmainHtml)

FileWriteLine($search,"<p><font size=2><Center><b>Searching...</b></font></p><p></p>")
FileClose($search)
_Singleton("SimpleSearch | Ashley");-allow only one open

$oIE = _IECreateEmbedded() ;-make the first html window
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate($title, 500, 541)
$Searchfile = GUICtrlCreateButton("Search", 420, 462, 75, 25, 0)
$website = GUICtrlCreateLabel("SimpleSoftware.freefourms.org", 353, 523, 147, 17)
$FileType = GUICtrlCreateInput("Type here to search your pc for files", 8, 464, 410, 21)
$linebrake = GUICtrlCreateLabel("---------------------------------------------------------------------------------------------------------------------------------------------------------------------", 0, 450, 510, 17)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$Filelist = GUICtrlCreateObj($oIE,0, 0, 500, 450)
_IENavigate($oIE, @TempDir&"\startmain.htm", 0)
$WindowsV = GUICtrlCreateLabel("Your windows version is:",  8, 496, 200, 17)
$Index = GUICtrlCreateButton("Index (broke)", 3, 515, 75, 25, 0)
$transparency = GUICtrlCreateButton("Set Transparency", 80, 515, 95, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;sets OS version
If @OSVersion=="WIN_95" Then Changeos() 
If @OSVersion=="WIN_98" Then Changeos()
If @OSVersion=="WIN_ME" Then Changeos()
If @OSVersion=="WIN_NT4" Then Changeos()
If @OSVersion=="WIN_2000" Then Changeos()
If @OSVersion=="WIN_XP" Then Changeos() 
If @OSVersion=="WIN_VISTA" Then Changeos()
If GUICtrlRead($WindowsV) = "Your windows version is:" Then nChangeos()


While 1
 $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $GUI_EVENT_CLOSE
           If $nMsg[1] = $Form1 then Exit
        Case $Searchfile
            $Results = _FileSearch($all, GuiCtrlRead($FileType), 1, '', True)
        Case $Index
        
        Case $transparency
            transparency()
    EndSwitch
    
WEnd

Func SearchButton()
_IENavigate($oIE, @TempDir&"\search.htm", 0)
$Results = _FileSearch($all, GuiCtrlRead($FileType), 1, '', True)
EndFunc


;the search func;s

Func _FileSearch($sPath, $sFilter = '*.*', $iFlag = 0, $sExclude = '', $iRecurse = False)
    ;Verify folder exists
    If Not FileExists($sPath) Then Return SetError(1, 1, '')
    
    ;Set file filter to default
    If $sFilter = -1 Or $sFilter = Default Then $sFilter = '*.*'

    ;Set folder/file flag to default
    If $iFlag = -1 Or $iFlag = Default Then $iFlag = 0

    ;Set exclude filter to default
    If $sExclude = -1 Or $sExclude = Default Then $sExclude = ''

    ;Declare characters not allowed in file filter or exclude filter
    Local $aBadChar[6] = ['\', '/', ':', '>', '<', '|']

    ;Check file filter and exclude filter for bad characters
    For $iCC = 0 To 5
        If StringInStr($sFilter, $aBadChar[$iCC]) Or StringInStr($sExclude, $aBadChar[$iCC]) Then Return SetError(2, 2, '')
    Next

    ;Verify file filter isn't just empty space
    If StringStripWS($sFilter, 8) = '' Then Return SetError(2, 2, '')

    ;Verify file flag is 0(Files and folders),1(Files), or 2(Folders)
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, '')

    ;Append semi-colon to file filter (multiple filters allowed)
    If Not StringInStr($sFilter, ';') Then $sFilter &= ';'

    ;Split file filter string into array with whitespace removed (Filters with spaces will not work!)
    Local $aSplit = StringSplit(StringStripWS($sFilter, 8), ';'), $sRead
    ;Loop through file filters
    For $iCC = 1 To $aSplit[0]
        ;Skip empty filters
        If StringStripWS($aSplit[$iCC], 8) = '' Then ContinueLoop

        ;Check if leftmost character is a period and ????
        If StringLeft($aSplit[$iCC], 1) = '.' And UBound(StringSplit($aSplit[$iCC], '.')) - 2 = 1 Then 
            ;Set current file filter to wildcards
            $aSplit[$iCC] = '*' & $aSplit[$iCC]
        EndIf

        Local $iPid

        ;Recursive search if $iRecurse is set true
        If Not $iRecurse Then
            $iPid = Run(@ComSpec & ' /c ' & 'dir "' & $sPath & '\' & $aSplit[$iCC] & '" /b /o-e /od', '', @SW_HIDE, 6)
        Else
            $iPid = Run(@Comspec & ' /c dir /b /s /a "' & $sPath & '\' & $aSplit[$iCC] & '"', '', @SW_HIDE, 6)
        EndIf

        ;Capture output from dir command
        While 1
            $sRead &= StdoutRead($iPid)
            If @error Then ExitLoop
        WEnd
    Next

    ;Verify dir result isn't whitespace
    If StringStripWS($sRead, 8) = '' Then Return SetError(4, 4, '')

    ;Split search results by line
    Local $aFSplit = StringSplit(StringTrimRight(StringStripCR($sRead), 1), @LF)
    Local $sHold

    ;Loop through results array
    For $iCC = 1 To $aFSplit[0]
        ;If exclusion filter is greater than zero
        If $sExclude And StringLeft(StringTrimLeft($aFSplit[$iCC], StringInStr($aFSplit[$iCC], '\', 0, -1)), StringLen(StringReplace($sExclude, '*', ''))) = StringReplace($sExclude, '*', '') Then 
            ContinueLoop
        EndIf

        ;Check result against file/folder flag
        Switch $iFlag
            Case 0 ;Files and folders
                $sHold &= $aFSplit[$iCC] & Chr(1)

            Case 1 ;Files ONLY
                If StringInStr(FileGetAttrib($aFSplit[$iCC]), 'd') Then ContinueLoop
                $sHold &= $aFSplit[$iCC] & Chr(1)

                ;Add item to html, show size in mb
            
            FileWriteLine($filesHtml,"<p><font size=2><b>" & $aFSplit[$iCC] & "|"  & StringFormat("%.2f mb", FileGetSize($aFSplit[$iCC]) / 1048576) & "</b></font></p><p></p>")
            _IENavigate($oIE, @TempDir&"\Files.htm", 0)
            
            Case 2 ;Folders ONLY
                If Not StringInStr(FileGetAttrib($aFSplit[$iCC]), 'd') Then ContinueLoop
                $sHold &= $aFSplit[$iCC] & Chr(1)
                
        EndSwitch
    Next

    ;If # of characters in result is greater than 1, split by Start of Header special character and return
    If StringTrimRight($sHold, 1) Then 
        Return StringSplit(StringTrimRight($sHold, 1), Chr(1))
    EndIf
            
    Return SetError(4, 4, '')
    
EndFunc

 


;end search func's

Func Changeos() ;-changes the 0S version
    GUICtrlSetData($WindowsV, "Your Windows version is "& @OSVersion &".")
endfunc

Func nChangeos() ;-if not running on windows
    GUICtrlSetData($WindowsV, "You are not running on a windows system")
endfunc

;index
Func _index()

EndFunc
;end index func's


Func transparency()
$Form2 = GUICreate("Set transparency.", 345, 80, 191, 109)
$Slider1 = GUICtrlCreateSlider(32, 32, 281, 41)
$Label1 = GUICtrlCreateLabel("Move the Slider Across the bar to make the window more transparent", 8, 8, 329, 17)
GUISetState(@SW_SHOW)


GUICtrlSetLimit($Slider1, 5, 1)

While 1
    $Msg = GUIGetMsg(1)
    Switch $Msg[0]
        Case $GUI_EVENT_CLOSE
            If $Msg[1] = $Form2 then ExitLoop(1)
        Case $Slider1
            $TransLevel = GUICtrlRead($Slider1)
            Switch $TransLevel
                Case 1
                    WinSetTrans($Form1, "", 255)
                Case 2
                    WinSetTrans($Form1, "", 200)
                Case 3
                    WinSetTrans($Form1, "", 150)
                Case 4  
                    WinSetTrans($Form1, "", 100)
                Case 5
                    WinSetTrans($Form1, "", 50)
                Case 5
                    WinSetTrans($Form1, "", 0)
 
            EndSwitch
    EndSwitch
WEnd
GuiDelete($form2)
EndFunc

Anyideas

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.