Jump to content
Macro Express Forums

Text input on a locked workstation


Recommended Posts

Hi Guys,

 

Just signed up, hoping someone would be able to help me out!

 

I'm trying to use macro express to shutdown a program, launch it again, enter in a username-password and hit enter.

 

My problem is that even though the program shutdowns and restarts- none of the text entries (username and password) work.

 

When I log back in to the workstation in morning the program is open and waiting for the username and password to be entered.

 

The macro works perfectly when I test run it while logged into the system.

 

Below is the macro. Any help would be appreciated.

 

Thanks

 

AtinK

 

<IF PROGRAM Option="\x01" Program="XYZ"/>
<TERMINATE PROCESS Window="FALSE" Name="XYZ" Partial="TRUE" Wildcards="TRUE" Timeout="1000"/>
<END IF/>
<DELAY Flags="\x01" Time="5"/>
<LAUNCH PROGRAM AND ACTIVATE WINDOW Title="XYZ" Exact_Match="FALSE" Wildcards="FALSE" Path="C:\\Program Files\\XYZ.exe" Mode="\x00" Default_Path="TRUE" Wait="1" Wait_For_Program="12"/>
<IF NOT PROGRAM Option="\x00" Program="XYZ.EXE"/>
<WINDOW ACTIVATE Title="XYZ" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
<END IF/>
<WINDOW ACTIVATE Title="XYZ" Exact_Match="FALSE" Wildcards="FALSE"/>
<DELAY Flags="\x01" Time="3"/>
<TEXT TYPE Action="0" Control="%C[1]%" Text="username" _PROMPT="0x0004"/>
<DELAY Flags="\x01" Time="2"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<DELAY Flags="\x01" Time="2"/>
<TEXT TYPE Action="0" Text="password"/>
<DELAY Flags="\x01" Time="2"/>

Link to comment
Share on other sites

Looking at your code now. Some random thoughts.

 

  1. You should use the code tags here in the forum. Checkout the button <>. Also it's nice to have both the code as you have but also right click and opt to copy command text a paste than in another code box. Easier for us to follow.
  2. You should recommend cleaning up your code. You can put multiple Text Type keystrokes in the dialog. IE instead of 3 commands make 1 with <space><tab><space>. And what's with noting more than a space? EG line 2. Doesn't seem necessary. I'd start by eliminating them.
  3. You don't have to test if the program is focused. If it's not it will just refocus the window.
  4. Why do you activate the window twice? Once in the condition.
  5. Why the big 2 second delays?
  6. It seems all of those lines could be distilled to 3 lines. Terminate, Launch and activate, and one texttype with name, tab, and password. Why does that not work. Sorry, I'd make an example but this stupid form will not let me paste anymore.

The superfluous space TextTypes would be my first suspicion. After that I'd want to verify that under normal circumstances the program's user name field is focused. You might need to focus it first.

It's a little bit of an advanced technique but if it were me I'd use controls and send the text to controls. Maybe it's too soon for that but you should eventually try to do it that way. We can help you learn that if you're interested.

Link to comment
Share on other sites

Oh, I'm sorry. I just realized the title of your post. If the workstation is locked no GUI activities will work. And it's not MEP's fault. It's because, well, in a sense they do not exist. Or more accurately are in a suspended state. IE you can't do any user input kind of things while the workstation is locked like moving the mouse, clicking, or typing.

Link to comment
Share on other sites

Not that I'm aware of. That's part of the whole point. It's a security measure. It needs a CTRL+ALT+DEL and credentials assuming you're on a Domain. They don't want software to be able to do this or it would be a huge security vulnerability.

 

Disconnected Remote Desktop session are the same way.

Link to comment
Share on other sites

is there a way to unlock workstation and run macro?

 

Yes, but it's a little complicated!

Here is a summary of the steps needed. If you're interested in the detail, please let me know.

 

- Run a (I suggest password-protected to prevent others looking at the code) macro (scheduled to run at a specific time) to:

