[jawsscripts] Re: Close window with SendMessage function?

  • From: "Donald Marang" <donald.marang@xxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Fri, 14 Aug 2009 17:09:59 -0400

Perfectly reasonable.  I will attempt a few examples.

String Function ReformatPhoneNumber (string sNumber)
;Outputs my preferred phone number format: 800-555-8355 (Tell Me service)
Let sNumber = StringReplaceSubstrings (sNumber, "(", Null ())
Let sNumber = StringReplaceSubstrings (sNumber, ")", Null ())

Let sNumber = StringReplaceChars (sNumber, " ", "-")

Return sNumber
EndFunction

Then in another function or script you can use this functions as many times 
as you like with a statement such as:
Let sPhone = lvGetItemText (hWnd, iCurrentChild, 2)
Let gsVCAContactNumber = ReformatPhoneNumber (sPhone)

This will grab the string in the 2nd Colum of the selected item in a list 
view and convert it to the desired format.  I store this in a global 
variable so it can be used later by another script.

Besides being more understandable and reusable, functions are  also more 
maintainable.  If I decided I now prefer all my phone numbers read to me as 
"800.555.8355", all the necessary changes can be made in one place.  Nothing 
else should be effected.

Many functions will have a return type of Int and have both a Return True 
and Return False statements inside the function based on some conditional 
logic.  Make sure that all conditions return a value and that the function 
does not exit without assigning a return value.  Note that the value after 
the Return keyword does not always have to be a variable. You can also 
directly return a value or the return value of another function, such as:
Return True
Return 5
Return StringReplaceChars (sNumber, " ", "-")


Another hard concept for some to wrap their heads around is am statement 
like:
Let i = i + 1

This is impossible in Algebra and the natural world, but is common in the 
"virtual land" of computer programming!  In programming languages, the equal 
sign is a  symbol to store a value into a variable.  Variables in computer 
terms amount to be a memory location or processor register.  Therefore the 
the above statement does not say that the value of i is equal to the value 
of i plus 1.  It actually says to take the value stored in the variable 
stored in memory, which is located with the pointer referred to as i, and 
add the integer 1 to this value.  This is communally called incrementing. 
Then the result is stored back in the same memory location, again referred 
to as i.


hth,
Don Marang


----- Original Message ----- 
From: "Geoff Chapman" <gch@xxxxxxxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Friday, August 14, 2009 9:10 AM
Subject: [jawsscripts] Re: Close window with SendMessage function?


