Page 1 of 1 1
Topic Options
#80969 - 2002-06-19 12:50 AM setfocus and send keys
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
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...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#80970 - 2002-06-19 01:33 AM Re: setfocus and send keys
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
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
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#80971 - 2002-06-19 01:58 AM Re: setfocus and send keys
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#80972 - 2002-06-19 02:36 AM Re: setfocus and send keys
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
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.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#80973 - 2002-06-19 04:55 AM Re: setfocus and send keys
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
see http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=2;t=003501

for continuance...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#80974 - 2002-06-20 12:28 AM Re: setfocus and send keys
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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,
_________________________
!

download KiXnet

Top
#80975 - 2002-06-19 01:39 PM Re: setfocus and send keys
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
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.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#80976 - 2002-06-19 01:58 PM Re: setfocus and send keys
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#80977 - 2002-06-19 02:57 PM Re: setfocus and send keys
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
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).
Top
#80978 - 2002-06-19 03:07 PM Re: setfocus and send keys
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#80979 - 2002-06-19 03:15 PM Re: setfocus and send keys
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
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.
Top
#80980 - 2002-06-19 03:46 PM Re: setfocus and send keys
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#80981 - 2002-06-19 03:50 PM Re: setfocus and send keys
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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 ]
_________________________
!

download KiXnet

Top
#80982 - 2002-06-19 03:55 PM Re: setfocus and send keys
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
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


Top
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.07 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org