Radimus
(KiX Supporter)
2002-06-19 12:50 AM
setfocus and send keys

the biggest problem with setfocus, is that you can't get a return that the window has focus...

run "notepad.exe"
while not setfocus("untitled - notepad") loop
sendkeys("look, I finally have focus")

That is like the winwaitactive command in scriptit and autoit. I'd like to use that, but the management doesn't want to trust any 3rd party software (that can't be sued/held liable).

They didn't even want to use kixtart, untill I handed them a resource kit CD that said Microsoft and that kixtart was on it...


Kdyer
(KiX Supporter)
2002-06-19 01:33 AM
Re: setfocus and send keys

Hmm..

This seems to work..

code:
break on cls
run "notepad.exe"
setfocus("Untitled - Notepad")
;while not setfocus("Untitled - Notepad") loop
sendkeys("look, I finally have focus")

Kent


Radimus
(KiX Supporter)
2002-06-19 01:58 AM
Re: setfocus and send keys

but if the window isn't open yet.. process is still running, it doesn't pause/wait for it, nor return a code that it can't find it

part 2, it the ability to read some of the contents of that window.

Specifically for use in installing apps or completing forms


Les
(KiX Master)
2002-06-19 02:36 AM
Re: setfocus and send keys

SetFocus() will in fact return whether it was successful. Not in the same fashion as AutoIT but will if used in a loop. I do it in loops often. It certainly would be an improvement if it would return some of the text in the windo to discern windows with the same title as does AutoIT.

Radimus
(KiX Supporter)
2002-06-19 04:55 AM
Re: setfocus and send keys

see http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=2;t=003501

for continuance...


LonkeroAdministrator
(KiX Master Guru)
2002-06-20 12:28 AM
Re: setfocus and send keys

rad, there was one problem found and help line given (to me).
if you name windows the same, kix may get confused about to which set the focus.
help line was:
winzip32.exe /noqp /autoinstall

cheers,


Radimus
(KiX Supporter)
2002-06-19 01:39 PM
Re: setfocus and send keys

winzip was just an example... a easy program to install that I had available for development purposes.

I know all about ISS files, and the making of MSI packages, and command line options for certain apps.

I have serveral in house apps that are deployed with the installers provided with the development tool: VB, Access, whatever.

I am more concenrned with the functionality of setfocus and sendkeys than with a specific app...

Has any one played with pausing the kbd and mouse devices to block input.


LonkeroAdministrator
(KiX Master Guru)
2002-06-19 01:58 PM
Re: setfocus and send keys

rad, I didn't think you being a novice.

but, sendkey gives you the info wether it can set focus or not.
so, I don't see any other problem than if you have multiple windows named the same.


Chris S.
(MM club member)
2002-06-19 02:57 PM
Re: setfocus and send keys

Rad, would your management let you use the AutoItX dll? If so, you could incorporate it into your KiX scripts (and use the Block Input function as well).

Radimus
(KiX Supporter)
2002-06-19 03:07 PM
Re: setfocus and send keys

nope... no 3rd party shareware/freeware at all. only apps from 'reliable' sources.

If the app came as a reskit util, then they consider that as a blessing...

They allowed be to use scriptit as it says microsoft, but autoit is from an 'unknown' 3rd party. Even though they see that it looks to be functionally identical to scriptit, with more enhancements... scriptit was probably an 'old' version, before the author went his own way and improved it into autoit.

So my options are:
software from a 'reliable' source (that is also free)
scripting it with Kix (which I have pretty much done)

I was kind of hoping that there would be a COM method that would have more detail than the setfocus/sendkey methods


Chris S.
(MM club member)
2002-06-19 03:15 PM
Re: setfocus and send keys

No offense to you of course, but that is a ridiculous policy your management has adopted. Do they really think they'll be able to sue Microsoft if Internet Explorer 7.0 has a security bug that allows hackers into their system? They aren't protected any more by using Microsoft's free stuff (COM, WSH, IE, etc.) than they are by not using AutoIt. Of course, I'm probably preaching to the choir.

Radimus
(KiX Supporter)
2002-06-19 03:46 PM
Re: setfocus and send keys

from management today...
quote:

Kelly and Cook are going through the FEDs to get them to understand the problems of distribution of their program; that's why your input of problems and ideas for how they can "fix" it are so important. Arizona did an automated rollout, but they are a Novell network, and used ZENworks to make images for each of their OS's and then pushed them out....very time consuming. They use W95, W98, and some NT clients.

An industry standard compliant installation program would solve many problems, indeed.

We will not be using the autoit program. If you can use the scriptit's ase.scp that's OK. Joe will be getting the "must install by" deadline from Molly today or tomorrow.

It is a government org... virtually everything is stupid, but since we don't have the time/resources to evaluate/test/inspect every app, we assume that a app from a reliable sourse is reliable. CYA


LonkeroAdministrator
(KiX Master Guru)
2002-06-19 03:50 PM
Re: setfocus and send keys

nice.
so sweeeeeeet...

I love US.

btw, our government is using linux side by side with unix&win*

[ 19 June 2002, 15:51: Message edited by: Lonkero ]


Chris S.
(MM club member)
2002-06-19 03:55 PM
Re: setfocus and send keys

Well, you can use WSH AppActivate (available in WSH 2.0) to improve upon KiX's Setfocus...

quote:

The AppActivate method returns a Boolean value that identifies whether the procedure call is successful. This method changes the focus to the named application or window, but it does not affect whether it is maximized or minimized. Focus moves from the activated application window when the user takes action to change the focus (or closes the window).

In determining which application to activate, the specified title is compared to the title string of each running application. If no exact match exists, any application whose title string begins with title is activated. If an application still cannot be found, any application whose title string ends with title is activated. If more than one instance of the application named by title exists, one instance is arbitrarily activated.

Example:
code:
$rc=setfocus("Internet Explorer provided by The Relizon Company")
if @error<>0
? "Setfocus Failed"
endif
$WshShell=CreateObject("WScript.Shell")
$ActiveApp=$WshShell.AppActivate("Internet Explorer provided by The Relizon Company")
if $ActiveApp=-1
? "WSH Succeeded."
endif