Jump to content

Clip Question


styles3000
 Share

Recommended Posts

Hey Fella's,

I gotta a little problem. I have a function that looks at this documents dddddd.txt. I want the function to go in and extract JUST ...<meta name="verify-v1" content="EnhXI57tuxWNlAkxSBDWYXP0rYphvpNDtjiyZ2v1GGk=" /> and place it on the clipboard. How can I do that?

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

$Find_This = "<head>"
$Find_This_Too = "<title>"
$hFile = FileOpen("D:\Documents and Settings\Taevon Jones\Desktop\dddddd.txt ",0)    ;Open file in read mode

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    )
    $text_from_clip = ClipGet()    ;Takes the result off the clipboard
    $result = StringReplace($SomeTxt, $MyResult, $text_from_clip)
    Clipput($Result)    ;Put the result on the clipboard
Else
    MsgBox(0,"Warning", "Unable to find the wanted string")
EndIf
Link to comment
Share on other sites

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

$Find_This = "<head>"
$Find_This_Too = "<title>"
$hFile = FileOpen("D:\Documents and Settings\Taevon Jones\Desktop\dddddd.txt ",0)    ;Open file in read mode

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    )
    $text_from_clip = ClipGet()    ;Takes the result off the clipboard
    $result = StringReplace($SomeTxt, $MyResult, $text_from_clip)
    Clipput($Result)    ;Put the result on the clipboard
Else
    MsgBox(0,"Warning", "Unable to find the wanted string")
EndIf

Something like this perhaps

$start = "<meta name="
$finish = "/>"
clipput($start & _stringbetween($someText,$start,$finish) & $finish)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

run this as is:

$hFile = FileOpen("D:\Documents and Settings\Taevon Jones\Desktop\dddddd.txt ", 0) ;Open file in read mode

If @error Then
    MsgBox(0, "Warning", "Unable to open file")
    Exit
EndIf

$SomeTxt = FileRead($hFile) ;reads the complete file
FileClose($hFile)

$start = "<meta name="
$finish = "/>"
ClipPut($start & _StringBetween($SomeTxt, $start, $finish) & $finish)

;http://www.autoitscript.com/forum/index.php?showtopic=19718&view=findpost&p=136319
Func _StringBetween($s_String, $s_Start, $s_End = 0)
    $s_Start = StringInStr($s_String, $s_Start) + StringLen($s_Start)
    Return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End) - $s_Start)
EndFunc   ;==>_StringBetween

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

It works perfectly, thanks a million.

run this as is:

$hFile = FileOpen("D:\Documents and Settings\Taevon Jones\Desktop\dddddd.txt ", 0) ;Open file in read mode

If @error Then
    MsgBox(0, "Warning", "Unable to open file")
    Exit
EndIf

$SomeTxt = FileRead($hFile) ;reads the complete file
FileClose($hFile)

$start = "<meta name="
$finish = "/>"
ClipPut($start & _StringBetween($SomeTxt, $start, $finish) & $finish)

;http://www.autoitscript.com/forum/index.php?showtopic=19718&view=findpost&p=136319
Func _StringBetween($s_String, $s_Start, $s_End = 0)
    $s_Start = StringInStr($s_String, $s_Start) + StringLen($s_Start)
    Return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End) - $s_Start)
EndFunc   ;==>_StringBetween

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...