jxw Posted May 27, 2020 Posted May 27, 2020 Hi, New to the AutoIt and this forum. Here's a weird behavior - can someone please tell me if it's a legit bug or if I'm doing something wrong? The script is below. The first part just makes sure all options are set to default. The weird behavior is that ControlSend() of a quotation mark to Notepad can either result in a ' or " It seems that you have to do a ControlClick() first in order to make the problem happen. What is going on here? Does it have to do with some unreliability of sending the SHIFT key state? If I put a delay after the ControlClick(), the problem seems to become more infrequent with increasing delay. Without the ControlClick(), the problem seems to go away completely. ; Full AutoIt options list - default value is listed first Opt("CaretCoordMode", 1) ;1=absolute, 0=relative, 2=client Opt("ExpandEnvStrings", 0) ;0=don't expand, 1=do expand Opt("ExpandVarStrings", 0) ;0=don't expand, 1=do expand Opt("GUICloseOnESC", 1) ;1=ESC closes, 0=ESC won't close Opt("GUICoordMode", 1) ;1=absolute, 0=relative, 2=cell Opt("GUIDataSeparatorChar", "|") ;"|" is the default Opt("GUIOnEventMode", 0) ;0=disabled, 1=OnEvent mode enabled Opt("GUIResizeMode", 0) ;0=no resizing, <1024 special resizing Opt("GUIEventOptions", 0) ;0=default, 1=just notification, 2=GUICtrlRead tab index Opt("MouseClickDelay", 10) ;10 milliseconds Opt("MouseClickDownDelay", 10) ;10 milliseconds Opt("MouseClickDragDelay", 250) ;250 milliseconds Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client Opt("MustDeclareVars", 0) ;0=no, 1=require pre-declaration Opt("PixelCoordMode", 1) ;1=absolute, 0=relative, 2=client Opt("SendAttachMode", 0) ;0=don't attach, 1=do attach Opt("SendCapslockMode", 1) ;1=store and restore, 0=don't Opt("SendKeyDelay", 5) ;5 milliseconds Opt("SendKeyDownDelay", 1) ;1 millisecond Opt("TCPTimeout", 100) ;100 milliseconds Opt("TrayAutoPause", 1) ;0=no pause, 1=Pause Opt("TrayIconDebug", 0) ;0=no info, 1=debug line info Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon Opt("TrayMenuMode", 0) ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return Opt("TrayOnEventMode", 0) ;0=disable, 1=enable Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect Opt("WinSearchChildren", 1) ;0=no, 1=search children also Opt("WinTextMatchMode", 1) ;1=complete, 2=quick Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Opt("WinWaitDelay", 250) ;250 milliseconds Local $sWindow = "Untitled - Notepad" Local $hWnd = WinWait($sWindow, "", 10) Local $sControl = "Edit1" ; Send a mouse click to the edit control using the handle returned by WinWait. ControlClick($hWnd, "", $sControl) ; comment out this line and the problem goes away ControlSend($hWnd, "", $sControl, '"') ; seems to randomly send either ' or "
Nine Posted May 27, 2020 Posted May 27, 2020 (edited) I am unable to reproduce your issue, all sends are correctly performed. What version of autoit are you using ? Edit : I remember awhile ago someone has a similar problem with ControlSend and using KB while script was running. By using my BlockInput UDF (see my signature), it has solved the issue. Edited May 27, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
abberration Posted May 27, 2020 Posted May 27, 2020 Try sending a Chr(34) instead of '"'. Easy MP3 | Software Installer | Password Manager
seadoggie01 Posted May 27, 2020 Posted May 27, 2020 Strangely, I was able to reproduce this one time. (Version 3.3.14.5) All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
Nine Posted May 27, 2020 Posted May 27, 2020 Try putting a sleep after ControlClick. I also remember that using mouse while script was running could cause the issue too. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
seadoggie01 Posted May 27, 2020 Posted May 27, 2020 (edited) I only got it to work the very first time... I haven't been able to do it ever again. I think it's magic Edit: Moving the mouse did it. I maximized Notepad and moved my mouse on my second screen. Putting the ControlClick & ControlSend in a loop helped catch it. Edited May 27, 2020 by seadoggie01 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
seadoggie01 Posted May 27, 2020 Posted May 27, 2020 (edited) So this seems to fix it, but makes the mouse a bit jumpy Func ControlSend_Fixed($sTitle, $sText, $sControlID, $sString) Local $tagRECT = "struct;long Left;long Top;long Right;long Bottom;endstruct" Local $tRECT = DllStructCreate($tagRECT) Local $aPos = MouseGetPos() DllStructSetData($tRECT, "Left", $aPos[0]) DllStructSetData($tRECT, "Top", $aPos[1]) DllStructSetData($tRECT, "Right", $aPos[0]) DllStructSetData($tRECT, "Bottom", $aPos[1]) DllCall("user32.dll", "bool", "ClipCursor", "struct*", $tRECT) Local $vRet = ControlSend($sTitle, $sText, $sControlID, $sString) DllCall("user32.dll", "bool", "ClipCursor", "ptr", 0) If @error Then Return SetError(1, 0, False) Return $vRet EndFunc (Based off of Gary Frost's MouseTrap) Edited May 27, 2020 by seadoggie01 (3 edits because I can't code without Au3Check) All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
Nine Posted May 27, 2020 Posted May 27, 2020 Try my udf it worked quite nicely at the time. It solved both problems : mouse and kb... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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