Jump to content

Font and Copy Question


 Share

Recommended Posts

Hello

I will start off with my simple question first, I need to somehow copy text automatically when text is selected by the user.

This second part might be a bit harder more or less I want it to be like charmap.exe you select the font you want and it displays it although I want it to display all the font on to buttons but if someone can post code of extracting each character out of certain font types I might be able to handle the rest of the script.

Thanks

Link to comment
Share on other sites

I will start off with my simple question first, I need to somehow copy text automatically when text is selected by the user.

Are you wanting to copy just any text copied in a particular window, or is it in a gui that you're creating?

This second part might be a bit harder more or less I want it to be like charmap.exe you select the font you want and it displays it although I want it to display all the font on to buttons but if someone can post code of extracting each character out of certain font types I might be able to handle the rest of the script.

It sounds like you are creating a gui, (at least I'd expect you are given what you're talking about), so I guess you would want to get the list of supported fonts from the Help File, list them in a combobox and then do a guictrlsetfont for every control you want it to change for, when the user selects a particular font.

Link to comment
Share on other sites

Are you wanting to copy just any text copied in a particular window, or is it in a gui that you're creating?

It sounds like you are creating a gui, (at least I'd expect you are given what you're talking about), so I guess you would want to get the list of supported fonts from the Help File, list them in a combobox and then do a guictrlsetfont for every control you want it to change for, when the user selects a particular font.

Exactly :)

Link to comment
Share on other sites

I don't know were to start with either one of them :)

Well for the first one, I'd look at the functions While...Wend and ClipGet in the Help File.

For the second one, I'd look into GuiCreate and then start playing with all of the GuiCtrlCreate functions, along with GuiCtrlSetFont (to change your fonts of course).

And report back when you have examples to be helped with! :)

Link to comment
Share on other sites

Well for the first one, I'd look at the functions While...Wend and ClipGet in the Help File.

For the second one, I'd look into GuiCreate and then start playing with all of the GuiCtrlCreate functions, along with GuiCtrlSetFont (to change your fonts of course).

And report back when you have examples to be helped with! :)

I know a bit about Autoit, since I have been using it for months and all I want to really know is these two questions can you help me or not please!

How can I know if text is highlighted in my GUI?

The other question is not as simple as setting the fonts on buttons because I want to know what fonts are installed on their computer and pull all of the fonts and make it label the buttons it's self instead of me having to code 200 fonts on buttons.

Link to comment
Share on other sites

I know a bit about Autoit, since I have been using it for months and all I want to really know is these two questions can you help me or not please!

How can I know if text is highlighted in my GUI?

The other question is not as simple as setting the fonts on buttons because I want to know what fonts are installed on their computer and pull all of the fonts and make it label the buttons it's self instead of me having to code 200 fonts on buttons.

See this is where an example helps, because if you give me an example of what you're trying to do then I can tell that you already know the basics of what you're talking about.

Here's an example of how you can do the first part, but I don't know if it fixes what you want because you're refusing to give me anything to work with.

