Sign in to follow this  
Followers 0
martin

Esc causes problem if script running

8 posts in this topic

#1 ·  Posted (edited)

I have an AutoIt script to run an old dos program in DOSBox because that's the only way I can get it to work in Windows 7.

The script starts up DOSBox with the relevant configuration file and it all works ok unless I press Esc. There is nothing in my script to use Esc and in case it made a difference I tried using

Opt("GuiCloseOnESc", 0)

although the script has no gui. I am not using _IsPressed and there is no hotkey for "{Esc}"

The script needs to be kept running because it monitors the DOSBox window and sets it to full screen when needed. When in full screen pressing the Esc key will often cause a temporary switch to the desktop before the script sees that the window is the wrong size and sets it back.

If I stop the script this problem is not there, that is if the app is in full screen mode then pressing the Esc key doesn't cause any problem.

So I conclude that the AutoIt script somehow is reacting to the Escape key in a way that I don't understand. I assume that it must intercept the Esc key for the "GuiiCloseOnEsc" option, but maybe it then sends the key back to the wrong window.

Has anyone got any ideas about this?

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites



Have you tried to capture the Escape key with a dummy function?

Share this post


Link to post
Share on other sites

Have you tried to capture the Escape key with a dummy function?

Yes, I tried using a hotkeyset to capture the ESc key and call a function which does nothing. The problem still occured.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Are you using x64? If you are then have you tried #AutoIt3Wrapper_UseX64=N. I sometimes finds this solves a few problems I may have.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Does this still happen with a empty script? (just a While and Sleep to keep it up)

I will try to reproduce this when I get home. Maybe an hour.

Thanks AdmiralAlkex but I douibt you will be able to reproduce the problem as you see below.

Strangely it does seem to depend on the script but I can't say I understand why. If I make the script start up the DOSBox and then just idle in a loop then the problem appears to go. I think it has something to do with the fact that the script changes the state of the window. It seems that if the script restores the program from minimized and then maximizes the program then pressing Escape causes some strange effect..

The circumstances needed to cause the effect are very difficult for anyone else to reproduce because it only happens when I've chosen certain options in the app, chosen to run another app in another DOSBox, closed the second app and set the first one back to full screen. Then the problem occurs. If I do these things maually with the script running in an idle loop but taking no part in the state of the windows, then there is no problem with the Escape key.

I've discovered that pressing Esc actually minimizes the window whereas I had thyought the focus was being shifted to another window. Because my script restores the program if it's minimized I didn't realize it was happening. There is nothing in my script to make anything minimize.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I think it has something to do with the fact that the script changes the state of the window. It seems that if the script restores the program from minimized and then maximizes the program then pressing Escape causes some strange effect..

Maybe hide the Window, then do the minimised -> maximised stuff, and then Unhide ?

Share this post


Link to post
Share on other sites

Maybe hide the Window, then do the minimised -> maximised stuff, and then Unhide ?

Thanks for your suggestion whim.

SInce the problem only happens when I have the application in full screen I have decided on another approach.

I use the "windowresolution" setting in the DOSBox configuration file to mak ethe windowed version almost full screen and don't worry about setting it to full screen. Now there is no problem.

So I don't understand why the Esc caused the problem but I've found a way to get round it. That took me about 6 hours. :)>


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0