caramen Posted November 21, 2020 Posted November 21, 2020 (edited) Hello guys, I made 8 years ago a tool for a call center. A tool to let them make a looooot of action with a single click. The purpose is to go VERY VERY FAST. Each technician make arroud 40 000 actions per day... And each seconds won will be a lot of time won for them. Now I'm called back by this customer for another mission, and I can see the update of their system to Windows 10 bring them some issue with the tool. I want to make a present for this long time customer editing my own sources with an improved tool for free. In some particular function. The tool is just typing some text into some fields. That was 100% reliable on Windows 7. But it no more the case on Windows 10. My skills 8 years ago was far from now. And this tool was made only for me at the first purpose. So there is no error checking because it's not needed in this tool. But I want to make it 100% reliable back. So I tried to implement a WinGetHandle into this tool but I fall into another issue that is not really an issue but it's just a lake of performances. The tool at a precise moment send some text with particular layout everything work fine. Things get wrong at the moment I want to check too much the windows handle when I do : $hWinHandle = WinGetHandle ( "[ACTIVE]" ) $dClipSave = ClipGet () ClipPut ($A) Send ("^v") ClipPut ($dClipSave) WinActivate ( $hWinHandle ) To have a 100% reliable script I did that : (Really not the good way to do it fast) Func _SecuriteAntiPerteFocus () $hWinHandle = WinGetHandle ( "[ACTIVE]" ) EndFunc Func _SendAvSaPrPa ( $a = "" ) $hBefore = ClipGet () ClipPut($a) WinActivate ( $hWinHandle ) Send("^v") EndFunc Func _Send ( $a = "" ) ClipPut($a) WinActivate ( $hWinHandle ) Send("^v") EndFunc Func _SendApRePrPa ( $a = "" ) ClipPut($a) WinActivate ( $hWinHandle ) Send("^v") ClipPut ($hBefore) EndFunc An example of one function where it is very too long using this way : Func Func1000 () _CleanAndWait () ;~ WinActivate ( $hWinHandle ) _SendAvSaPrPa ($MSymp0) Send("{ENTER}") Send("{ENTER}") Send("{ENTER}") _Send ( $MSymp1 ) Send("{ENTER}") _Send ( $MSymp2 ) Send("{ENTER}") _SendApRePrPa ( $MSymp3 ) Send("{ENTER}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{END}") Menu () EndFunc I think you got the idea without even try the function... Each WinActivate ( $hWinHandle ) Will take 750 ms. Which will result in maybe 2100ms if it's made 3 time in the function. The problem is pretty same If I only use one WinActivate ( $hWinHandle ) 750 ms is way too much for that kind of purpose. Is there a way to do the same without wasting so much time ? Edited November 21, 2020 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted November 21, 2020 Author Posted November 21, 2020 (edited) Oh damn it... I feel stupid... Like a lot of time writing my topic made me think how to dodge the fact to do the WinActive if it's not needed 😇.... *I'm just adding a check... Func _SecuriteAntiPerteFocus () $hWinHandle = WinGetHandle ( "[ACTIVE]" ) EndFunc Func _SecuriteAntiPerteFocusCheck () If $hWinHandleCheck = WinGetHandle ( "[ACTIVE]" ) <> $hWinHandle Then WinActivate ( $hWinHandle ) EndIf EndFunc This has solved my issue. Thanks anyway. Edited November 21, 2020 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted November 21, 2020 Author Posted November 21, 2020 (edited) My issue solved but If I'm SPamming click I'm still loosing focus probably because of the normal sends used. BTW I cannot ControlSend in this case. If you have a trick to help me to be 100% reliable practicing this task I take all attemps !!! I tried that : Same I lost focus If I click out of windows. Func _SendApRePrPa ( $a = "" ) ; An exemple of custom Send. ClipPut($a) _SecuriteAntiPerteFocusCheck () SendKeepActive ( $hWinHandle ) Send("^v") ClipPut ($hBefore) EndFunc Func _OnDesactiveLaSecu () ;Function to free the current windows Handle From sendkeepactive SendKeepActive ( "" ) EndFunc Func _SecuriteAntiPerteFocus () ; Function to get widows Handle $hWinHandle = WinGetHandle ( "[ACTIVE]" ) EndFunc Func _SecuriteAntiPerteFocusCheck () ; Function to check if we are still in the same windows handle before send If $hWinHandleCheck = WinGetHandle ( "[ACTIVE]" ) <> $hWinHandle Then WinActivate ( $hWinHandle ) EndIf EndFunc How I'm using these functions : Func Func1000 () _CleanAndWait () _SendAvSaPrPa ($MSymp0) Send("{ENTER}") Send("{ENTER}") Send("{ENTER}") _Send ( $MSymp1 ) Send("{ENTER}") _Send ( $MSymp2 ) Send("{ENTER}") _SendApRePrPa ( $MSymp3 ) Send("{ENTER}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{END}") _OnDesactiveLaSecu () Menu () EndFunc They had admin rights in win 7. And they haven't got them anymore in Windows 10. So BlockInput was a good option but not possible here anymore... I'm not able to get 100% reliable script depending on if the user make a double click by mistake or in that kind of cases/. Edited November 21, 2020 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Nine Posted November 21, 2020 Posted November 21, 2020 (edited) Look at my BlockInput UDF in my sig. It will not show UAC and it is really fast (takes only few ms). I am sure you would get more help if you could make a replicable script (using notepad). Well you already know that, right ? BTW this statement is badly formatted : If $hWinHandleCheck = WinGetHandle ( "[ACTIVE]" ) <> $hWinHandle Then Edited November 21, 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
GokAy Posted November 21, 2020 Posted November 21, 2020 Hey, Excuse me if I am asking noobish questions Is ControlSend (or perhaps ControlSendText) the Windows SendMessage equivalent in AutoIt? What type of data do you normally send? Maybe you can use SendMessage(WM_SETTEXT) to a dummy/hidden InputBox ? And check for changes in it and perform a certain algorithm, instead of all the send()s. The receiving window should be able to process all without being active, no? The receiving side then, if needed, can send a "action completed" kind of message to the sender window, etc. So further actions can be sent if things get some time to process. Also, maybe you can get the time whenever clicks/or events happen, and reject if the consecutive clicks are within a certain time interval instead of blocking stuff all together. You could keep different times for different events this way in the case they can be run independently of each other (different windows perhaps?). Just ideas here.
caramen Posted November 21, 2020 Author Posted November 21, 2020 (edited) 1 hour ago, Nine said: Well you already know that, right ? 😅 Yeah... but well. If I would have did that I would have know why I was loosing focus so you know that's not fun x). True beginner mistake, this is what I did after ... and then I see why I was loosing focus. I commented the line that is getting the wingethandle in the first function. (She was too big, so I don't put her here). !Good example for beginners that read this subject! I feel myself inside. I'm far from the skill of other helpers here. So.... first, thanks for your splendid answer like always 9. EDIT : I will check your blockinput UDF for sure ! And second I won't forget to do a proper reproducer next time, even If I think it is easy script that does not require it. @GokAy ControlSend is when you can use classic ControlGetHandle or GUICtrlGetHandle which was not the case here because I'm manipulating the kind of windows that does not return the correct wanted handle using these functions. In my case it would have been a MEGA pain to do it with controlsend and UIA for a so easy task. Edited November 21, 2020 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted November 21, 2020 Author Posted November 21, 2020 (edited) 1 hour ago, Nine said: BTW this statement is badly formatted : If $hWinHandleCheck = WinGetHandle ( "[ACTIVE]" ) <> $hWinHandle Then I did that for this. After made the correct reproducer I figured it out. Func _SecuriteAntiPerteFocusCheck () $hWinTitleCheck = WinGetTitle ( "[ACTIVE]" ) ConsoleWrite ("Check = "&$hWinTitleCheck&@CRLF) If $hWinTitleCheck <> $hWinTitle Then WinActivate ( $hWinTitle ) ConsoleWrite ("_SecuriteAntiPerteFocusCheck = Fenêtre NON identique"&@CRLF) Else ConsoleWrite ("_SecuriteAntiPerteFocusCheck = Fenêtre identique"&@CRLF) EndIf EndFunc Edited November 21, 2020 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Nine Posted November 21, 2020 Posted November 21, 2020 Yep, I had to do something similar in the past. WinActivate can take quite some time, uselessly if it is already active. I just tested with new beta and WinActivate is still somewhat slow. “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
caramen Posted November 21, 2020 Author Posted November 21, 2020 (edited) I have lot of things open rn, may it depend on how many win/invisible win have to be checked. no time to test Edited November 21, 2020 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
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