JohnS Posted October 22, 2019 Share Posted October 22, 2019 Hi, Last time I was here was nine years ago, at a time when I was learning to use Autoit. Then my life took a turn and I stopped. Now I need some help again. My organization makes me digitally sign my documents with a password. Before I would be able to sign 20 or 30 documents just by entering only once the password. Now I need to insert the password for every single document. So it goes like this: 1- I select all the documents I want to sign and give the order to sign them. 2- A window will appear. 3- I insert the password and click the OK button. 4- The window disappears. 5- The window appears. Repeat 3 to 5 I know this works for a single document: WinWait("Segurança do Windows","Memorizar credenciais") If Not WinActive("Segurança do Windows","Memorizar credenciais") Then WinActivate("Segurança do Windows","Memorizar credenciais") WinWaitActive("Segurança do Windows","Memorizar credenciais") ;Wait till window is shown Send("MY PASSWORD") ControlClick("Segurança do Windows", "Memorizar credenciais", "Button2") ;Click the OK Button to Confirm Password Then I copied some code from the forum, because I wanted a loop and to be able to terminate the script after all the signing was done: https://www.autoitscript.com/forum/topic/21810-how-do-i-make-a-script-repeat/?do=findComment&comment=151054 And got this: #include <GuiConstants.au3>;Functions needed for most GUI Code GuiCreate("Your GUI", 472, 188);Create GUI Window with the width of 472 and height of 188 $Button_1 = GuiCtrlCreateButton("Exit", 10, 130, 130, 50);Button_1 is the Exit Button $Button_2 = GuiCtrlCreateButton("Insert Password", 250, 100, 210, 80); Button_2 is the Execute Script function GuiSetState() While 1;your LOOP $msg = GuiGetMsg();retrieves the button or control that was pressed Select; starts a case statement Case $msg = $GUI_EVENT_CLOSE;case statement, its like an if statement but better when you have alot of statements ExitLoop; If the program is exited it will exit the loop. Case $msg = $Button_1 ExitLoop;Exits the Loop Case $msg = $Button_2 ExecuteScript(); goes to the Execute Script function EndSelect; ends the case statements WEnd Func ExecuteScript();Creats the Execute Script Function ;Your Code WinWait("Segurança do Windows","Memorizar credenciais") If Not WinActive("Segurança do Windows","Memorizar credenciais") Then WinActivate("Segurança do Windows","Memorizar credenciais") WinWaitActive("Segurança do Windows","Memorizar credenciais") ;Wait till window is shown Send("MY PASSWORD") ControlClick("Segurança do Windows", "Memorizar credenciais", "Button2") ;Click the Yes Button to Confirm Password EndFunc But only the "Exit" button is working. The "Insert password" does nothing and after clicking it the "Exit" button does not work anymore. Can anyone help me, please? Link to comment Share on other sites More sharing options...
Nine Posted October 22, 2019 Share Posted October 22, 2019 WinWait will block the script until the window exists. That's why the exit button doesn't work after using the insert password button... “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
JohnS Posted October 23, 2019 Author Share Posted October 23, 2019 Thanks, Nine. WinWait pauses the script, as the help file mentions, so that is the reason. I could add a timeout for the WinWait command, since 0 is the default, but is there a way to cancel the script at any given time, mainly when clicking the "Exit" button? Link to comment Share on other sites More sharing options...
SkysLastChance Posted October 23, 2019 Share Posted October 23, 2019 You could use a Hotkey HotKeySet("{ESC}", "Terminate") Func Terminate() Exit 0 EndFunc You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott 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