Jump to content

Turn a blind eye to the window


yookee
 Share

Recommended Posts

I have a script, but it can't work properly.

; Script 1

WinActivate("Window A") ; Activate window A

Send("!C") ; Press Alt+C to unfold submenu of mainmenu on window A, like "File|Calculation|Help"

Send("L") ; Press L to select one menuitem(as Load(L)), then window B be shown

WinActivate("Window B") ; Oh, window B not be activated, current active window is explorer running this script

But if these is only one line in script, and window B is shown already, deactivated.

; Script 2

WinActivate("Window B") ; No problem,window B is activated

In help document of AutoIt, these is an example for WinList()

$var = WinList()

For $i = 1 to $var[0][0]

If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then

MsgBox(0, "Detail", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])

EndIf

Next

Func IsVisible($handle)

If BitAnd( WinGetState($handle), 2 ) Then

Return 1

Else

Return 0

EndIf

EndFunc

I add these codes to scripts for enumerating all window existed.

In second script, window B is listed out.

But in first script, window B is shown and not listed at all.

What and how does Send() enchant window B?

Edited by yookee
Link to comment
Share on other sites

Welcome to the forums!

It sounds like there's a slight delay between sending the keystrokes and the creation of "Window B".

You can try pausing the script for a few milliseconds with Sleep() or wait for the window to be created.

WinActivate("Window A") ; Activate window A
Send("!C") ; Press Alt+C to unfold submenu of mainmenu on window A, like "File|Calculation|Help"
Send("L") ; Press L to select one menuitem(as Load(L)), then window B be shown
WinWait("Window B") ; Wait for the window to be created
WinActivate("Window B")

Also, I suggest that you look into the WinMenuSelectItem function...

If the application uses standard menus, it will be much more reliable than Send and doesn't require Window A to be active or visible.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

:)

I see.

I find things being done more quickly is not better, we should relax for enjoyment.

In my case, many Send() be used, not only WinWait() and WinWaitActive() must be used, but also SendKeyDelay have to be adjusted.

Opt("SendKeyDelay", 50) work finely, but delay=20ms is out of control.

Link to comment
Share on other sites

  • 4 weeks later...

While 1
If Winexists(window B) then
Winactivate(window B)
exitloop
Else
Sleep(100)
endif
Wend

Just read all of above, that makes more sence,

I am trying to automate a process with a SAP frontend daabase.... A lot of point and click, and there are just lists of projects I get from fellow peers at work. As you can see I am running the same porcess for everything in excel column.

Anywayz I need am having trouble because the remote host where the app is running, has a heave traffic load which eats up processor time. I need to insert a if statment that identifies an error and the end user has to click a button to continue. I want the script to not stop and continue completeion of the list provided. Later I will get fance and add a logfile. I'll b workin it for now any advice will help. I am a Linux/Unix guy, but helping friends with a little VB.

Dim $ProjectNum

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

WinWait("Project Builder: Project EUSMB.MOC.000036","")

If Not WinActive("Project Builder: Project EUSMB.MOC.000036","") Then WinActivate("Project Builder: Project EUSMB.MOC.000036","")

WinWaitActive("Project Builder: Project EUSMB.MOC.000036","")

For $ProjectNum = 0000037 To 000574 Step 1

Send("{CTRLDOWN}{F2}{CTRLUP}")

Sleep(2500)

Send ("{ALT}!e")

Sleep(2500)

Send ("{DOWN}{DOWN}{DOWN}{RIGHT}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{RIGHT}{ENTER}")

Sleep(2500)

Send ("{ALT}!p")

Sleep(3000)

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

WinWait("Open Project","")

If Not WinActive("Open Project","") Then WinActivate("Open Project","")

WinWaitActive("Open Project","")

Sleep(3000)

Send("EUSMB.MOC.")

Send($ProjectNum)

Send("{ENTER}")

WinWait("Close the project and open another","")

If Not WinActive("Close the project and open another","") Then WinActivate("Close the project and open another","")

WinWaitActive("Close the project and open another","")

Send("{ENTER}")

Sleep(30000)

Next

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