Sign in to follow this  
Followers 0
styles3000

Re-writing Function To Send From The Clipboard

5 posts in this topic

I'm wanting to replace a string within a file. The problem I'm having is that I'm coming from the clipboard. I've been trying to send what was copied without shellexecuting. Is it possible to StringReplace from the clipboard to a file without opening it?

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:\Objects To Burn\Adsense\websites\HOME-MASTER-PHP2.htm ",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


Sleep(5000)
ShellExecute("D:\Objects To Burn\Adsense\websites\HOME-MASTER-PHP2.htm ")
Sleep(5000)
Send("{ALTDOWN}{ALTUP}e")
Sleep(500)
Send("a")
Sleep(500)
Send("{CTRLDOWN}v{CTRLUP}")

Share this post


Link to post
Share on other sites



I'm wanting to replace a string within a file. The problem I'm having is that I'm coming from the clipboard. I've been trying to send what was copied without shellexecuting. Is it possible to StringReplace from the clipboard to a file without opening it?

You want to write to a file without opening it...? ;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You want to write to a file without opening it...? Posted Image

My bad, that was a poor choice of words. I do want to go into the file but without opening it on my desktop.

In other words, I want to open it in a "behind the scenes" kind of way.

Share this post


Link to post
Share on other sites

My bad, that was a poor choice of words. I do want to go into the file but without opening it on my desktop.

In other words, I want to open it in a "behind the scenes" kind of way.

Use FileOpen and FileWrite then.

Share this post


Link to post
Share on other sites

Use FileOpen and FileWrite then.

thanks

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