E1M1 Posted February 23, 2011 Share Posted February 23, 2011 What's the C++ code for WinWaitNotActive()? Is there any specific function that is called or does autoit just get title of active window like 50 times in sec and return when current window title is not equal to old window title? edited Link to comment Share on other sites More sharing options...
Richard Robertson Posted February 23, 2011 Share Posted February 23, 2011 It's basically a loop with a sleep in it. It just checks and returns when it happens or times out. Link to comment Share on other sites More sharing options...
E1M1 Posted February 23, 2011 Author Share Posted February 23, 2011 I wonder what's good sleep for it? 10? edited Link to comment Share on other sites More sharing options...
jvanegmond Posted February 23, 2011 Share Posted February 23, 2011 I wonder what's good sleep for it? 10?It depends on the demands of your application. If it's some unattended script, then it might as well check every 30 seconds. By default, it probably uses WinWaitDelay option: 250ms. github.com/jvanegmond Link to comment Share on other sites More sharing options...
E1M1 Posted February 23, 2011 Author Share Posted February 23, 2011 I managed to code this but for some reason I see only 1 char. #include <string> #include <windows.h> #include <stdio.h> #include <iostream.h> using namespace std; int main() { HWND handle = GetForegroundWindow(); int len = GetWindowTextLengthW( handle )+1; wchar_t * title = new wchar_t[len]; GetWindowTextW(handle, title, len ); wprintf("%s",title) ; return 0; } edited Link to comment Share on other sites More sharing options...
Richard Robertson Posted February 23, 2011 Share Posted February 23, 2011 It only returns one character of any active window? Link to comment Share on other sites More sharing options...
E1M1 Posted February 23, 2011 Author Share Posted February 23, 2011 It was printf's problem. Got whole title with msgbox.. But I found ineresting thing.. Compare C++ time to autoit time. AutoIt is about 21 times slower. #include <string> #include <windows.h> #include <stdio.h> #include <iostream> using namespace std; wstring GetActiveWindowTitle() { wstring title; HWND handle = GetForegroundWindow(); int len = GetWindowTextLengthW( handle )+1; wchar_t * omgtitle = new wchar_t[len]; GetWindowTextW(handle,omgtitle,len); title += omgtitle; return title; } int main() { int i = 1; for (i;i < 200000;i++) { GetActiveWindowTitle(); } //wstring loltitle; //loltitle = L"Title is: "; //loltitle += GetActiveWindowTitle(); //MessageBoxW(NULL,loltitle.c_str(),L"hi",0); return 0; } $in = TimerInit() for $i = 1 to 200000 WinGetTitle("[Active]") Next ConsoleWrite(TimerDiff($in)&@CRLF) edited Link to comment Share on other sites More sharing options...
James Posted February 23, 2011 Share Posted February 23, 2011 But I found ineresting thing.. Compare C++ time to autoit time. AutoIt is about 21 times slower.I wonder if that has anything to do with the fact that AutoIt is an interpreted language? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
E1M1 Posted February 23, 2011 Author Share Posted February 23, 2011 I wonder if that has anything to do with the fact that AutoIt is an interpreted language?True. I didn't think interpreting takes that much time.consolewrite C++ and autoit are almost equal.. C++ is like 1.2 times faster, not 21. edited Link to comment Share on other sites More sharing options...
Mobius Posted February 23, 2011 Share Posted February 23, 2011 (edited) ~ Edited March 2, 2011 by Mobius Link to comment Share on other sites More sharing options...
E1M1 Posted February 23, 2011 Author Share Posted February 23, 2011 Right Mobius. I didn't say anything bad about autoit speed. I just mentioned difference between 2 languages and that's all. edited Link to comment Share on other sites More sharing options...
Zedna Posted February 24, 2011 Share Posted February 24, 2011 What's the C++ code for WinWaitNotActive()?Look at sources:http://www.autoitscript.com/autoit3/files/archive/autoit/autoit-v3.1.0-src.exe Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Administrators Jon Posted February 25, 2011 Administrators Share Posted February 25, 2011 It was printf's problem. Got whole title with msgbox..But I found ineresting thing.. Compare C++ time to autoit time. AutoIt is about 21 times slower.AutoIt goes to sleep to conserve CPU when it's waiting, and then it also adds on the WinWaitDelay when it detects a window so that it gets a chance to be fully active before you start sending keys to it. So be default a wait is always going to be around the 300ms mark. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ 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