- - place the machine in a state where it won't ask for a password when restarting (write values to the registry)

- - reboot

- Using a utility you can download for free, restart the machine and have MEP start a tailored startup macro to:

- - reset the machine state to asking for a password

- - run the macro you describe above to close and relaunch your app and enter a userid and password

 

Your special startup macro can be run when the relevant registry value you wrote exists.

-

Link to comment
Share on other sites

AtinK: You could use the Windows Task Scheduler to run a macro. When you define a task in the scheduler you can specify that it needs to log in to perform the task. For the process you can either specifiy the Macro Express Player (macexp.exe) or the smaller launcher (meproc.exe) and use a parameter that looks something like "/AYourMacro".

Cory: After reading your critique of AtinK's macro I decided to look at it. For anyone else interested, here it is in human readable form:

If Program "XYZ" is running
  Terminate Process: XYZ
End If
Delay: 5 seconds
Launch Program and Activate Window: Program "XYZ.exe", Parameters "", Window "XYZ"
If Not Program "XYZ.EXE" is focused
  Window Activate: XYZ
End If
Window Activate: XYZ
Delay: 3 seconds
Text Type (Simulate Keystrokes): username
Delay: 2 seconds
Text Type (Simulate Keystrokes): <TAB>
Delay: 2 seconds
Text Type (Simulate Keystrokes): password
Delay: 2 seconds

Cory, I rarely disagree with your analysis but in this case ...

 

AtinK, The only change I would make is to remove the second "Window Activate" command. That one IS unnecessary. The remainder of the macro I would leave as is until I was certain that it worked. This macro looks just like how I would write it before optimization. Once the macro is working you can either reduce the amount of delay or combine "Text Type" commands.

 

For the record, this:

If Not Program "XYZ.EXE" is focused
  Window Activate: XYZ
End If

is a published trick to speed up your macro. The "Window Activate" command takes a relatively long time to perform. By checking you can you can avoid the Window Activate command if the window is already focused.

Link to comment
Share on other sites

For the record, this:

 

If Not Program "XYZ.EXE" is focused  Window Activate: XYZEnd If
is a published trick to speed up your macro. The "Window Activate" command takes a relatively long time to perform. By checking you can you can avoid the Window Activate command if the window is already focused.
Thanks, never knew that. Could explain some slow performing macros of mine. It does seem surprising though. Do I have it right. Are you saying that the Window Activate command takes a significant time to determine whether the target window is active? IOW, significantly longer than that 3-line substitute?

 

BTW, I'd say that the most frequent flaw in my macros appear related to Window Activate and Wait for Window. Often I have to replace them with simple longish delays.

 

Terry, East Grinstead, UK

Link to comment
Share on other sites

Periodically we find performance benefits by using different techniques as in this case. If someone was interested I'd be happy to create an archive of user contributed examples on my webpage. I was thinking of doing exactly this a while back to demonstrate the speed benefit of a binary search given how slowly MEP loops thru arrays. If anyone is ever interested let me know as I'd be happy to host and collaborate.

Link to comment
Share on other sites

Thanks guys for responses.

 

Just to let you know I purchased an auto login tool that logs me in just before the macro is scheduled to run. But no luck. Any suggestions?

 

Cheers

I did outline a solution above - it's up to you to request details if you're interested.

Link to comment
Share on other sites

Thanks Paul. The auto log on tool logs me into windows successfully. After the login, I've scheduled a task (windows scheduled tasks) to restart MEP. The macro activation method I've used is 'Process Event' - When process starts running (MACEXP.EXE). But the macro doesn't run.

 

How do I get it to be a "special start up macro" as you suggested?

 

Thanks again for you help with this!

Link to comment
Share on other sites

How do I get it to be a "special start up macro" as you suggested?

 

Thanks again for you help with this!

 

Schedule it to run when MEP starts - and you'll need to be able to distinguish between normal mode, and the special mode created by your auto log on tool, so that you run your desired macro only in this special mode.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...