Sign in to follow this  
Followers 0
stefilina

How can i close a web page

3 posts in this topic

Hy.I'm new in AutoIt and i want to close a web page.

Opt("WinTitleMatchMode",2);

Opt("MouseCoordMode",0);

Run("page path","",@SW_MAXIMIZE);

WinWaitActive("title of page");

...

sleep(500)

If WinWaitActive("a javascript dialog box") then

sleep(1000);

send("{ENTER}");

sleep(500);

;send("{TAB}");

;send("{ENTER}");

send("!+r")

sleep(1000)

send ("!{F4}");//here i close if the condition is true

else

sleep(5000)

;send("!{F4}");//but it doesn't work..and i really don't know why..:x

EndIf

I've tried to send alt+f4 even after endif but it still doesn't work...Please help me

Share this post


Link to post
Share on other sites



Opt("WinTitleMatchMode",2);
Opt("MouseCoordMode",0);
Run("page path","",@SW_MAXIMIZE);
WinWaitActive("title of page");

sleep(500)
If WinWaitActive("a javascript dialog box") then
    sleep(1000); AutoIt is not like C++ and other languages that require you to end lines with an ; so this character is used as a commenting character.
    send("{ENTER}")
    sleep(500)
    send("{TAB}")
    send("{ENTER}")
    send("!+r")     ;You are sending Alt + Shift + r
    sleep(1000)
    send ("!{F4}")      ;here i close if the condition is true
else
    sleep(5000)
    send("!{F4}")       ;but it doesn't work..and i really don't know why..:(
EndIf

There are a few things I can see wrong with this even though I do not entirely understand what you are doing.

A comment in AutoIt is ;

Therefore, you can not end a line with that character. In autoit, you do not end a line as you would in C++.

I think that should work for you.


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

If WinWaitActive("a javascript dialog box") then

This makes no sense. By using WinWaitActive you tell your script to wait until a window is active and then it returns the handle (a whole number) to that window. I think your intention was:

If - script has waited until the window active - then - 
do this

But in reality this happens

If - a number (gets returned from waiting for the window) - then -
do this

So what should, If - a number - then, do?

Anyway, my guess is that the javascript window is not automatically activated (because it is a child window of the main window or something like that). Try using WinWait to wait for the window to exist.

Edited by Manadar

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