Jump to content

[Help] Script to digitally sign documents


JohnS
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...