Sign in to follow this  
Followers 0
Dryden

Help: Paste as Text

16 posts in this topic

Hi again.

A couple of months ago, I developed a script to help me filing forms of some other old software, but sometimes my script crashes and I didn't know why, until now.

Here's the thing, my script captures emails from outlook and puts them in the other software, the problem is that in certain emails the text has some weird fonts and/or images that the other software don't recognize, in fact the other software only recognizes simple text.

My script uses a basic Ctr+C in outlook to copy the entire text, then it transforms the text into a variable and injects it in the program without the need of it being visible, what I'm looking for is a way of converting my variable to simple text and every time there's an image in the middle of the text replace it for the word %7Boption%7D for example.

Thx in advance.


"Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." - Terry Pratchett.

Share this post


Link to post
Share on other sites



I can be mistaken but try String function

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

you might have to look at the dreaded StringRegExp () there's a pattern match for any "word" character: a-z, A-Z, 0-9 or underscore (_) \w or Match any non-word character \W & get rid of it.

if you show us what you want to keep and what you want not to keep maybe we can generate the pattern.

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

I think I've probably bitten more than I can chew... :S

The problem is I don't want to save only some things here or there, I want the whole text. I give you an example: if instead of injecting the text from Outlook directly to the other program I paste it in Notepad++ or SciTE and then if I copy it form one of this programs and injected from there, it never crashes because the text loses it's format and images and becomes simple text.


"Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." - Terry Pratchett.

Share this post


Link to post
Share on other sites

Have you tried what I have suggested? use String function e.g

$MyVarWithText = String($YourVariableWithTextAndImages)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

or even if your not happy with what Ombra has suggested what about instead of just using Ctrl C to copy and the getting the string from the clipboard why not find the ID of the edit control and use GUICtrlRead() would this not remove formatting etc , not sure but no harm in trying ?

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

How do you capture the emails from outlook? I think there is a way to capture it as plain text.

Share this post


Link to post
Share on other sites

Have you tried what I have suggested? use String function e.g

$MyVarWithText = String($YourVariableWithTextAndImages)
I've tried that, It. I think it solved it... let me test it out for a day or so to see if crashing stops.

or even if your not happy with what Ombra has suggested what about instead of just using Ctrl C to copy and the getting the string from the clipboard why not find the ID of the edit control and use GUICtrlRead() would this not remove formatting etc , not sure but no harm in trying ?

In the beginning I thought of doing that, the problem is that most of the times the same email goes back and forward between my company and the clients and the mail keeps getting bigger in each reply, so I just want the new text to be injected in the other program, otherwise I'm just (re)pasting the same thing. This way, the person who's checking the emails just have to select the part of the email that is new press Ctrl+C ant then press a given key to update the other program.

"Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." - Terry Pratchett.

Share this post


Link to post
Share on other sites

Ombra, thnx for the help, but sadly it didn't work.

Here's a bit of my code:

Func Preencheentrada()
If WinActive("Criar\Editar comunicação") Then
    $prautodata=IniRead("K-Auto.ini","Configs","prdata","")
    If $prautodata<>1 Then
        $assunto=InputBox($prog,"Assunto")
        $assuntoantcomunic=$assunto
    Else
        $assunto=("Recepção de email no dia " & _NowDate())
        
    EndIf
    BlockInput(1)
    $descricaotemp=_ClipBoard_GetData()
    $descricao=String($descricaotemp)
    WinActivate("Criar\Editar comunicação")
;~  Assunto e Descrição
    ControlSetText("Criar\Editar comunicação", "", "[CLASS:ThunderRT6TextBox; INSTANCE:5]", $assunto)
    ControlSetText("Criar\Editar comunicação", "", "[CLASS:ThunderRT6TextBox; INSTANCE:4]", $descricao)
    ControlClick("Criar\Editar comunicação", "", "[CLASS:Edit; INSTANCE:2]")
    Send($utilizador)

I used to have:

$descricao=_ClipBoard_GetData()

But now I replaced it for

$descricaotemp=_ClipBoard_GetData()
$descricao=String($descricaotemp)

I think that it clears at least some text formating (maybe all), but (although it seems to be happening less frequently) the script keeps crashing in some emails...

I'm starting to think that could be something to do with this computer and not with the script itself, because I asked one of the other users of my script if he have had many crashes and he says that it happens very rarely.

There are 4 people using it and it seems that almost never happens to any of them but in my computer it happens at least 5/10 times a day... :S

Any suggestions?


"Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." - Terry Pratchett.

Share this post


Link to post
Share on other sites

sorry but what is crashing ? the AI script or your email program outlook i think you said or the "other program" you mentioned.

My script crashes. It's one of those windows "Program Stopped Responding" errors.


"Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." - Terry Pratchett.

Share this post


Link to post
Share on other sites

hi every one,

i am at a beginner level when it comes to programing in PHP.

i want to make an array of names of class students , but can get it rite.

i want it to be in such a way that , each person enters his/her name in HTML text box and presses submit and the name is stored in array.

Share this post


Link to post
Share on other sites

sorry Dryden, your guna need a guru i think. if your inputting the result from String($descricaotemp) and its giving that kind of crash then you got me :)

Welokeype , i think you meant to post a new post not interrupt into this one ! so post again with a new post. but welcome anyhow.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

sorry Dryden, your guna need a guru i think. if your inputting the result from String($descricaotemp) and its giving that kind of crash then you got me :party:

Well, thx for the help. I think I'm going do a "not so high-tech" script, I'm guessing that if instead of ControlSetText() I could use Send() or paste it directly from clipboard. My 1st version worked with Send() and it never crashed, going back a step...

Anyway, thx again! :)


"Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." - Terry Pratchett.

Share this post


Link to post
Share on other sites

well i wouldn't give up just yet, you can try doing some fault diagnosis.

find an email the is making it crash,

firstly check that it makes it crash every time you use it, if its does not crash every time with the same text input then i cant go not further, but if it does crash every time then you can start looking at what exactly is causing the problem by a process of elimination.

basically just remove one part of the offending text at a time until you find what is the cause, once you have found what it is you can then deal with it.

it might be quite a long process but might be worth it in the end.

but it does sound a little odd that you say it's crashing more on some pc's than others but that might just be a coincidental effect of not knowing the exact cause, but on the other hand might not and would need all your code being picked apart :)

anyhow good luck with whatever you decide.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

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