BR4ND0N8 Posted June 20, 2017 Share Posted June 20, 2017 Hello all, Long time lurker... first time poster. Usually, I am able to search the AutoIt forums or whip out my Google-Fu in order to get around a weird scripting issue but I have been unable to resolve the issue I have come up with this time. When searching I found very few results and they didn't help me to resolve the issue. So, I decided to join the forum and test out the more adept scripters to see what they could find. Here's what I am dealing with... I am in the process of creating a Windows 7 Kiosk image for use in a public environment and I am trying to prevent people from clicking on the Favorites and Tools buttons on the toolbar in Internet Explorer 11. The script that I created is creating a transparent GUI (without controls or borders) over-top of Internet Explorer 11 and will move when/if IE11 is moved. All of that seems to be working pretty well. The weird thing that is happening is that when Internet Explorer 11 is closed, and the transparent GUI closes afterward, an AutoIt Error window appears stating: AutoIt Error Line 895 (File "C:\...\...\...\...\KDG - Kiosk - IE InPrivate Lock v1.0.exe"): Error: Subscript used on non-accessible variable. [OK] - I have tried this on 3 different PCs and they all have the same issue. - I have reinstalled AutoIt v3.3.14.2 - I have reinstalled SciTE4AutoIt3 v17.224.935.0 - Removed local variables and switched to global variables (per a forum recommendation I found... did not help.) - Removed most extra code I was playing with. The script runs and closes gracefully from F5 in SciTE, but after it's compiled I get the error. What do you guys/gals think? I will attach my script and a screenshot of the error message I receive. Thank you, Brandon KDG - Kiosk - IE Lock - InPrivate - Copy.au3 Link to comment Share on other sites More sharing options...
BR4ND0N8 Posted June 20, 2017 Author Share Posted June 20, 2017 Here is my code inserted into a post so you don't have to download the .AU3 Thank you! expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=C:\- Brandon\Utility\AutoIt\KDG - Kiosk - IE InPrivate Lock\KDG - Kiosk - IE InPrivate Lock v1.0.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;========== KDG - Kiosk - IE Lock - InPrivate v1.0 ========== ;========== Brandon Bolles - 2017 - updated 2017.06.20 ========== ;========== Include Section ========== #include <GUIConstantsEx.au3> #include <TrayConstants.au3> #include <WindowsConstants.au3> ;========== Include Section ========== ;========== Pragma Compile Section ========== ;#pragma compile(ExecLevel, highestavailable) #pragma compile(ExecLevel, requireAdministrator) #pragma compile(Icon, C:\- Brandon\Utility\AutoIt\KDG - RemoteUpdater\KDG - RemoteUpdater.ico) #pragma compile(ProductName, KDG - RemoteUpdater) #pragma compile(ProductVersion, v1.0) #pragma compile(FileVersion, 1.0.0.0) #pragma compile(FileDescription, KDG - Kiosk - IE Lock - InPrivate v1.0 - a utility to disable Favorites and Tools buttons) #pragma compile(LegalCopyright, © BR4ND0N8) ;TraySetToolTip("KDG - Kiosk - IE Lock - InPrivate v1.0") ;========== Pragma Compile Section ========== ;========== Option Section ========== Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Opt("WinTitleMatchMode", 2) ; Sets WinTitleMatchMode to Mode 2, which allows partial Windows Title calls.) ;========== Option Section ========== ;========== Variable Section ========== Global $GUI_Hidden Global $GUI_Hidden_Status Global $PositionBefore Global $PositionBefore_X_LR Global $PositionBefore_Y_UD Global $PositionBefore_Width Global $PositionBefore_Height Global $PositionAfter Global $PositionAfter_X_LR Global $PositionAfter_Y_UD Global $PositionAfter_Width Global $PositionAfter_Height Global $AppTitleID Global $AppHandleID ;========== Variable Section ========== ;========== Main_Routine ========== _Main() Func _Main() ShellExecute("iexplore.exe", "-private https://www.google.com", @SW_SHOWMAXIMIZED) WinWaitActive("Internet Explorer", "") $PositionBefore = WinGetPos("Internet Explorer", "") $PositionBefore_X_LR = $PositionBefore[0] ; WinGetPos - x (left to right) $PositionBefore_Y_UD = $PositionBefore[1] ; WinGetPos - y (up and down) $PositionBefore_Width = $PositionBefore[2] ; WinGetPos - width $PositionBefore_Height = $PositionBefore[3] ; WinGetPos - height $GUI_Hidden = GUICreate("KDG - Kiosk - IE Lock - InPrivate", 55, 25, (($PositionBefore_X_LR + $PositionBefore_Width) - 63), ($PositionBefore_Y_UD + 32), $WS_POPUP, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW) ;WinSetTrans($GUI_Hidden, "", 1) ; WinSetTrans("title", "text", transparency (0=invisible - 255=solid)) WinSetTrans($GUI_Hidden, "", 150) ; WinSetTrans("title", "text", transparency (0=invisible - 255=solid)) GUISetState(@SW_SHOW) ; will display an empty dialog box If WinExists("Internet Explorer", "") Then $AppTitleID = "Internet Explorer" WinWait($AppTitleID, "", 60) ; (..., "", 60) = 60 second timeout and (..., "", 0) = no timeout WinActivate($AppTitleID, "") WinSetState($AppHandleID, "", @SW_MAXIMIZE) Else EndIf AdlibRegister("WindowMove_Routine", 10) ; Run the GUI until the dialog is closed While 1 $GUI_Hidden_Status = GUIGetMsg() If $GUI_Hidden_Status = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() EndFunc ;========== Main_Routine ========== ;========== WindowMove_Routine ========== Func WindowMove_Routine() $PositionAfter = WinGetPos("Internet Explorer", "") $PositionAfter_X_LR = $PositionAfter[0] ; WinGetPos - x (left to right) $PositionAfter_Y_UD = $PositionAfter[1] ; WinGetPos - y (up and down) $PositionAfter_Width = $PositionAfter[2] ; WinGetPos - width $PositionAfter_Height = $PositionAfter[3] ; WinGetPos - height WinMove($GUI_Hidden, "", (($PositionAfter_X_LR + $PositionAfter_Width) - 63), ($PositionAfter_Y_UD + 32)) EndFunc ;========== WindowMove_Routine ========== Link to comment Share on other sites More sharing options...
BrewManNH Posted June 20, 2017 Share Posted June 20, 2017 It's coming from your AdLib function, it's being called every ten milliseconds, so it's probably getting activated too quickly before the GUI closes. Try using a Windows message handler instead of monitoring the position of IE every 10ms. Try using WM_MOVE or perhaps WM_MOVING, not too sure. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
BR4ND0N8 Posted June 20, 2017 Author Share Posted June 20, 2017 This is the first time I've used AdLib for a function that wasn't a pre-working snippet/module, so that would make sense. If I added Sleep(1000) before GUIDelete() Would that, most likely, remedy the problem? I ask because I like the current refresh rate when moving the window. A longer delay between refresh causes the overlay Transparent GUI to lag behind the Internet Explorer 11 window... and this error only occurs when closing IE11 just before the script closes. Link to comment Share on other sites More sharing options...
BR4ND0N8 Posted June 20, 2017 Author Share Posted June 20, 2017 I think I figured it out. I will do some testing tomorrow when I get back to work. I added an If/Then/Else to the AdLib routine... not sure why I didn't do that. Sometimes it helps to have someone with fresh eyes. Below will depict what I changed. Thank you for pointing me in the right direction BrewManNH!!! I changed this: While 1 $GUI_Hidden_Status = GUIGetMsg() If $GUI_Hidden_Status = $GUI_EVENT_CLOSE Then ExitLoop WEnd To this: While 1 $GUI_Hidden_Status = GUIGetMsg() If $GUI_Hidden_Status = $GUI_EVENT_CLOSE Then ExitLoop Else EndIf WEnd And changed the AdLib routine: Func WindowMove_Routine() $PositionAfter = WinGetPos("Internet Explorer", "") $PositionAfter_X_LR = $PositionAfter[0] ; WinGetPos - x (left to right) $PositionAfter_Y_UD = $PositionAfter[1] ; WinGetPos - y (up and down) $PositionAfter_Width = $PositionAfter[2] ; WinGetPos - width $PositionAfter_Height = $PositionAfter[3] ; WinGetPos - height WinMove($GUI_Hidden, "", (($PositionAfter_X_LR + $PositionAfter_Width) - 63), ($PositionAfter_Y_UD + 32)) EndFunc To this: If Not WinExists("Internet Explorer", "") Then Exit Else $PositionAfter = WinGetPos("Internet Explorer", "") $PositionAfter_X_LR = $PositionAfter[0] ; WinGetPos - x (left to right) $PositionAfter_Y_UD = $PositionAfter[1] ; WinGetPos - y (up and down) $PositionAfter_Width = $PositionAfter[2] ; WinGetPos - width $PositionAfter_Height = $PositionAfter[3] ; WinGetPos - height WinMove($GUI_Hidden, "", (($PositionAfter_X_LR + $PositionAfter_Width) - 63), ($PositionAfter_Y_UD + 32)) EndIf 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