MrBoo Posted January 23, 2008 Posted January 23, 2008 Hi folks, Only me again - I'm really sorry about asking silly questions - I promise I'm trying to figure things out myself first, and using help and forum-search... Hope you can help... At the moment I'm trying to wait for, maximise and screen-grab an IE 7 window (in Vista if it makes any difference) - here's what I've tried... #include <ScreenCapture.au3> WinWait("Futuremark - ORB - Result Analyzer - Windows Internet Explorer") WinActivate("Futuremark - ORB - Result Analyzer - Windows Internet Explorer") WinSetState("Futuremark - ORB - Result Analyzer - Windows Internet Explorer", "", @SW_MAXIMIZE) _ScreenCapture_Capture("C:\TEST-RESULTS\3DMark06 Pass 1.jpg") And... #include <ScreenCapture.au3> WinWait("[CLASS: IEFrame]") WinActivate("[CLASS: IEFrame]") WinSetState("[CLASS: IEFrame]", "", @SW_MAXIMIZE) _ScreenCapture_Capture("C:\TEST-RESULTS\3DMark06 Pass 1.jpg") Neither works... In the first example the window isn't maximised and the screen-grab is taken (before the content is ready but I'll add a 'sleep' for that); in the second example the script just pauses and doesn't notice the IE window... Any help would be fantastic! Thanks in advance, Rob.
blademonkey Posted January 23, 2008 Posted January 23, 2008 WinWait("[CLASS: IEFrame]") that's not actually working for me. I don't think it's detecting your ieframe, so it's not triggering/targeting your ie window. I dont know what to tell you for the Class stuff, i'm not very familiar with that syntax, but what you could do is this #include <ScreenCapture.au3> Opt("WinTitleMatchMode", 2) WinWait("Internet Explorer") WinSetState("Internet Explorer", "", @SW_MAXIMIZE) WinActivate("Internet Explorer") _ScreenCapture_Capture("C:\TEST-RESULTS\3DMark06 Pass 1.jpg") ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung
MrBoo Posted January 23, 2008 Author Posted January 23, 2008 Thanks for the advice, I tried your suggestion and it did the same as my first example... Didn't maximise the window and just continued to take the screen-grab anyway. Returned exit code 0 so as far as AutoIt is concerned it went smoothly? Regards, Rob.
blademonkey Posted January 23, 2008 Posted January 23, 2008 you had the "Opt("WinTitleMatchMode", 2)" in the new code you tested? that should have worked, the only other think i can think of is that your script needs to have a longer winwait delay or something. ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung
MrBoo Posted January 23, 2008 Author Posted January 23, 2008 (edited) I'll give it a go with longer WinWaitDelay as it's like AutoIt isn't recognising the window title... I just tried another little idea - sending F11 to make IE go to full-screen mode (the first sleep was added to allow the page to load and the second to allow the button-bar in the full-screen IE window to disappear). ...IE wasn't sent to full-screen and the script just continued... Regards, Rob. #include <ScreenCapture.au3> WinWait("Futuremark - ORB - Result Analyzer - Windows Internet Explorer") WinActivate("Futuremark - ORB - Result Analyzer - Windows Internet Explorer") Sleep(10000) Send("{F11}") Sleep(2000) _ScreenCapture_Capture("C:\TEST-RESULTS\3DMark06 Pass 1.jpg") Send("{F11}") Edited January 23, 2008 by MrBoo
PsaltyDS Posted January 23, 2008 Posted January 23, 2008 Much better way to do this with IE functions: #include <ScreenCapture.au3> #include <IE.au3> If WinWait("Google", "", 10) Then ; 10sec timeout $oIE = _IEAttach("Google", "Title") $hIE = _IEPropertyGet($oIE, "HWND") WinActivate($hIE) _IELoadWait($oIE) _IEPropertySet($oIE, "theatermode", True) _ScreenCapture_Capture("C:\Temp\Test1.jpg") _IEPropertySet($oIE, "theatermode", False) Else MsgBox(16, "Error", "Did not see Google window before timeout!") Exit EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
MrBoo Posted January 23, 2008 Author Posted January 23, 2008 (edited) Hey! Thanks for the reply... I've looked at your code and tried to figure out what I need to change to test it for my scenario... (I know this isn't completely altered, but from what I could see as a novice it seemed that it should help test at least, even if not perfect)... #include <ScreenCapture.au3> #include <IE.au3> If WinWait("Futuremark - ORB", "", 10) Then; 10sec timeout $oIE = _IEAttach("Futuremark - ORB", "Title") $hIE = _IEPropertyGet($oIE, "HWND") WinActivate($hIE) _IELoadWait($oIE) _IEPropertySet($oIE, "theatermode", True) _ScreenCapture_Capture("C:\Temp\Test1.jpg") _IEPropertySet($oIE, "theatermode", False) Else MsgBox(16, "Error", "Did not see Google window before timeout!") Exit EndIf When I ran that, I got: >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\3XS\Desktop\chunk5.au3" --> IE.au3 V2.3-1 Warning from function _IEAttach, $_IEStatus_NoMatch --> IE.au3 V2.3-1 Error from function _IEPropertyGet, $_IEStatus_InvalidDataType --> IE.au3 V2.3-1 Error from function _IELoadWait, $_IEStatus_InvalidDataType --> IE.au3 V2.3-1 Error from function _IEPropertySet, $_IEStatus_InvalidDataType --> IE.au3 V2.3-1 Error from function _IEPropertySet, $_IEStatus_InvalidDataType Even though there were warnings/errors, it gives me some hope that now AutoIt can at least see the window and what's going on to some degree... I'm a little confused about what the $oIE and $hIE bits are for, particularly the relevance of "HWND" after the $hIE = statement... If you could maybe help me make a little more sense of what's going on I'd be sincerely grateful! Thanks again, Rob. EDIT: OK so I found out that HWND is for getting the handle of the window... Still working on the rest! EDIT2: So thinking that it was complaining about the use of HWND to grab and then refer to the window handle, I opened up the page source and looked for the HTML title element, and tried this: #include <ScreenCapture.au3> #include <IE.au3> If WinWait("Futuremark - ORB - Result Analyzer", "", 10) Then; 10sec timeout $oIE = _IEAttach("Futuremark - ORB - Result Analyzer", "Title") $hIE = _IEPropertyGet($oIE, "title") WinActivate($hIE) _IELoadWait($oIE) _IEPropertySet($oIE, "theatermode", True) _ScreenCapture_Capture("C:\Temp\Test1.jpg") _IEPropertySet($oIE, "theatermode", False) Else MsgBox(16, "Error", "Did not see Google window before timeout!") Exit EndIf ...Returns the same errors/warnings and I'm not sure why? Thanks and regards, Rob. Edited January 23, 2008 by MrBoo
PsaltyDS Posted January 23, 2008 Posted January 23, 2008 Look at _IEAttach() in the help file and try some of the other modes, specifically try "WindowTitle" vice "Title". The window handle is not required, I just put it in there to use it for WinActivate($hIE) to make sure it was the active window when the screen capture happened. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
MrBoo Posted January 23, 2008 Author Posted January 23, 2008 (edited) Thanks for your reply (again!)...While you were looking at this I've been doing some more testing...The deduction is that it's UAC related...OK, this might be a little tricky for me to find the right vocabulary and structure for, so please bear with me!What happens in my script...1) User launches script from compiled .exe - I am using #RequireAdmin (more in point 3) so UAC pop-up appears to get the user to agree to elevation.2) Script runs various testing applications (which don't require elevation) and takes screen-grabs3) Script launches 3DMark06 (which does require elevation to run), as #RequireAdmin has been used, 3DMark06 inherits permission from the script .exe and runs fine.4) I use ControlClick a few times to make 3DMark06 do start its tests.5) I come to the results screen, use ControlClick again to hit two buttons - the first to 'show the results' and the second to agree to a disclaimer. After this second ControlClick, 3DMark06 launches Internet Explorer and sends it to a page (example URL: http://service.futuremark.com/orb/resultan...p;UID=13622225) to show me the result of the test.6) I want my script to maximise this IE window, take a screengrab, then continue to other operations....That's where it falls down, the script doesn't interract with the IE window at all.What I've found is that my script, elevated to Admin by UAC (in order to launch 3DMark), will not communicate with IE (which has inherited permissions from 3DMark, which in turn inherited them from my script).To prove this theory, I manually copied the example URL above from the IE window 3DMark launched to the clipboard, launched a new (non-Admin) instance of IE from the Start Menu (manually) and pasted the URL into it. I ran the portion of the script which will maximise IE and screengrab it. It worked flawlessly.To further prove this, I then ran a command prompt as Administrator, launched iexplore.exe and pasted the URL again. I ran the same portion of the script and it didn't maximise the IE window, and just continued to take the screengrab.So, it would seem that my elevated script will not communicate with an elevated IE window, but will communicate to a 'peon' one. The problem with this is that 3DMark06 needs to be elevated to run, so it launches IE elevated. I can't workaround this by making my script copy the URL from the elevated IE window and paste it into a 'peon' one, because the script and IE window can't even communicate enough to copy the URL out for pasting elsewhere. If I try to use _IEPropertyGet to grab the URL, it simply reports "0" as the URL....Which results in my being TOTALLY stuck!Does anyone have any suggestions for getting the script (running with elevated permissions) to communicate with an IE window running elevated?Regards,Rob.EDIT - Also, I have tried disabling UAC completely with a RegWrite at the beginning of the script, but 3DMark won't launch with 'Run' (shows that it requires elevation), and if I use 'ShellExecute' I have mouse control and controlclick issues (ie - I can't click any buttons to get 3DMark to do anything) - hence why I'm leaving UAC enabled and elevating the script with #RequireAdmin Edited January 23, 2008 by MrBoo
DaleHohm Posted January 23, 2008 Posted January 23, 2008 #RequireAdmin Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
MrBoo Posted January 23, 2008 Author Posted January 23, 2008 That's just the thing, I'm using #RequireAdmin in my script in order for 3DMark06.exe to start without nagging (because I would rather users allow the script elevation when they first run it than for them to keep coming back to the machine to check if 3DMark06.exe has caused a UAC prompt when it starts)... So 3DMark06.exe inherits its elevation from my script and starts fine... Then it launches IE to show the results, again elevated through inheritence. So in short, my script, and the IE window I wish to interract with are both UAC elevated, but they do not talk. As above, if I manually copy the URL from the elevated IE window started by 3DMark06 to a 'peon' window launched manually, the elevated script can interract with this and do the maximise operation I wish it to. The problem is that even though the script AND IE are both running elevated, they can't talk... Regards, Rob.
MrBoo Posted January 24, 2008 Author Posted January 24, 2008 (edited) I'm really sorry for the BTT... But surely one of the AutoIt Jedis has an idea of how I might get around this? I know it's UAC's fault that somehow two applications which are running 'elevated' or 'as administrator' can't communicate with each other; but there's got to be something sneaky which can be done in AutoIt to get around this? Regards, Rob. EDIT: I just tried using #RequireAdmin and disabling UAC with... Sleep(1000) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "ConsentPromptBehaviorAdmin", "REG_DWORD", "00000000") Sleep(1000) ...I did it to purely clutch at straws... Mainly because even when using the RegWrite above to disable UAC, if I don't use #RequireAdmin my script can't launch 3DMark06.exe - I figured that maybe if as far as IE knew, UAC was turned off, it wouldn't matter how it was launched and that my script would be able to interract with it. Unfortunately not - the same behaviour was evident - the script continued to take the screen grab without maximising the IE window first. Rob. Edited January 24, 2008 by MrBoo
DaleHohm Posted January 24, 2008 Posted January 24, 2008 You might want to try lauching your web apps in an HTA (HyperText Application) instead of in a .htm file. For more information on HTAs, see: http://msdn2.microsoft.com/en-us/library/m...471(vs.85).aspxDale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
MrBoo Posted January 24, 2008 Author Posted January 24, 2008 I like your thinking, but I'm not sure it's going to work... You see the issue is that 'I' launch 3DMark06, and 'it' launches the web content; so I've no control over how it does it. The front-runner for a workaround at the moment (just working on it now) is... 1) Create a script that doesn't run as administrator... i) Make this script open an IE window ii) Then stretch it to fill as much of the screen as possible (can't use maximise as 3DMark06 always opens a 'normal' (not minimised or maximised) window) iii) Close the IE window iv) Call the 'main' script which runs as Admin to perform the tests 2) When 3DMark06 launches IE, the window will be set as was by the 'Peon' script ...Not pretty I know, but you work with what you've got! I hope there's some way in AutoIt to simply stretch a window to a given size rather than simply maximising it (looking through the help now!)... Regards, Rob.
MrBoo Posted January 24, 2008 Author Posted January 24, 2008 (edited) Hmmm...From what I can see in the help there's no way to set a window to a particular size from a specified origin?ie- Make the window 1280x1000 pixels from pixel 0,0 in as origin?...Or have I missed something? (I hope!)Regards,Rob.EDIT: I just found WinMove and got very excited (sad I know!)... Will report back if my workaround is successful! Edited January 24, 2008 by MrBoo
MrBoo Posted January 24, 2008 Author Posted January 24, 2008 OK folks, It's not the most intelligent fix in the world, but hey, it works and I feel really happy that I've got past it! I've got two scripts now... The first simply does this: Opt("WinTitleMatchMode", 2) Run("C:\Program Files\Internet Explorer\iexplore.exe") WinWait("Windows Internet Explorer") WinActivate("Windows Internet Explorer") WinMove("Windows Internet Explorer", "", 0,0, 1280, 995) Sleep(500) Send("!{F4}") Run("C:\TESTS\FULLTESTS.EXE") The last line calls the 'real' test script which runs as Admin so everything else works, once 3DMark06 launches IE, it's set to a 1280x995 window (the full screen apart from the task bar), and it's all good! Regards, A very content Rob
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