#include <GUIConstants.au3>
Opt ("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 306, 176, 193, 125)
GUISetOnEvent ($GUI_EVENT_CLOSE, "_GUI_EVENT_CLOSE")
GUISetOnEvent ($GUI_EVENT_PRIMARYUP, "_GUI_EVENT_PRIMARYUP")

$Input1 = GUICtrlCreateInput("Input1", 80, 56, 121, 21)
$Input2 = GUICtrlCreateInput("Input2", 80, 86, 121, 21)
GUISetState(@SW_SHOW)

While 1
    Sleep (100)
WEnd

Func _GUI_EVENT_PRIMARYUP()
    If _IsFocused($Form1, $Input1) Then
        ControlSend ($Form1, "", "", "^c")
    EndIf
EndFunc

Func _GUI_EVENT_CLOSE()
    Exit
EndFunc

Func _IsFocused($hWnd, $nCID)
    Return ControlGetHandle($hWnd, '', $nCID) = ControlGetHandle($hWnd, '', ControlGetFocus($hWnd))
EndFunc   ;==>_IsFocused

If your aim on the font thing is to change the font of your GUI to one of their choosing, you'll want to note from the GuiCtrlSetFont Help page:

See the Appendix for a complete list of Windows fonts and the Windows versions under which they are supported.

There's only 65 fonts listed in the appendix to use in the first place, and I guess as far as that goes, I'd use a combobox to list them out and let them choose them that way.
Link to comment
Share on other sites

I know a bit about Autoit, since I have been using it for months and all I want to really know is these two questions can you help me or not please!

How can I know if text is highlighted in my GUI?

The other question is not as simple as setting the fonts on buttons because I want to know what fonts are installed on their computer and pull all of the fonts and make it label the buttons it's self instead of me having to code 200 fonts on buttons.

exodius is right, a sample of your code would help us help you. This might help, provided you're using an editbox in your GUI:

$aSel = _GUICtrlEdit_GetSel($yourGUI)
If $aSel[0] = $aSel[1] Then (Nothing is selected)

Hope this helps.

Link to comment
Share on other sites

exodius is right, a sample of your code would help us help you. This might help, provided you're using an editbox in your GUI:

$aSel = _GUICtrlEdit_GetSel($yourGUI)
If $aSel[0] = $aSel[1] Then (Nothing is selected)

Hope this helps.

I am sorry to you and Exodius and thanks for trying to put up with me after reading my own posts I did leave out information but I got the flu and got a nasty fever along with other stuff so I am not thinking straight.

Envoi your right it is a edit control I am trying to get the selected text, I see this function gets me the start and finish of the selected text but how would I actually put that to text instead of the numbers.

The second question I had is... Autoit will find every font installed put it in a combo box and when the user selects the font, Autoit will take every number and letter from that font and place it on to buttons just like charmap.exe

Charmap can find all fonts and display them all automatically thats what I want.

Link to comment
Share on other sites

Envoi your right it is a edit control I am trying to get the selected text, I see this function gets me the start and finish of the selected text but how would I actually put that to text instead of the numbers.

That was just to help you with this question:

How can I know if text is highlighted in my GUI?

If those two numbers are equal, then nothing is selected. If you now need to extract the selected text, you could send the control a ^c to copy it. Then use the _ClipBoard_GetDataEx. But I think that's messy. I'd rather not use a Send() or ControlSend().

I'd do something like:

$editBoxString = _GUICtrlEdit_GetText($yourEditBox)
$aSel = _GUICtrlEdit_GetSel($yourEditBox)
$selectedString = StringMid($editBoxString, $aSel[0], ($aSel[1]-$aSel[0]))

But, heck, you might consider that messy. :)

Does that help?

Link to comment
Share on other sites

Envoi your right it is a edit control I am trying to get the selected text, I see this function gets me the start and finish of the selected text but how would I actually put that to text instead of the numbers.

The second question I had is... Autoit will find every font installed put it in a combo box and when the user selects the font, Autoit will take every number and letter from that font and place it on to buttons just like charmap.exe

Charmap can find all fonts and display them all automatically thats what I want.

In regards to your first issue:

Try to insert the line Envoi gave you and then post your code, there's very little more we can do for you in this extremely-abstract way of discussing what you want. We sort of have a grasp on what you want to do, but have no idea how you're implementing it so... No more questions until you show us some code please.

In regards to your second issue:

The unfortunate truth is AutoIt is not C# or some other .Net programming language that's made by Microsoft. As such it has limitations in some ways that, while not impossible to get around, are going to be more advanced than the standard "in the helpfile" functionset is going to provide for.

So pretty much, I'd search the forum for a way to have the AutoIt gui recognize more fonts, but I don't know that you're going to find it. The same goes for recreating the behavior of charmap.exe.

Finally:

I'm not trying to be mean, and I appreciate that you've been sick, but you have to do your part in this, no one has an obligation to help you - they do it because they're willing to help you try to figure something out... But you have to help them help you.

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