Jump to content

wait for text input to continue?


Recommended Posts

Hi all... I need some help.

I've search all over this forum and can't find an answer that comes close to my questions. I have 2 issues.

I use a script to deactivate user accounts in my companies Electronic Medical Records system and the script takes me to the user selection screen where I have to input the users name. The script should then continue on with the deactivation process.

I need to be able to pause the script... input the users name... hit enter and the script continues through to completion.

Here is the code I use... I used the macro recorder to record the steps here. You'll see where I input a sample username when I recorded it below. "CHRILEE" on line 16 in SciTE.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=..\Program Files\AutoIt3\Icons\au3.ico
#AutoIt3Wrapper_outfile=Deactivate.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
WinWait("CHA - Production Environment - CHRISTOPHER LEBLANC - TEST DEPT", "")
If Not WinActive("CHA - Production Environment - CHRISTOPHER LEBLANC - TEST DEPT", "") Then WinActivate("CHA - Production Environment - CHRISTOPHER LEBLANC - TEST DEPT", "")
WinWaitActive("CHA - Production Environment - CHRISTOPHER LEBLANC - TEST DEPT", "")
Send("{TAB}{SHIFTDOWN}{TAB}{SHIFTUP}{ENTER}")
WinWait("User Selection","")
If Not WinActive("User Selection","") Then WinActivate("User Selection","")
WinWaitActive("User Selection","")
Send("chrilee{ENTER}")
Send("{ALTDOWN}{DOWN}{ALTUP}{RIGHT}{SPACE}{SHIFTDOWN}9{SHIFTUP}inactive{SHIFTDOWN}0{SHIFTUP}{TAB}inactive{TAB}inactive{SPACE}employee{TAB}{ALTDOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ALTUP}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{DELETE}{DOWN}{TAB}{TAB}{TAB}{TAB}{DELETE}{ALTDOWN}f{ALTUP}")

As you can see I have a very inefficient section of code at the end there where I basically hit Down then Delete 20 times in a row. This is to clear out a field that could either be 1 item or 20 depending on the users duties here. Is there a way to loop the sequence {DOWN}{DELETE} 20 times without retyping it like that? it works as it is just fine..but it's messy code I'd rather do away with.

Thanks in advance for any help you can give. I'll attach the actual file also.

Deactivate.au3

Link to comment
Share on other sites

Even if you get it working, that is going to be very fragile and error prone. You should take a little time to learn how to get control IDs and/or ClassNameNN identities of the controls you want (use the AutoIt Window Info Tool, AU3Info.exe) and do your data entry with ControlSend() if at all possible.

For example, what you posted would start out like this (with fictitious id info in $idEditUserButton and $idUserNameInput):

Global $hMain, $sMainTitle = "CHA - Production Environment - CHRISTOPHER LEBLANC - TEST DEPT"
Global $idEditUserButton = "[CLASS:Button; INSTANCE:1]" ; Delete User button ID
Global $hUserSel, $sUserTitle = "User Selection"
Global $idUserNameInput = "[CLASS:Input; INSTANCE:1]"

WinWait($sMainTitle, "")
$hMain = WinGetHandle($sMainTitle, "")
ControlClick($hMain, "", $idEditUserButton)
WinWait($sUserTitle, "")
$hUserSel = WinGetHandle($sUserTitle, "")
ControlSend($hUserSel, "", $idUserNameInput, "chrilee")
ControlSend($hUserSel, "", $idUserNameInput, "{ENTER}")

; ... etc.

Notice that actions are taken directly on the controls involved without tabbing around the GUI to get there. The correct control identities would come from AU3Info.exe.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Even if you get it working, that is going to be very fragile and error prone. You should take a little time to learn how to get control IDs and/or ClassNameNN identities of the controls you want (use the AutoIt Window Info Tool, AU3Info.exe) and do your data entry with ControlSend() if at all possible.

For example, what you posted would start out like this (with fictitious id info in $idEditUserButton and $idUserNameInput):

Global $hMain, $sMainTitle = "CHA - Production Environment - CHRISTOPHER LEBLANC - TEST DEPT"
Global $idEditUserButton = "[CLASS:Button; INSTANCE:1]" ; Delete User button ID
Global $hUserSel, $sUserTitle = "User Selection"
Global $idUserNameInput = "[CLASS:Input; INSTANCE:1]"

WinWait($sMainTitle, "")
$hMain = WinGetHandle($sMainTitle, "")
ControlClick($hMain, "", $idEditUserButton)
WinWait($sUserTitle, "")
$hUserSel = WinGetHandle($sUserTitle, "")
ControlSend($hUserSel, "", $idUserNameInput, "chrilee")
ControlSend($hUserSel, "", $idUserNameInput, "{ENTER}")

; ... etc.

Notice that actions are taken directly on the controls involved without tabbing around the GUI to get there. The correct control identities would come from AU3Info.exe.

:)

Yes I can see how that would be very beneficial. Especially if the layout of the gui changes with the next service upgrade. So this code you wrote here will do what exactly? Forgive my noob-ness to all of this but it looks like a cleaner version of what I have now but it will still ploy right through that name input field rather than let me put the name in. Am I off on my analysys?

Link to comment
Share on other sites

Yes I can see how that would be very beneficial. Especially if the layout of the gui changes with the next service upgrade. So this code you wrote here will do what exactly? Forgive my noob-ness to all of this but it looks like a cleaner version of what I have now but it will still ploy right through that name input field rather than let me put the name in. Am I off on my analysys?

What I posted was only intended to demo more reliable use of ControlSend(). I did hard code the values like "chrilee". To pause for input on that, you would just do this:
$sInputName = InputBox("Test", "Input a user name:  ", "")
ControlSend($hUserSel, "", $idUserNameInput, $sInputName)

I actually like to embellish it a bit:

While 1
    $sInputName = ""
    $sInputName = InputBox("Test", "Input a user name:  ", "")
    If @error <> 0 Then Exit ; User closed the box without input, exit on error
    If $sInputName <> "" Then ExitLoop ; Got input from user
WEnd
ControlSend($hUserSel, "", $idUserNameInput, $sInputName)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

To quote Yoda: "{Sighs} Hear you nothing that I say...?" :)

That part would be like this:

Global $hUserSel, $sUserTitle = "[CLASS:ThunderRT6FormDC; TITLE:User Selection]"
Global $idUserNameInput = "[CLASS:ThunderRT6TextBox; INSTANCE:1]"

; ...

WinWait($sUserTitle, "")
$hUserSel = WinGetHandle($sUserTitle, "")
$sInputName = InputBox("Test", "Input Name: ")
ControlSend($hUserSel, "", $idUserNameInput, $sInputName)

; ...

"{Tab}", "{Down}", Send(), the ways of the Dark Side are they!

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...