Jump to content
Sign in to follow this  
Alterego

Controls

Recommended Posts

Alterego

I'm using the most recent version and trying to get either ControlClick, ControlFocus, ControlSend, or ControlSetText to work...I could make this go with any of them. I don't get any compile or run errors or anything, it just takes the focus off of both windows, so maybe I am interacting with a hidden element? The little piece of code in question is ControlSetText ( "", "C:\blah\blah.txt", "", $search ).

I've tried a zillion different variations of these commands, leaving blank quotes in every space or inputing various data given to me by the Spy. I figured if any of them would work it would be the one above since it is a very specific bit of text that the window is opening with, it should be easy to identify it and replace it. I also tried skipping my file search operation and just using the "test" instead of $search..I tried everything i can think of basically :idiot:

The full code looks like:

Dim $TomeRaider = "C:\Program Files\TomeRaider3\TomeRaider.exe"

Run( $TomeRaider, "C:\Program Files\TomeRaider3\", @SW_MAXIMIZE )

WinWait( "TomeRaider", "Categories" )
If not WinActive( "TomeRaider", "Categories" ) Then WinActivate( "TomeRaider", "Categories" )
WinWaitActive ( "TomeRaider", "Categories" )

Send( "{ALTDOWN}{ALTUP}{DOWN}{DOWN}{DOWN}{ENTER}" ) 

FileChangeDir ( "I:\blah\" ) 
$search = FileFindFirstFile ( "WP_" *  ".txt" )
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf
ControlSetText ( "", "Automatic", "Button2", $search )

The window I am working with is the TomeRaider 3 file > import menu (it's free to install and import stuff). It seems to be very sensitive, as a pixel more or less and you are in another control ID. Anyway, none of them seem to work! Here's the information its giving me. I've been working on this spot for 3 hours trying to find a way, which isn't so bad considering i'm a newb...i've learned a lot. If anyone could peek at this and give me a hint that would be great.

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: File Import

Class: #32770

Size: X: 153    Y: 29    W: 494    H: 488

>>>>>>>>>>> Mouse Position <<<<<<<<<<<

Screen: X: 194 Y: 112

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0xFFFFFF Dec: 16777215

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Control ID: 1057

ClassNameNN: Button2

Text:  Automatic

(Control is hidden)

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

Tab1

C:\blah

...

Source File

Progress1

Progress

--

Output

Open

Import

Cancel

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

Segmentation

Automatic

Fixed ( Value below )

1024

Log File

Produce Log File

...

Create In The Following Directory

Pictures

Skip Pictures

Save

Sorting

Automatically Sort Unsorted Files

Leave The Subject Order As It Is

Ask Me Before Sort

Or maybe it's

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: File Import

Class: #32770

Size: X: 153    Y: 29    W: 494    H: 488

>>>>>>>>>>> Mouse Position <<<<<<<<<<<

Screen: X: 189 Y: 112

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0x000000 Dec: 0

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Control ID: 1035

ClassNameNN: Edit3

Text: 

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

Tab1

C:\Blah

...

Source File

Progress1

Progress

--

Output

Open

Import

Cancel

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

Segmentation

Automatic

Fixed ( Value below )

1024

Log File

Produce Log File

...

Create In The Following Directory

Pictures

Skip Pictures

Save

Sorting

Automatically Sort Unsorted Files

Leave The Subject Order As It Is

Ask Me Before Sort

Share this post


Link to post
Share on other sites
this-is-me

ControlSetText("File Import", "", "Edit3", $search)


Who else would I be?

Share this post


Link to post
Share on other sites
Alterego

I've got it automagically compiling now! My next trick is to get it to recognize when it's done compiling. The ONLY difference is that the aforementioned control gets greyed out during processing, and is reactivated afterwards.. Is there any way to check for this? WinGetState doesn't seem to check for that, I don't think there is a way to make ControlEnable simply detect it. I guess what I'd be looking for is ControlWaitActive :idiot:

Share this post


Link to post
Share on other sites
Alterego

I got it! haha :idiot:

Do 
    Sleep (5000)
    $litmusLoop = ControlEnable("File Import","", "Edit3")
    Sleep (1000)
    ControlDisable("File Import","", "Edit3")
Until $litmusLoop = 0

Share this post


Link to post
Share on other sites
this-is-me

ControlCommand can also check if a control is enabled.


Who else would I be?

Share this post


Link to post
Share on other sites
Alterego

Thanks for that. I can't quite get it to do what i'm asking yet. What happens is that before compiling Button19's text is Import. After pushing Import, Button19's text is Stop. After it's done importing Button19's text is Compile. I'd like to detect when it turns from stop to compile and then close TomeRaider. Any advice on how to get this? I took a screenshot. Button19 is bottom middle :idiot:

Edited by Alterego

Share this post


Link to post
Share on other sites
MHz

You could try something like this

AdlibEnable('CheckControl', 250); Top of Script.

While 1
    Sleep(1000)
WEnd; Bottom of Script. To keep it alive.

Func CheckControl()
    $a = ControlGetText('TomeRaider', '', 'Button19')
    If $a = 'Stop' Then
        Do
            Sleep(1000)
            $a = ControlGetText('TomeRaider', '', 'Button19')
        Until $a = 'Compile'
    ; ControlClick exit button
        Exit
    EndIf
EndFunc; Check control change.
This would check for the button change of stop to compile. Not tested, but what I would try.

Share this post


Link to post
Share on other sites
Alterego

That's a really neat bit of code. I really like that Adlib function

This works as-is. Thanks!

edit: well i did change it a little it :idiot: turns out i didnt have to use that adlib function.

Func CheckControl()
If not WinActive( "File Import", "" ) Then WinActivate( "File Import", "" )
WinWaitActive( "File Import", "" )
    $a = ControlGetText('File Import', '', 'Button19')
    If $a = 'Stop' Then
        Do
            Sleep(1000)
            $a = ControlGetText('File Import', '', 'Button19')
        Until $a = 'Compile'
        ProcessClose ( "TomeRaider.exe" )       
    EndIf
EndFunc
Edited by Alterego

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  

×