Jump to content

WinExists doesn't work


Recommended Posts

Hello,

I'm trying to use WinExists on a web page but it doesn't work. I don't think the code is wrong because it works with other pages.

Is it possible that the web sites in blocking WinExists?

If yes do you have any idea to know if a world is present on the web page?

Have a nice confinement ^^

Fluflu

Link to comment
Share on other sites

Hi @FrancescoDiMuro, thanks for replying me!

it's a private portal.

Here is my code but again it works on other sites. The global aim of the code is to get notified when a word of the page is removed. I can't use any function that require the URL because i have to connect to the portal.

Spoiler

HotKeySet("!{x}", "_Exit")                       
Opt("WinTitleMatchMode", 3)                     ; This is to tell the script to only refresh the EXACT window, incase there are similar windows.
While 1 ;
Sleep(2000)                                   
  $title = WinGetTitle("Chrome", "")           
If WinExists($title) Then
  WinActivate($title)                          
  WinWaitActive($title)                       
  Send("{F5}")
  $BOOLtrouve = WinExists($title,"Présence")
  If ($BOOLtrouve="0") Then
      MsgBox(0,"","The word has desapeared!")
  EndIf

Else                                             ; This is an else statement to tell the script to do a different operation if the window is not running.
  Sleep(10)                                     ; Just a filler item to wait until the desired window is running.
EndIf                                             ; End the If statement to continue the script.
WEnd                                             ; Close the While LOOP
Func _Exit()                                     ; This is the function that is linked to the kill switch, ALT+X. It tells the script to perform the following actions.
Exit                                             ; In this case it is to close the entire program.
EndFunc                                         ; Close the function up.

 

 

Link to comment
Share on other sites

Yes i can but it's gone be the same,isn't it?

I've tried the search part of my code without the refresh part and it works!

Spoiler

#include <StringConstants.au3>
#include <MsgBoxConstants.au3>


$title = WinGetTitle("Firefox", "")

If WinExists($title) Then
  WinActivate($title)                          
  WinWaitActive($title)                       
  $texte = WinGetText($title)
  MsgBox(0,"",$texte)
  $BOOLtrouve = WinExists($title,"Vous")
  If ($BOOLtrouve="1") Then
      MsgBox(0,"","Appel!")
  Else
      MsgBox(0,"","pas troivé")
  EndIf
EndIf

This is pretty weird.

 

Link to comment
Share on other sites

1 minute ago, fluflu said:

Yes i can but it's gone be the same,isn't it?

Not really.
With IE UDF you could do something like this:

#include <IE.au3>

Global $objIE

$objIE = _IECreate("https://www.autoitscript.com/autoit3/docs/libfunctions/_IEPropertyGet.htm", 0, 1)

ConsoleWrite("Title of the tab: " & _IEPropertyGet($objIE, "title") & @CRLF)
ConsoleWrite("Title of the Window: " & WinGetTitle(_IEPropertyGet($objIE, "hwnd")) & @CRLF)

_IEQuit($objIE)

:)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

You right click on the word you are looking for, on the pop up menu, click Inspect.  That is the DOM, copy it and paste it here.  If you cannot use IE, you will have to use WebDriver

Link to comment
Share on other sites

<div class="alert alert-success">
                                Vous avez été noté présent le 17/04/2020 à 14h48                            </div>

 

@Nine Is it that?

Ok i will try with webdriver

Link to comment
Share on other sites

Exactement fluflu.  You can read all tags with div and search for innertext that contains the word "Présent".  There is a learning curve to get accustomed to the UDF, but it is worth the effort, as you will have much more control over your browser.  Bonne chance.

Link to comment
Share on other sites

ok guys @Nine @FrancescoDiMuro I finally suceed it!!

All my problems only came from one line : Opt("WinTitleMatchMode", 3)

I read that it is to tell the script to only refresh the EXACT window, incase there are similar windows so this is why i have put it in my script.

Is it really for that? And if yes do u know what happened?

 

Thanks a lot for taking the time to help me!

have a great day guys

Link to comment
Share on other sites

Opt("WinTitleMatchMode", 3) means that the title of the windows must be exactly the same as what you have provided in the function.  It is also case-sensitive.  So either there were additional characters in the window title or it was not spelled correctly (case wise).  In other words, there was a mismatch between the string and the real window title.  

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