Sign in to follow this  
Followers 0
simonwar

Selecting from a drop down list ....

5 posts in this topic

Hi,

I am trying to open a file by entering part of its name into its Open box and then attempting to record using the MacroRecorder the action of selecting the entry in the pull-down.

I am ok with getting only one file in the pull-down to chose from, but I keep getting an error, as i cannot seem to get the file in the pull-down to select, with mouse or a keystroke and appear in the open-file entry box and therefore open on enter?

Any ideas ?

Share this post


Link to post
Share on other sites



If you know the path and file name - then look at ShellExecute()

If not, post the code that you have and maybe someone can see the problem.

-MSP-


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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

No I don't know the PATH or full FILENAME.

I set the software up so that OPEN is at the right PATH, and the FILENAME is established by entering into the 'select file form window' in the OPEN window part of the FILENAME enought to see it appear in a pull-down box - default to XP.

The code follows:

Its created using the macro recorder. My PC is set up ready with the application 'Catalog- eSafety Signs', open at the right place.

The full code is below but if you look at:

If Not WinActive("Select...","") Then WinActivate("Select...","")

WinWaitActive("Select...","")

Send("{CTRLDOWN}v{CTRLUP}-")

MouseMove(314,11)

MouseDown("left")

This is where the scipt fails to select an item in a pull-down box, after I 'Ctrl-V' PASTE and using a hyphen '-' input enough letters of the filename required for it to appear as the only option in the pull-down.

Its the Mouse Down("left") that fails to work, there's seems to be a slight delay before the pull-down appears and the mouse has already moved and clicked down before its had a chance to realise itself.

A way of waiting until pull-down results had finished would work... perhaps ?

See what you think, code below. Thanks, Simon.

CODE
#region --- ScriptWriter generated code Start ---

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

WinWait("Catalog - eSafety Signs","")

If Not WinActive("Catalog - eSafety Signs","") Then WinActivate("Catalog - eSafety Signs","")

WinWaitActive("Catalog - eSafety Signs","")

MouseMove(953,144)

MouseDown("left")

MouseUp("left")

MouseMove(920,246)

MouseDown("left")

MouseUp("left")

Send("{HOME}{SHIFTDOWN}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{SHIFTUP}{CTRLDOWN}c{CTRLUP}")

MouseMove(349,155)

MouseDown("left")

MouseUp("left")

Send("{DOWN}")

MouseMove(1060,187)

MouseDown("left")

MouseUp("left")

MouseMove(815,221)

MouseDown("left")

MouseUp("left")

MouseMove(1170,222)

MouseDown("left")

MouseUp("left")

WinWait("Select...","")

If Not WinActive("Select...","") Then WinActivate("Select...","")

WinWaitActive("Select...","")

Send("{CTRLDOWN}v{CTRLUP}-")

MouseMove(314,11)

MouseDown("left")

MouseUp("left")

Send("{BACKSPACE}-")

MouseMove(311,383)

MouseDown("left")

MouseUp("left")

Send("{ENTER}")

WinWait("Catalog - eSafety Signs","")

If Not WinActive("Catalog - eSafety Signs","") Then WinActivate("Catalog - eSafety Signs","")

WinWaitActive("Catalog - eSafety Signs","")

MouseMove(680,243)

MouseDown("left")

MouseUp("left")

MouseMove(322,148)

MouseDown("left")

MouseUp("left")

Send("{DOWN}")

MouseMove(982,150)

MouseDown("left")

MouseUp("left")

MouseMove(924,216)

MouseDown("left")

MouseUp("left")

MouseMove(1180,227)

MouseDown("left")

MouseUp("left")

WinWait("Select...","")

If Not WinActive("Select...","") Then WinActivate("Select...","")

WinWaitActive("Select...","")

Send("{CTRLDOWN}v{CTRLUP}{SHIFTDOWN}l{SHIFTUP}2x1")

MouseMove(292,386)

MouseDown("left")

MouseUp("left")

Send("{ENTER}")

WinWait("Catalog - eSafety Signs","")

If Not WinActive("Catalog - eSafety Signs","") Then WinActivate("Catalog - eSafety Signs","")

WinWaitActive("Catalog - eSafety Signs","")

MouseMove(675,241)

MouseDown("left")

MouseUp("left")

MouseMove(803,696)

MouseDown("left")

MouseUp("left")

MouseMove(266,147)

MouseDown("left")

MouseUp("left")

#endregion --- ScriptWriter generated code End ---

Edited by simonwar

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I hope that some member can help you more than I can on this. I'm not sure what would be best for what you are doing.

You might want to replace this:

Send("{HOME}{SHIFTDOWN}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{SHIFTUP}{CTRLDOWN}c{CTRLUP}")

with this:

Send("{HOME}+{END}^c")

...or better yet, look into ControlGetText()

This:

WinWaitActive("Select...","")

Send("{CTRLDOWN}v{CTRLUP}-")

MouseMove(314,11)

MouseDown("left")

MouseUp("left")

could become:

WinWaitActive("Select...","")

Send("^v-")

Sleep(2000)

MouseClick("left", 314, 11)

Using a hard coded Sleep time is not the best answer, but it might work for you.

Edited by herewasplato

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

Share this post


Link to post
Share on other sites

Nice one!

The pause using Sleep works a treat.

What I actually had to do was use Sleep twice as follows

Send("{CTRLDOWN}v{CTRLUP}-")

Sleep (2000)

MouseMove(314,11)

MouseDown("left")

MouseUp("left")

Sleep (1000)

It seems XP Windows has take think a second to realise the file in the pop-up window..... give it a second though and it finds the file no probs!.

Thanks, Simon.

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