Sign in to follow this  
Followers 0
cappy2112

Problem with ControlCommand()- and an Edit box

17 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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.


[center]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.[/center]

Share this post


Link to post
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()

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
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.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
Share on other sites

Man only 3 - 22oz'ers :P

you're a cheap date / lightweight eh?

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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 :P


[center]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.[/center]

Share this post


Link to post
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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

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

Share this post


Link to post
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)

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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]

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