DannyJ Posted August 30, 2019 Posted August 30, 2019 So I want to write an endles loop that check that a window is active or not and if the window is not active it stops. Sleep(5500) $sActiveWindowTitle = WinGetTitle( "[ACTIVE]" ) $pagename = "Google" ConsoleWrite(StringInStr($sActiveWindowTitle,$pagename)) While 1 MyAdLibFunc() WEnd Func MyAdLibFunc() Local Static $iCount = 0 $iCount += 1 ConsoleWrite("MyAdLibFunc called " & $iCount & " time(s)" & @CRLF) If (StringInStr($sActiveWindowTitle,$pagename ) > 0) Then ConsoleWrite(@CRLF & "now " & $sActiveWindowTitle & @CRLF) ConsoleWrite(StringInStr($sActiveWindowTitle,$pagename)) Else ConsoleWrite(@CRLF & "now" & $sActiveWindowTitle & @CRLF) ConsoleWrite(StringInStr($sActiveWindowTitle,$pagename)) Exit EndIf EndFunc ;==>MyAdLibFunc
Developers Jos Posted August 30, 2019 Developers Posted August 30, 2019 (edited) 1 minute ago, DannyJ said: So I want to write an endles loop that check that a window is active or not and if the window is not active it stops. Nice, but what is the question/issue? Jos Edited August 30, 2019 by Jos DannyJ 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
DannyJ Posted August 30, 2019 Author Posted August 30, 2019 Hi Jos the issue is that in my code if I change between windows the function not recognize that I changed the Google window. Can you check the code? Thanks.
Developers Jos Posted August 30, 2019 Developers Posted August 30, 2019 Ok, well, you aren't updating the $sActiveWindowTitle variable with the current situation so you keep on testing the start status. Jos DannyJ 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
DannyJ Posted August 30, 2019 Author Posted August 30, 2019 Thank you And have you got any idea how to update $sActiveWindowTitle variable?
Developers Jos Posted August 30, 2019 Developers Posted August 30, 2019 50 minutes ago, DannyJ said: Thank you And have you got any idea how to update $sActiveWindowTitle variable? Yes... but more important have you? You were able to fill it initially, so surely you can up we the appropriate statement at the right place to update that variable each loop you check for it. Jos DannyJ 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
DannyJ Posted August 30, 2019 Author Posted August 30, 2019 $pagename = "Google" $loop = (StringInStr($sActiveWindowTitle,$pagename)) While $loop <> 0 MyAdLibFunc() $loop = (StringInStr($sActiveWindowTitle,$pagename)) WEnd This code still not works any ideas to correct it?
Nine Posted August 30, 2019 Posted August 30, 2019 What Jos meant is you need to refresh the active window, take a look at this : #include <Constants.au3> Opt("MustDeclareVars", 1) Const $pagename = "Google" HotKeySet("{END}", "_Exit") AdlibRegister("MyAdLibFunc", 10000); check every 10 secs While 1 Sleep(100) WEnd Func MyAdLibFunc() Local Static $iCount = 0 $iCount += 1 ConsoleWrite("MyAdLibFunc called " & $iCount & " time(s)" & @CRLF) Local $sActiveWindowTitle = WinGetTitle("[ACTIVE]") ConsoleWrite("now " & $sActiveWindowTitle & @CRLF) If StringInStr($sActiveWindowTitle, $pagename) Then ConsoleWrite(StringInStr($sActiveWindowTitle, $pagename & @CRLF)) Else ConsoleWrite(StringInStr($sActiveWindowTitle, $pagename & @CRLF)) Exit EndIf EndFunc ;==>MyAdLibFunc Func _Exit () Exit EndFunc DannyJ 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
DannyJ Posted September 5, 2019 Author Posted September 5, 2019 Great Thank you very much for assistance😀
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