E1M1 Posted February 23, 2011 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
Richard Robertson Posted February 23, 2011 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.
E1M1 Posted February 23, 2011 Author Posted February 23, 2011 I wonder what's good sleep for it? 10? edited
jvanegmond Posted February 23, 2011 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
E1M1 Posted February 23, 2011 Author 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
Richard Robertson Posted February 23, 2011 Posted February 23, 2011 It only returns one character of any active window?
E1M1 Posted February 23, 2011 Author 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
James Posted February 23, 2011 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
E1M1 Posted February 23, 2011 Author 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
E1M1 Posted February 23, 2011 Author 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
Zedna Posted February 24, 2011 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
Administrators Jon Posted February 25, 2011 Administrators 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.
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