> ah, ok. thanks Don.
> hmmmm, now perhaps this gives me a chance to display my even further
> embarrassing ignorance, and ask a question that's been kinda lurking 
> around
> in my non-informed mind for ages. if anyone would care to stoop so low to
> explain? <grin.>
> but, ... ok this is kind of pretty embarrassing to admit,
> but, I've never quite got my head around this concept yet, of functions,
> actually returning, values.
> especially user built ones.
> and in what specific circumstances I might find this useful?
>
> like in your example below Don, you indicate that SendMessage function,
> returns, an integer value?  Presumably maybe at a guess, perhaps something
> like 1 if it thought it was successful at delivering the message,
> and 0 if not maybe?  I don't know.
> ... whatever it is, how exactly might I usefully utilize/implement such a
> feature, as the value that a given function may return like this?
>
> Like I understand the concept of, "return," in the middle of a
> scrip/function, terminating the execution/running of the script/function 
> at
> that point,
> I've been able to successfully utilize that much before,
> But I don't reeeeally yet understand totally, what the fsdn means when it
> says, that it also,
> returns, "the value of an expression, if given, to the calling function.
>
> would anyone care to either posit a bit of exemplery code which might
> illustrate, or point me to a place I might find some written? that would 
> be
> sooooo excellent.
> Like sometimes I have seen the keyword, Return, in the middle of a script 
> or
> function, with things in parenthisies after it, like (0) or some other
> value?
> so like I mean do they do that, when they want the function, to carry with
> it, or return, if I'm using the term correctly here,  a certain value if 
> the
> function quits at that point? like in the midst of an if condition say?
> whereas if the condition wasn't met and the
> execution went further, resulting in more processing, that entire function
> might return some different value?
> am I halfway on the right track with how this works?
>
>
> thanks.
> and sorry for the kinda low-life question.
> i do really have a lot to learn eh.
>
> geoff c.
>
>
>
> ----- Original Message ----- 
> From: "Donald Marang" <donald.marang@xxxxxxxxx>
> To: <jawsscripts@xxxxxxxxxxxxx>
> Sent: Friday, August 14, 2009 12:18 PM
> Subject: [jawsscripts] Re: Close window with SendMessage function?
>
>
>> Me either!  I followed the thread back where a similar postMessage call
> was
>> suggested.  It works perfectly!  I had previously had a function that
>> literally attempted five different ways to close the app and still failed
>> occasionally.  I will repeat the call here:
>> postMessage(ghVCAMain, 0x10, 0, 0) ; 0x10 is WM_Close
>>
>>
>> Don Marang
>>
>>
>> ----- Original Message ----- 
>> From: "Bryan Garaventa" <bgaraventa11@xxxxxxxxxxxxxx>
>> To: <jawsscripts@xxxxxxxxxxxxx>
>> Sent: Thursday, August 13, 2009 9:46 PM
>> Subject: [jawsscripts] Re: Close window with SendMessage function?
>>
>>
>> > That is sort of weird... I was able to close an app's main window by
> using
>> > SendMessage(GetAppMainWindow(GetFocus()), 0x10, 0, 0)
>> > I'm not sure what could be happening.
>> >
>> > ----- Original Message ----- 
>> > From: "Donald Marang" <donald.marang@xxxxxxxxx>
>> > To: <jawsscripts@xxxxxxxxxxxxx>
>> > Sent: Thursday, August 13, 2009 6:20 PM
>> > Subject: [jawsscripts] Re: Close window with SendMessage function?
>> >
>> >
>> >>I did see this function in that list.  However, functions that I have
>> >> written and merged with default.jss also show up in this list.  I also
>> >> have
>> >> several tools added to my JAWS installation.  I was wondering if I
> would
>> >> require other users to have certain tools installed if I distribute 
>> >> any
>> >> scripts.  So far, it is not closing any windows or applications and
>> >> always
>> >> returns 0.
>> >>
>> >> Don Marang
>> >>
>> >>
>> >> ----- Original Message ----- 
>> >> From: "Bryan Garaventa" <bgaraventa11@xxxxxxxxxxxxxx>
>> >> To: <jawsscripts@xxxxxxxxxxxxx>
>> >> Sent: Thursday, August 13, 2009 6:42 PM
>> >> Subject: [jawsscripts] Re: Close window with SendMessage function?
>> >>
>> >>
>> >>> Nope, you should see SendMessage in your JAWS functions list, as well
> as
>> >>> PostMessage, which provides limited access to the API through JAWS.
>> >>>
>> >>> ----- Original Message ----- 
>> >>> From: "Donald Marang" <donald.marang@xxxxxxxxx>
>> >>> To: <jawsscripts@xxxxxxxxxxxxx>
>> >>> Sent: Thursday, August 13, 2009 3:28 PM
>> >>> Subject: [jawsscripts] Re: Close window with SendMessage function?
>> >>>
>> >>>
>> >>>> Is the SendMessage function a built-in JAWS function or is it part 
>> >>>> of
>> >>>> another package, such as HomerKit?  Do you need to load or provide
> any
>> >>>> other
>> >>>> commands first such as an Use statement?
>> >>>>
>> >>>> Don Marang
>> >>>>
>> >>>>
>> >>>> ----- Original Message ----- 
>> >>>> From: "Jim Bauer" <holdsworthfan@xxxxxx>
>> >>>> To: <jawsscripts@xxxxxxxxxxxxx>
>> >>>> Sent: Thursday, August 13, 2009 4:46 PM
>> >>>> Subject: [jawsscripts] Re: Close window with SendMessage function?
>> >>>>
>> >>>>
>> >>>>> sendMessage(hwnd, 0x0112, 0x000F, 0)
>> >>>>> The populated parameters are wm_syscommand and wm_close,
> respectively.
>> >>>>>>-----Original Message-----
>> >>>>>>From: jawsscripts-bounce@xxxxxxxxxxxxx
>> >>>>>>[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Bryan
> Garaventa
>> >>>>>>Sent: Tuesday, August 11, 2009 2:13 PM
>> >>>>>>To: jawsscripts@xxxxxxxxxxxxx
>> >>>>>>Subject: [jawsscripts] Close window with SendMessage function?
>> >>>>>>
>> >>>>>>Does anyone know what the correct parameters are for forcing a
> window
>> >>>>>>to
>> >>>>>>close using the SendMessage function? The window handle is pretty
>> >>>>>>obvious,
>> >>>>>>but I'm not sure what the other constants should be.
>> >>>>>>Thanks,
>> >>>>>>Bryan
>> >>>>>>__________
>> >>>>>>Visit and contribute to The JAWS Script Repository
>> >>>>>>http://jawsscripts.com
>> >>>>>>
>> >>>>>>View the list's information and change your settings at
>> >>>>>>http://www.freelists.org/list/jawsscripts
>> >>>>>>
>> >>>>>>
>> >>>>>>__________
>> >>>>>>Visit and contribute to The JAWS Script Repository
>> >>>>>>http://jawsscripts.com
>> >>>>>>
>> >>>>>>View the list's information and change your settings at
>> >>>>>>http://www.freelists.org/list/jawsscripts
>> >>>>>>
>> >>>>>>
>> >>>>>>This e-mail and any attachments to it are confidential and are
>> >>>>>>intended
>> >>>>>>solely for use of the individual or entity to whom they are
> addressed.
>> >>>>>>If
>> >>>>>>you have received this e-mail in error, please notify the sender
>> >>>>>>immediately and then delete it.  If you are not the intended
>> >>>>>>recipient,
>> >>>>>>you must not keep, use, disclose, copy or distribute this e-mail
>> >>>>>>without
>> >>>>>>the author's prior permission.  The views expressed in this e-mail
>> >>>>>>message
>> >>>>>>do not necessarily represent the views of Highmark Inc., its
>> >>>>>>subsidiaries,
>> >>>>>>or affiliates.
>> >>>>>>__________
>> >>>>>>Visit and contribute to The JAWS Script Repository
>> >>>>>>http://jawsscripts.com
>> >>>>>>
>> >>>>>>View the list's information and change your settings at
>> >>>>>>http://www.freelists.org/list/jawsscripts
>> >>>>>
>> >>>>> __________
>> >>>>> Visit and contribute to The JAWS Script Repository
>> >>>>> http://jawsscripts.com
>> >>>>>
>> >>>>> View the list's information and change your settings at
>> >>>>> http://www.freelists.org/list/jawsscripts
>> >>>>>
>> >>>>
>> >>>> __________
>> >>>> Visit and contribute to The JAWS Script Repository
>> >>>> http://jawsscripts.com
>> >>>>
>> >>>> View the list's information and change your settings at
>> >>>> http://www.freelists.org/list/jawsscripts
>> >>>>
>> >>>
>> >>> __________
>> >>> Visit and contribute to The JAWS Script Repository
>> >>> http://jawsscripts.com
>> >>>
>> >>> View the list's information and change your settings at
>> >>> http://www.freelists.org/list/jawsscripts
>> >>>
>> >>>
>> >>
>> >> __________
>> >> Visit and contribute to The JAWS Script Repository
> http://jawsscripts.com
>> >>
>> >> View the list's information and change your settings at
>> >> http://www.freelists.org/list/jawsscripts
>> >>
>> >
>> > __________
>> > Visit and contribute to The JAWS Script Repository
> http://jawsscripts.com
>> >
>> > View the list's information and change your settings at
>> > http://www.freelists.org/list/jawsscripts
>> >
>>
>> __________
>> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>>
>> View the list's information and change your settings at
>> http://www.freelists.org/list/jawsscripts
>>
>
> __________
> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
> 

__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

View the list's information and change your settings at 
http://www.freelists.org/list/jawsscripts

Other related posts: