Jump to content

How to set focus to a window which I don't know the type in advance


Recommended Posts

Hi all,

I plan to do the following.

1) I want to select some text from an application, this application could be MS word, could be firefox, could be IE, or others.

2) I want to send "Ctrl+C" so the selected text will be sent to clipboard.

I tried the following.

I wrote a code and the send command to send "Ctrl+C". Then I compiled it to an executable. Then I create an shortcut for this executable and put it on the quick launch. Then I select the text in WORD/Firefox/IE/etc, then I click the icon in the quick launch.

I checked the clipboard, I found the CTRL+C does not catch whatever I select. It appears when I click the icon in the quick launch, I immediately lost the focus of the application which has the text selected.

My question is how can I accomplish the task? I don't know in advance what this application is. So I can not use winactive to focus to this application and then send CTRL+C.

My friend told me that in older version AutoIt, there is an applications called copyselect.exe can do the job. But the current version Autoit seems does not have this tools.

I really appreciate your help.

Link to comment
Share on other sites

Why do you need to copy it? You could use a function to do this. Show some code and explain a bit better why you need this done and maybe we can help more.

Link to comment
Share on other sites

Why do you need to copy it? You could use a function to do this. Show some code and explain a bit better why you need this done and maybe we can help more.

What I want to do is to select some text, copy it to clipboard, then use an external program called winclip to convert the code to UTF8 code (winclip can convert the content of clipboard to UTF8 code). I don't want to press CTRL+C. I want the code to do it.

So I plan to compile my code to EXE, then create a shortcut in quick lunch. I will select some text, may be from IE/Firefox/MS word,etc. Then press the shortcut in quick launch. The code should copy the selected text to clipboard, then winclip will convert the content in clipboard into UTF8 code, then I will do further work.

My code is very simple, as below.

send ("^c")

RunWait("\winclip.exe" & " -p -m " & $utf8_in, '', @SW_HIDE )

The problem is send ("^c") can not catch the text I selected.

If you have other solutions, please let me know. Thanks.

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