Jump to content

Cropping Info


styles3000
 Share

Recommended Posts

Hello,

I will already have info stored in the clipboard.I want to take whats copied in the clipboard and hold it. I want autoit to go into D:\Documents and Settings\Taevon Jones\Desktop\HOME-MASTER-PHP ,look for the symbol and words"<script type" and "</script>", once it finds it I want it to select all thats in between the "<script type" and "</script>" and paste what ever is in the clipboard.

I also want autoit to go into D:\Documents and Settings\Taevon Jones\Desktop\PAGE-MASTER-PHP and look for the symbol and words "<script type" and "</script>" as well. Once it finds it I want it to do the same thing and select all thats in between the "<script type" and "</script>" and paste what ever in the clipboard. Be mindful that the symbol and words"<script type" and "</script>" occurs a few times. So if we could write the script to scan both of the documents and where ever it sees the symbol and words"<script type" and "</script>" to perform the above, that'll be great.

I have a script here that I need help altering to form it to the what I just said above.

#include <file.au3>
Global $hFile
Global $SomeTxt
Global $StartPos, $EndPos
Global $Find_This, $Find_This_Too
Global $MyResult

$Find_This = "<script type"
$Find_This_Too = "</script>"
$hFile = FileOpen("D:\Documents and Settings\Taevon Jones\Desktop\HOME-MASTER-PHP ",0)    ;Open file in read mode
$hFile = FileOpen("D:\Documents and Settings\Taevon Jones\Desktop\PAGE-MASTER-PHP ",0)
If @error Then
    MsgBox(0,"Warning", "Unable to open file")
    Exit
EndIf

$SomeTxt = FileRead($hFile)    ;reads the complete file
FileClose($hFile)
$StartPos = StringInStr($SomeTxt,$Find_This) + StringLen($Find_This) ;finds the first string and puts the pos direct behind the found string

If $StartPos = 0 Then        ;means $Find_This not found, no need to continue
    MsgBox(0,"Warning", "Unable to find: " & $StartPos)
    Exit
Else
    ConsoleWrite("$StartPos= " & $StartPos & @CRLF)        ;not needed just added to check if code works
EndIf

$EndPos = StringInStr($SomeTxt,$Find_This_Too,0,1,$StartPos) ;finds the first occurence of $Find_This_Too after $Start_pos

If $EndPos = 0 Then        ;means $Find_This_Too was not found, no need to continue
    MsgBox(0,"Warning", "Unable to find: " & $EndPos)
    Exit
Else
    ConsoleWrite("$EndPos= " & $EndPos & @CRLF)        ;not needed just added to check if code works
EndIf

$MyResult = (StringMid($SomeTxt,$StartPos,$EndPos-$StartPos))
$MyResult = StringStripWS($MyResult,3)

If StringLen($MyResult) <> 0 Then
    MsgBox(0,"Finished", "You were looking for: " & $MyResult    )
    ClipPut($MyResult)    ;Put the result on the clipboard
Else
    MsgBox(0,"Warning", "Unable to find the wanted string")
EndIf
Link to comment
Share on other sites

So it should look like this......

#include <file.au3>
Global $hFile
Global $SomeTxt
Global $StartPos, $EndPos
Global $Find_This, $Find_This_Too
Global $MyResult

$Find_This = "<script type"
$Find_This_Too = "</script>"
$hFile = FileOpen("D:\Documents and Settings\Taevon Jones\Desktop\HOME-MASTER-PHP ",0)    ;Open file in read mode
;$hFile = FileOpen("D:\Documents and Settings\Taevon Jones\Desktop\PAGE-MASTER-PHP ",0)
If @error Then
    MsgBox(0,"Warning", "Unable to open file")
    Exit
EndIf

$SomeTxt = FileRead($hFile)    ;reads the complete file
FileClose($hFile)
$StartPos = StringInStr($SomeTxt,$Find_This) + StringLen($Find_This) ;finds the first string and puts the pos direct behind the found string

If $StartPos = 0 Then        ;means $Find_This not found, no need to continue
    MsgBox(0,"Warning", "Unable to find: " & $StartPos)
    Exit
Else
    ConsoleWrite("$StartPos= " & $StartPos & @CRLF)        ;not needed just added to check if code works
EndIf

$EndPos = StringInStr($SomeTxt,$Find_This_Too,0,1,$StartPos) ;finds the first occurence of $Find_This_Too after $Start_pos

If $EndPos = 0 Then        ;means $Find_This_Too was not found, no need to continue
    MsgBox(0,"Warning", "Unable to find: " & $EndPos)
    Exit
Else
    ConsoleWrite("$EndPos= " & $EndPos & @CRLF)        ;not needed just added to check if code works
EndIf

$MyResult = (StringMid($SomeTxt,$StartPos,$EndPos-$StartPos))
$MyResult = StringStripWS($MyResult,3)

If StringLen($MyResult) <> 0 Then
    MsgBox(0,"Finished", "You were looking for: " & $MyResult    )
    ClipPut($MyResult)    ;Put the result on the clipboard
Else
    MsgBox(0,"Warning", "Unable to find the wanted string")
EndIf
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...