barkeeper Posted March 1, 2010 Share Posted March 1, 2010 (edited) hi there, I have a question to you guys, not sure if it's even possible, but want to ask anyway. Is there an option in AutoIt to check for a javascript dialog popup and when it appears auto-click the OK button? We use a piece of online software at work that checks if you're still using it every 30 minutes, you click OK to make the dialog disapear and still be logged in, if you don't click within 10 minutes you get logged out. I'd like the script to auto check for a webpage javascript dialog, and click OK when it appears. I'll include a screenshot to make things easier for you. Thank you for looking into this and helping me, I appreciate it a lot! JJ - The Netherlands Edited March 1, 2010 by barkeeper Link to comment Share on other sites More sharing options...
JohnOne Posted March 1, 2010 Share Posted March 1, 2010 well you could check for it via a pixelchecksum() every nine minutes, and if its there then click it. read PixelChecksum() Sleep() MouseClick() in the helpfile. Unfortunately thats the only way I know. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
barkeeper Posted March 1, 2010 Author Share Posted March 1, 2010 Thanks! Could you give me a snippet of how that code would look like maybe ?JJwell you could check for it via a pixelchecksum() every nine minutes, and if its there then click it.readPixelChecksum()Sleep()MouseClick()in the helpfile.Unfortunately thats the only way I know. Link to comment Share on other sites More sharing options...
JohnOne Posted March 1, 2010 Share Posted March 1, 2010 (edited) Something like this, you will need to read the helpfile with regards the functions. And you will need to use au3windowinfotoll to get some info. $pChecksum = ;whatever the checksum of the popup is While 1 Sleep(540000) $pCheck = PixelChecksum() ;coordinates in here If $pCheck = $pChecksum Then MouseClick() ;coordinates in here EndIf WEnd Edited March 1, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 1, 2010 Share Posted March 1, 2010 I would use WinGetPos since it looks like that popup is a set size. You can look for a window of that size in a loop then controlclick the ok. $window=WinGetPos("Message from webpage") While 1 $window=WinGetPos("Message from webpage") If $window[2]="enter the window width here" And $window[3]="enter the height here" Then ControlClick("Message from webpage","","control ID of the OK button here","Left",1);use the windowinfo tool from autoit EndIf Sleep(10) WEnd this little 2 line snipit will give you the width and height, but only run it when the window you want the size of is open $window=WinGetPos("Message from webpage") MsgBox(0,"Size of window","Size: Width: "&$window[2]&" Height: "&$window[3]) 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
JohnOne Posted March 1, 2010 Share Posted March 1, 2010 Yes that would probably be better. I was under the impression javascript did not show up as a window, rather an object on the webpage. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
barkeeper Posted March 1, 2010 Author Share Posted March 1, 2010 You guys Rock, I'm going to try that right away, will let you know the outcome. Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 1, 2010 Share Posted March 1, 2010 Yes that would probably be better. I was under the impression javascript did not show up as a window, rather an object on the webpage. I just tested it on our clock in page which uses a popup with the same window name and it worked fine. Not to say it will for this as I can't test it on that window. this is the exact code that worked for me (the window I'm sure is going to be a different size though) $window=WinGetPos("Message from webpage") While 1 $window=WinGetPos("Message from webpage") If IsArray($window) Then If $window[2]=185 And $window[3]=126 Then ControlClick("Message from webpage","","[CLASS:Button; INSTANCE:1]","Left",1);use the windowinfo tool from autoit EndIf EndIf Sleep(10) WEnd 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
barkeeper Posted March 1, 2010 Author Share Posted March 1, 2010 My test is going to take a little time since I need to let the application get idle, if I get a support call in the meantime the timeout counter is reset As soon as I know more, I'll post it here. JJ Link to comment Share on other sites More sharing options...
barkeeper Posted March 1, 2010 Author Share Posted March 1, 2010 (edited) It worked Thank you guys sooo much, the working code for me was : $window=WinGetPos("Message from webpage") While 1 $window=WinGetPos("Message from webpage") If IsArray($window) Then If $window[2]=377 And $window[3]=204 Then ControlClick("Message from webpage","","[CLASS:Button; INSTANCE:1]","Left",1);use the windowinfo tool from autoit EndIf EndIf Sleep(10) WEnd 1 more question : Will this LOOP and wait for the next time the popup appears ? Edited March 1, 2010 by barkeeper Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 1, 2010 Share Posted March 1, 2010 another option that might work instead of pixelchecksum and wingetpos would be using winexists 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 1, 2010 Share Posted March 1, 2010 1 more question : Will this LOOP and wait for the next time the popup appears ?yes, While 1 is a neverending loop 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
barkeeper Posted March 1, 2010 Author Share Posted March 1, 2010 Got it, such a newbie Thank you guys for the help! you're lifesavers Link to comment Share on other sites More sharing options...
barkeeper Posted March 2, 2010 Author Share Posted March 2, 2010 1 thing i've noticed, not sure if you guys know any solution for that. But it turns out that with Vista Aero turned on the popup appears to have a different size (the border gets slighly thicker). Any ideas ? Jj Link to comment Share on other sites More sharing options...
JohnOne Posted March 2, 2010 Share Posted March 2, 2010 Is this window "message from webpage" the only one with that name ? If so you dont need to check its size. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Bert Posted March 2, 2010 Share Posted March 2, 2010 What happens when you use the AutoIt window info tool on it? Does the tool give you any info? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 2, 2010 Share Posted March 2, 2010 Is this window "message from webpage" the only one with that name ?If so you dont need to check its size.Yeah, he said Javascript popup so I wasn't sure if using the window title would work. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
barkeeper Posted March 3, 2010 Author Share Posted March 3, 2010 It appears to have different sizes when you have "AERO" activated, it's like a little extra border is around the screens, adapting the size in the source did the trick. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now