Jump to content

How To Set A Variable In Winactivate?


Recommended Posts

Hi,

I'm new here, just discovered Autoit and it rocks!

I also have my first problem:

I want to activate a large number of successive windows: title = Figure 1, Figure 2, Figure 3 .... Figure N

in a do/untill or for/next loop.

eg:

$n = 0

Do

    $n = $n + 1

    WinActivate("Figure $n")

Until $n = 200

Only this doesn't work of course. How do I put a variable in the WinActivate title ?

Thanks alot

Link to comment
Share on other sites

This should work (without testing):

$n = 0
Do
   $n = $n + 1
   WinActivate("Figure " & $n, "")
Until $n = 200

Forgot the , "" on the WinActivate Function.

Edited by MrBeatnik

Please correct me if I am wrong in any of my posts. I like learning from my mistakes too.

Link to comment
Share on other sites

Wait for the window, then use WinActivate.

A For loop has a counter to suit use

For $n = 1 To 200
    WinWait("Figure No." & $n)
    WinActivate("Figure No." & $n)
    Sleep(1000)
Next
Edited by MHz
Link to comment
Share on other sites

Sorry :)

Tried it and it isn't working either

yeah, the reason your first attempt wasn't working was because you have to concatenate the variable in as in the samples given. I bet, just based on the number of windows with successive titles like that, you're probably trying to activate child windows. try this...

Opt("WinSearchChildren",1)
$n = 1
While WinExists("Figure No." & $n)
WinActivate("Figure No." & $n)
$n = $n + 1
WEnd
Link to comment
Share on other sites

This should work (without testing):

WinActivate("Figure " & $n, "")
I'm having trouble activating a window using only a variable.

Is there any reason that this shouldn't work?

WinActivate($var)

Thanks,

mike

Edited by blueschism
Link to comment
Share on other sites

I'm having trouble activating a window using only a variable.

Is there any reason that this shouldn't work?

WinActivate($var)

Thanks,

mike

It will work, if feed the correct string that the variable holds.

Sorry, but the info that you supply is at best, guessing to solve.

Link to comment
Share on other sites

It will work, if feed the correct string that the variable holds.

Sorry, but the info that you supply is at best, guessing to solve.

I'm pulling parts quantities out of an AS400 system and updating one of 2 user selected excel spreadsheets. The AS400 window and both excel spreadsheets are open in the background when attempting this. It's not correctly grabbing the spreadsheet. Here are the sections that apply.

Opt("WinTitleMatchMode", 2) 

; which excel doc?
$aLoop = 1
While $aLoop = 1
    $xlsin = InputBox("Get stock amounts", "Enter:" & @CRLF & @CRLF & "1 for TOP 100" & @CRLF & "2 for Manual", "", "")
    If @error = 1 Then
        Exit
    Else
        If $xlsin = 1 Then
            $spreadsheet = "Top"
            ExitLoop
        ElseIf $xlsin = 2 Then
            $spreadsheet = "manual"
            ExitLoop
        Else
            MsgBox(4096, "Error", "You typed in the wrong thing - try again!")
        EndIf
    EndIf
WEnd

; which line?
$bLoop = 1
While $bLoop = 1
    $ROW = InputBox("XLS Line to start on", "Enter Row number to start on", "2")
    If @error = 1 Then
        Exit
    ElseIf $ROW >= 2 Then
        $ROW = Int($ROW)
        ExitLoop
    EndIf  
WEnd

; start at excel field
WinActivate($spreadsheet)
Send("^{HOME}")
Send("{DOWN " & $ROW & "}")
Send("{UP}")

The 2 excel docs are called:

Top 100 Parts.xls

manual spreadsheet.xls

Any suggestions appreciated,

mike

Edited by blueschism
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...