Sign in to follow this  
Followers 0
styles3000

Clip Get Question

3 posts in this topic

Hey Fellas,

In this script I want to take whats off the clipboard(ClipGet) and place it between the Start and End locations. Here's the document that I'm using.HOME-MASTER-PHP.htm When I run the script, it says unable to find. I know I need to make a minor adjustment somewhere.Could some one help me?

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

$Find_This = "<googlecode>"
$Find_This_Too = "</googlecode>"
$hFile = FileOpen("D:\Documents and Settings\Taevon Jones\Desktop\HOME-MASTER-PHP ",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    )
    ClipGet()    ;Takes the result off the clipboard
    ;Clipput($MyResult)    ;Put the result on the clipboard
Else
    MsgBox(0,"Warning", "Unable to find the wanted string")
EndIf

Share this post


Link to post
Share on other sites



Maybe something like this:

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

Share this post


Link to post
Share on other sites

Maybe something like this:

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

It still says unable to find, what could I be doing wrong?

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  
Followers 0