Jump to content

Problem with ControlCommand()- and an Edit box


 Share

Recommended Posts

I'm using ControlCommand to get the Highlighted text from an Edit box, that appears when a windows (Common Dialogue) File Browser is displayed.

My Call looks like this

>>ControlCommand ( Bank File, "File &name:", "Edit1", "GetSelected", "" )

Correction

my call really looks like this

$WindowTitle="Bank File"

ControlCommand ( $WindowTitle, "File &name:", "Edit1", "GetSelected", "" )

and an example of the Highlighted text in the edit box is "PerfBank1"

however, when I display the return value from ControCommand in a MSgBox, only a 1 is displayed.

What am I doing wrong? IS there a better way yo get the highlighted text in the edit box?

ControlGetText() only returns an empty string :P

Edited by cappy2112
Link to comment
Share on other sites

  • Moderators

For browser automation, take a look at Dales IE.au3. You can find it here: http://www.autoitscript.com/forum/index.php?showtopic=13398

Hope that helps a bit... Good Luck.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I'm using ControlCommand to get the Highlighted text from an Edit box, that appears when a windows (Common Dialogue) File Browser is displayed.

My Call looks like this

ControlCommand ( Bank File, "File &name:", "Edit1", "GetSelected", "" )

and an example of the Highlighted text in the edit box is "PerfBank1"

however, when I display the return value from ControCommand in a MSgBox, only a 1 is displayed.

What am I doing wrong? IS there a better way yo get the highlighted text in the edit box?

ControlGetText() only returns an empty string :P

first, i'd put "Bank File" in quotes, if that doesn't work you could try:

ControlSend("Bank File","","Edit1","^c")
$yourvaule = ClipGet()
Link to comment
Share on other sites

first, i'd put "Bank File" in quotes, if that doesn't work you could try:

ControlSend("Bank File","","Edit1","^c")
$yourvaule = ClipGet()

Looks like a good idea. I'll try it.

But I'd like to know why my ControlCommand() call doesn't work. I"m new to AutoIt, and there are a lot of API's to learn.

The tutorials are woefully inadequit, and the helpfile is very misleading.

Link to comment
Share on other sites

The tutorials are woefully inadequit, and the helpfile is very misleading.

Feel free to write your own tutorials after you use AutoIt for a while... for now, compare the "production" version of the help file with the beta one on any function and offer suggested changes.

Are you sure that your "(Common Dialogue) File Browser" uses "standard Microsoft controls" or are you just experimenting in the hopes that they will work?

From the help file under the topic "Controls":

Note: AutoIt only works with standard Microsoft controls - some applications write their own custom controls which may look like a standard MS control but may resist automation. Experiment!

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

I didn't say anything about internet explorer.

you'll have to forgive smoke, i think he must've had too much fun last night based on his posts this morning... but he really knows his stuff, i swear.

Looks like a good idea. I'll try it.

But I'd like to know why my ControlCommand() call doesn't work. I"m new to AutoIt, and there are a lot of API's to learn.

The tutorials are woefully inadequit, and the helpfile is very misleading.

there are a few small projects in the works to offer additional learning materials, but the helpfile really is awesome on it's own if you already know what you're trying to do. as far as why control command isn't working, the MOST likely cause is that you don't have quotes around the win title, after that, i'd go with plato on the possibility that they're not MS controls.
Link to comment
Share on other sites

  • Moderators

i think he must've had too much fun last night

Man only 3 - 22oz'ers :P ... I saw the word browser and missed the word 'file'.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

lol@lightweight, well I really slowed down my drinking to once every 3 or 4 months now, from an 18 pack a night after work. So yeh, a $15 a night ritual, to a $6 take me home and take advantage of me date (god, they were never that cheap!!) ... not too bad :P

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

lol@lightweight, well I really slowed down my drinking to once every 3 or 4 months now, from an 18 pack a night after work. So yeh, a $15 a night ritual, to a $6 take me home and take advantage of me date (god, they were never that cheap!!) ... not too bad :lmao:

way to put a silver lining on getting old! :P
Link to comment
Share on other sites

Are you sure that your "(Common Dialogue) File Browser" uses "standard Microsoft controls" or are you just experimenting in the hopes that they will work?

From the help file under the topic "Controls":

I have no idea if they are standard or not. It's not like applications come with this sort of information.

I don't know if I'm doing something wrong, or if the controls are not standard.

Link to comment
Share on other sites

you'll have to forgive smoke, i think he must've had too much fun last night based on his posts this morning... but he really knows his stuff, i swear.

there are a few small projects in the works to offer additional learning materials, but the helpfile really is awesome on it's own if you already know what you're trying to do. as far as why control command isn't working, the MOST likely cause is that you don't have quotes around the win title, after that, i'd go with plato on the possibility that they're not MS controls.

In the example I posted, I accidentally put the window title Bank FIle, instead of the variable I used for

the Window title. What I posted is not the way my code looked when I posted the question :-)

I was up until 2AM working on this :-)

Edited by cappy2112
Link to comment
Share on other sites

These both work for me:

Local $AllText = ControlGetText('Open', '', 'Edit1')
Local $SelText = ControlCommand('Open', '', 'Edit1', 'GetSelected')

MsgBox(0, '', $AllText & @LF & $SelText)
Link to comment
Share on other sites

first, i'd put "Bank File" in quotes, if that doesn't work you could try:

ControlSend("Bank File","","Edit1","^c")
$yourvaule = ClipGet()
I think I had a race condition going on.

I added a WinWiatActive() just before the SendCommand(), and now it works

If Not WinActive($WindowTitleText,"") Then WinActivate($WindowTitleText,"")

WinWaitActive($WindowTitleText,"")

$SelectedPatchBankName = ControlCommand ( $WindowTitleText, '', 'Edit1', 'GetSelected' )

Your ClipGet() solution now also works. Before the WinWaitActive(), nothing worked.

These are the kinds of things that drive me crazy- not knowing if I'm doing something wrong, not knowing if the problem is becuase the conrols are not Standard, or not knowing if I'm doing the right thing, but need a delay.

Link to comment
Share on other sites

These are the kinds of things that drive me crazy- not knowing if I'm doing something wrong, not knowing if the problem is becuase the conrols are not Standard, or not knowing if I'm doing the right thing, but need a delay.

The safest approach is to always assume that some form of delay is needed and use WinWait() etc.; this type of problem is then prevented. In my opinion it's also a good idea to assume that focus may not automatically be passed to a newly-created window, which is why I never use WinWaitActive() unless it immediately follows a WinActivate().

Programming in this way gives the advantage that you can set the WinWaitDelay to 0 and therefore increase the execution speed of your scripts.

Also, this code:

If Not WinActive($WindowTitleText,"") Then WinActivate($WindowTitleText,"")

can be simplified to:

WinActivate($WindowTitleText)

since there is no harm in calling WinActivate() on an already-activated window.

Link to comment
Share on other sites

Well I feel dumb - not asking "what code comes before".

Silly me - I assumed that you were testing with a small test script like:

manually bring up the window of interest

run your one line of code and one msgbox........

glad that you got it workin'

[size="1"][font="Arial"].[u].[/u][/font][/size]

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