Jump to content

Retrieving selected text from outside.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
estro

estro

    Newbie

  • Members
  • Pip
  • 6 posts
How is possible to input text selected outside of my python program to lets say a text file...

#2
LogicKills

LogicKills

    Programmer

  • Members
  • PipPipPipPip
  • 139 posts

estro said:

How is possible to input text selected outside of my python program to lets say a text file...

What do you mean text selected outside?
http://logickills.org
Science - Math - Hacking - Tech

#3
estro

estro

    Newbie

  • Members
  • Pip
  • 6 posts

LogicKills said:

What do you mean text selected outside?
Lets say the user selects some text within openoffice writer, and clicks some hot key (let's say ctrl+alt), how can my python program retrieve the selected text. (the user don't puts the selected text on clipboard by copying it...).

#4
manux

manux

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 234 posts
I know its possible with pygame to get what's in the clipboard, I know it works in WinXP, so I guess its possible if you play with the windows librairies, and since Python is very versatile, some lib already surely exists.

#5
Donovan

Donovan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 798 posts
Yes, you can do this with Python. Since Python is used for
"Getting data from a keyboard, a file, or some other device"

f = open("filename")
while 1:
    line = f.readline()
    if not line: break
    #process(line)

f.close()
           

Source: Text files: iterating over the lines in the file : Text File Read*«*File*«*Python

Go to this site and read. It tells you all the many different ways you can have it read from a text file:)
Posted Image
+Friend Me | My Graphics | Forum Rules | Help Forum | Forum FAQ

#6
manux

manux

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 234 posts
I think he meant getting things from the clipboard, you know CTRL+C, CTRL+V, the famous copy&paste :) .

Or actually he didn't, since with his openoffice example he is talking about taking the selected text, which is I guess a "variable" contained in openoffice, then I guess, it's up to interprocess communication, but I doubt openoffice supports that, you can always search in the doc...

#7
Donovan

Donovan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 798 posts
I am sure if he reads the site I linked him it will answer his questions:)
Posted Image
+Friend Me | My Graphics | Forum Rules | Help Forum | Forum FAQ

#8
estro

estro

    Newbie

  • Members
  • Pip
  • 6 posts

Donovan said:

I am sure if he reads the site I linked him it will answer his questions:)
This response is laughable.

You didn't get me right. I'll try to explain myself another time. Lets say my Python program created a wx.Frame(window). Now the user selects some text outside of my program wx.Frame(window). How can I get my hand on that text?