Jump to content
Sign in to follow this  
Wolfshare

Wait untill object exist

Recommended Posts

Wolfshare

Hello everyone, i would like to know is that possible to make wait untill object will be active? I am talking not about win title, i am talking how to detect is that thing already active or not if there is no title on the software, or it has not been changing after some of actions.

It is very hard to explain, but i can show you example, there is VPN, after script connect to vpn, how they could kn ow that it's connected? if title has not changing after sucess connection?

I would use winwaitactive("title") but i cannot on my case.. Please help me with that :)

Share this post


Link to post
Share on other sites
jdelaney

Get the handle of the window (prior to connection), then use the handle to loop until the title changes (fails/succeeds to connect).

WinGetHandle...the handle of the window will never change, even when the title does

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Wolfshare

Is there any examples? i would like to learn from examples.

Share this post


Link to post
Share on other sites
Wolfshare

Why not?

Because in my example after sucess connection title has not changed..

I cannot set sleep(time) because sometimes it takes longer...

Share this post


Link to post
Share on other sites
Wolfshare

Yes, look at the help file under WinGetHandle as suggested. There are examples there.

Thanks, will look into it.

Share this post


Link to post
Share on other sites
Wolfshare

Hey just tried WinWait("[CLASS:HMA! Pro VPN 2.7.1.7]", "Sucessfuly connected to VPN", 50)

But unfortunaly not sucess.. I dont know how to make script wait untill text "Sucessfuly connected to VPN" exist.. tried to change class, which i got from Autoit info.. but still not working.

Share this post


Link to post
Share on other sites
Wolfshare

Just tried, does not work.. You can see, i need to make it wait untill this exist..

post-59586-0-09788500-1362682643_thumb.p

Share this post


Link to post
Share on other sites
jdelaney

Put the window info tool crosair over the static, copy all of the data from the 'Summary' tab, and paste back to the forum. If you get the handle of the window, and the handle of the static, you can probably use a loop of controlgettext until the data changes to what you need.

try this...let us know if you can get the text of the control

$hwnd = WinGetHandle("HMA! Pro")
If Not IsHWnd($hwnd) Then
 MsgBox(1,1,"not able to find the window" )
 Exit
EndIf
$hControl = ControlGetHandle ($hwnd, "", "[REGEXPCLASS:STATIC; INSTANCE:15]" )
If Not IsHWnd($hControl) Then
 MsgBox(1,1,"not able to find the control" )
 Exit
EndIf
MsgBox(1,1,ControlGetText($hwnd, "",$hControl ))
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Wolfshare

I want to make it wait untill text exist, i mean sleep untill win exist, tried your script, but it's only showwing msg.

Share this post


Link to post
Share on other sites
Wolfshare

Now my code is:

Opt("WinTitleMatchMode", 2)
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <FF.au3>
global $clr
global $file
global $times
global $clr2
global $x
Local $x ;
$i = 0
$x = 0
$r = 0
$t = 0
While $i <= 10
Do
if not ProcessExists("HMA! Pro VPN.exe") Then
run("C:\Program Files\HMA! Pro VPN\bin\HMA! Pro VPN.exe")
endif
Until $x = 1


WEnd

then just want to wait it untill Sucessfuly connected to VPN exist.

Share this post


Link to post
Share on other sites
jdelaney

I wanted to make sure you are getting the control, first.

Then you can loop through until the text is as expected:

$timer = TimerInit()
$bFoundText = False
While TimerDiff($timer) < 20000
 If ControlGetText($hwnd, "",$hControl ) = "Succesfully connected to VPN" Then
  $bFoundText = True
  ExitLoop
 EndIf
WEnd
If $bFoundText Then
 MsgBox(1,1,"VPN connected within 20 seconds" )
Else
 MsgBox(1,1,"VPN NOT connected within 20 seconds" ) 
EndIf

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Wolfshare

Sorry folks, it's hard to understand, i was tired then, so now i really want to learn that, i have writed my script on other software, but now want to re-make it on this one :) but still cannot make that function work propertly, i would pay for help, if anyone could teach me how to make wait untill text exist on any software then continue work.. :)

Share this post


Link to post
Share on other sites
Wolfshare

sent via pm.

Share this post


Link to post
Share on other sites
Nessie

sent via pm.

Why not on the forum? So other people can help you? :P

Hi!


My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Share this post


Link to post
Share on other sites
JohnOne

Perhaps wires are crossed, I thought you meant you had written code in another language.

What you sent is just Autoit code which appears to wait until a window exists.

Also for future reference "post" means show in thread, not PM.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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  

×