The answers you were looking for...

Sunday, February 28, 2010

.HTA Secrets Revealed (of course, free of charge :)

Section 2 of 4 (chromeless window mouse drag / move)



Covered in this blog series: window drag, window minimize, launching Window’s default browser and using JavaScript and VBScript in the same document.


Various pieces of following information contain code and material discovered to work across all current versions of Windows as of February 2010. While some snippets are pseudo hacks and function properly as described, there isn’t any documentation from Microsoft about future support.



In 2009 I delved deep into the uncharted territory of chromeless HTAs, pushing it’s application powers to the limit. In the beginning stages of design I noticed that there were a few items of functionality unavailable to the HTA. The first one I noticed was the inability to window drag a chromeless HTA. Surely I had to be mistaken. Nonetheless, anyone running into the ‘access denied’ error while attempting to write a drag function knows full well where I’m coming from. After a little investigation it’s not hard to find that for security purposes, Microsoft has disabled such functionality. After further investigation, I noticed that the Internet’s popular HTA apps didn’t have the traditional mousedown / drag / release feature in their windows. Instead, they all had awkward work-arounds. Better yet, I couldn’t find a single instance of a chromeless HTA with a MINIMIZE button, nor access to the platform’s default browser. While I initially assumed this to be the an error, I declined to believe it until I could prove it.



After countless hours of research and testing, I verified what I had previously refused to believe. Still desirous of harnessing the power of the HTA, I decided to spend some quality time on real, viable solutions to these issues.



As any decent developer worth his salt knows, the best solution is always the simplest one. Complex work-arounds rarely function smoothly in the end. Below is the smooth and correct way to implement these functionalities into your HTA.



.HTA Chromeless Window Mouse Drag / Move Instructions

Download >>> example, documentation and instructions
[http://quio.me/_devbin/window_drag.zip]

[Note: download the above file to follow along with the instructions below]


With most all of the DOMs ‘drag’ functionality disabled in the HTA, it’s impossible to write a script to move the window in the HTA’s document flow. While there are a host of goofy and inane fixes that do nothing more than confuse the user, the solution I’ve crafted is rock-solid and ubiquitously supported.



The crux of the fix is to embed a modeless dialog in a separate HTA contained as a child within the primary HTA at the top of your chromesless window where the title bar would be. *Fhew* Then, with a mouse move event (an up and down event to capture and release also) track the movement of the modeless dialog and move the parent HTA window respectively. It sounds a bit difficult on the surface. However, the example is very straight forward.



(note: For sanity’s sake, I’ve labeled all objects and elements associated with the “title bar”, prefixed with either “tb" or "title” after the letter "q" for Quio.)



In the example download “window_drag” folder, all of the associated files for the example are contained in the root folder. For reference, there is a mirror of each file with the extension ".bak" The additional files in the “bin/” directory are simply for display and design purposes.



The Example Code:


1. In the “index.hta” file you’ll notice an embedded JavaScript tag referenceing “qtb.js” (abbr. for Quio Title Bar):


<script type="text/javascript" src="qtb.js"></script>




Here in the "qtb.js" file you will set the second embeded child HTA ("titlebar.hta" in this example)



In the "qtb.js" file you’ll also be setting the TOP, LEFT, HEIGHT and WIDTH of the modeless dialog which is placed on top of all other layer elements in the HTA.



2. In the “titlebar.hta” file you’ll be setting the “qtba.js” file which holds the mouse down, up and move events. The “titlebar.hta” file is also where the element is set for the mouse capture events and design control.



Note the “app_tb.css” file where the design elements and real estate dimensions are reiterated (match the settings in “qtb.js”)



That's all there is to it.



Recap:



While seemingly complex to configure on the surface, all of the programmatic coding and object/element placement within the DOM sit static in these example files and doesn't require any fundamental programming know-how.



File List and Function:



index.hta - Your main HTA file. This file sets-up “qtb.js”

qtb.js - This file sets up “titlebar.hta” as a modeless dialog. Also, dimensional settings for the title bar are set here.

titlebar.hta - This file sets up “qtba.js” and hold the title bar element which captures the mousedown event to trigger mousemove functionality.

qtba.js - This file is the foundation of the mouse events used for capturing, releasing and following the mouse cursor. I left a statement at the bottom of this file for those who have multiple window dialogs in their application to use.

app_tb.css - This file sets the design elements of the title bar. Utilizing background images, Microsoft filters and transitions (hey, its’ an HTA… why not take advantage), devising a design scheme to match your program’s interface seamlessly is unproblematic.



*** For minimizing HTA apps, reference the previous article at http://quiome.blogspot.com

*** Tomorrow’s article will cover accessing Windows default browser.



While the code for this application functionality is relatively small in scale, it entails several weeks of investigation,trial and error and know-how to program. If this helps you, your staff, or others complete a project, please feel free to donate to the cause. I'm also available for hire for micro projects and debugging. Please feel free to drop me a line for current availability and pricing [customapps@quio.me]









Saturday, February 27, 2010

.HTA Secrets Revealed

.HTA Secrets Revealed (of course, free of charge :)
Covered in this blog: chromeless HTA window drag, minimize, launching Window’s default browser and using JavaScript and VBScript in the same document.
Section 1 of 4

Various pieces of following information contain code and material discovered to work across all current versions of Windows as of February 2010. While some snippets are pseudo hacks and function properly as described, there isn’t any documentation from Microsoft about future support.

In 2009 I delved deep into the uncharted territory of chromeless HTAs, pushing it’s application powers to the limit. In the beginning stages of design I noticed that there were a few items of functionality unavailable to the HTA. The first one I noticed was the inability to window drag a chromeless HTA. Surely I had to be mistaken. Nonetheless, anyone running into the ‘access denied’ error while attempting to write a drag function knows full well where I’m coming from. After a little investigation it’s not hard to find that for security purposes, Microsoft has disabled such functionality. After further investigation, I noticed that the Internet’s popular HTA apps didn’t have the traditional mousedown / drag / release feature in their windows. Instead, they all had awkward work-arounds. Better yet, I couldn’t find a single instance of a chromeless HTA with a MINIMIZE button, nor access to the platform’s default browser. While I initially assumed this to be the case, I declined to believe it until I could prove it.

After countless hours of research and testing, I verified what I had previously refused to believe. Still desirous of harnessing the power of the HTA, I decided to spend some quality time on real, viable solutions to these issues.

As any decent developer worth his salt knows, the best solution is always the simplest one. Complex work-arounds rarely function smoothly in the end. Below is the smooth and correct way to implement these functionalities into your HTA.

1. Create the following object just before the closing </body> tag of the document you wish to be able to minimize:

<object Id="MyObj" CLASSID="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">

<param NAME="command" VALUE="minimize">

</object>


2. Create a JS function to reference the object

function minWin(){

MyObj.Click();

};



3. Create an element with an onclick event (click, up or down):


<span onmouseup="minWin()">

Click to minimize this window

</span>



Notes:

One of the most fascinating aspects of this set of code is that it’s undocumented (until now). From the Scripting Guy [
http://blogs.technet.com/heyscriptingguy/], to the ends of the Internet; while I was researching how to minimize a chromeless HTA, I continually ran into dead ends. Not only was I told by various sources that it was impossible, all the reasonable work-arounds didn’t fit any respectable programmers mantra of the simplest solution being the right solution.

The key to this solution is the inherent minimize Windows CLSID [WIKI link:
http://en.wikipedia.org/wiki/CLSID], ubiquitous throughout Microsoft’s OS functionality. Why this isn’t more widely disseminated, I’ll never know. It’s seemingly obvious to anyone in need.

Testing: I’ve found the code, in this example, to work on every Windows version to date; from Win98 – Win7.

While the above code is relatively small in scale, it entails several days of investigation and know-how. If this helps you, your staff, or others complete a project, please feel free to donate to the cause.
Stay tuned for our next blog on chromless HTA window drag…(due Monday 03/01/10)







Wednesday, February 24, 2010

I stole the Internet (well, borrowed it)

How to convert your wireless Linksys wrt54g router into a client

I’ve been overly fascinated with this latest find. Last month I moved from one side of town to the other. To my chagrin, mostly due to my laziness, the house closing was moved up one week and I hadn’t made preparations for a new broadband connection to be set up. I wasn’t terribly worried. I had my Verizon account with a Motorola Android and had already hacked it for use as a proxy and as back-up, a copy of PdaNet (an inexpensive tethering app for the Droid from June Fabrics [http://www.junefabrics.com] ). While I highly recommend PdaNet, it wasn’t practical for the time I was without a dedicated access point. I guess to be fair, I was being a little bit spoiled. The only frustrating aspect of the ordeal was that my phone had to be tethered via USB to my primary computer which then shared the connection with the other devices in the house. This didn’t effect me too much. The kids couldn’t play XBOX LIVE while I was gone from the house with my phone though(not exactly pioneer kiddos).


After two or three days I decided to see if there was a temporary solution to my woes. With my WiFi Analyzer app I checked the neighborhood and found a few unsecure networks with decent strength. That find immediately tripled my download speeds; though I still was tethered. With this new information, I did a quick search to see if there was any open source software for my Linksys WRT54g router that would enable me to “borrow” some of my neighbors bandwidth for a few days. Yowzers! There is a plethora of free software out there and they all work.


I tried all the popular versions of open source software I could find. Though I had trouble with some, they all worked swimmingly.

My recommendation for software and support for turning your router into a client, or client-bridge, is dd-wrt.com [http://www.dd-wrt.com].


Here is my time saving advice: When following the directions for installation and setup, take the time(s) listed extremely seriously. Patience will enable a quick and successful install of the software. When it is recommended that you unplug your router for 10 seconds, take it literally. When the instructions propose waiting one minute before re-setting your IP dynamically, follow the words to a T.


There are plethora of ideas floating around in my head with the ubiquitous open source software for the Linksys WRT54G router; a router I consider the work-horse of the industry. If neighborhoods could get together and form neighborhood networks, broadband companies would lose a significant amount of revenue… Just a thought!

Monday, February 22, 2010

Where is the Internet and why am I here?

Where is the Internet and why am I here?

The internet was capitalized back then; now it isn’t. Some people are buried in it. A lot of people still think AOL is it. Many more think it’s broken if their browser doesn’t point them to the Verizon.net homepage on startup. Others think it comes free in the air. Many are confused as to whether or not you can ask the internet a question. The web, the internet; the internet, the web… was it Al Gore that made the internet hot? On second thought, I think he increased the Earths’ temperature in a fictional movie.

Since 1996 I’ve been fascinated by browser based internet technologies. I didn’t sleep much in the late nineties. I was in a continuous state of awe. In 1997 I paid $100.00 to Network Solutions for the domain name houseclassifieds.com. As an entrepreneur, artist and budding software developer, I saw the WWW as infinite potential for excitement. The premise of the site was to allow people to list their homes for sale privately for an extremely modest fee. I think it was 50 bucks, give or take. This was BG (before Google… and back when it was properly spelled; googol) and people all over the country used my site. The domain slowly slipped into oblivion due to lack of attention, other interests and stiff, big money competition with much better websites (technological speaking).

Houseclassifieds was cutting edge for the time. It allowed users to upload images to their listings even on their 14.4 modems and before someone coined AJAX” some 10 years later. Next came Java. My brother, Jesse, pretty much invented Java based web page menus. This was over the top. While I worked with Jesse at opencube.com I got to work first hand on new, cutting edge applications with NASA, Intel, webMd, BestBuy, the FBI, FedEx, AOL and just about every Fortune 500 company on the planet. There was no such thing as a template, reference book or guide. Heck, there were no true search engines at the time. Archie was pointless, since there were no papers written on the new emerging technologies. No one had a degree in Java yet; the language was only two years old. Hotbot came very close when searching for answers. However, we had to pave our own roads for most of the apps. I was excitement personified.

Then in 2000 and coincidentally, DOTCOMs went kerplooey and Microsoft killed the web experience by tossing Java aside. I decided to solve the problem of “write once, run everywhere” (Java’s hallmark) with a product called FusionScript. FS was Javascript based and carried around a 15k overhead and was a rule set that displayed all the web elements exactly the same in all the browsers. It took into account the differences in rendering X and Y space relative to padding, margin, borders, etc.. in the DOM. I thought I was going to be as famous as Al Gore for awhile. This little product fixed everything for programmers who wanted to do cool things with their web apps, but didn’t know how to overcome rendering differences. I slapped the orca (missed the boat if you prefer) on that one. The timing was exactly when everyone was switching gears to CSS based layout; perfect for FS. FusionScript got buried in the bytes of excitement over other technologies and the browsers wising up to standards. It’s still a great product that no one will ever use.

Boy do I remember the enthusiasm when the web was switching to more dynamic delivery from both server and client. Ahhhh…. a web pages “mouse feel” was all the rage. I switched to working on a product called webnote. This was a JS based mini-app that enabled webmasters to add code to their sites enabling users to place sticky notes on their pages. The notes were only viewable by the person who wrote them and the content was stored client side. With sugar plumbs in my eyes I envisioned people all over the world taking notes on web pages to later reference, share and collaborate. Strike three and not even a whiff.

Fortunately, I’m not playing baseball. Taking advantage of Microsoft’s ubiquitous HTA, I decided to create a product to solve the world’s eCard conundrum. A quick side note: I firmly believe email to be the absolute worst method of communication on the planet and as alternate solutions come about, email will be the 8 track of the 2010 decade. The issue with eCards is that everyone was sending them and the process was daunting… go to a web site, register, select a card, type your note, send it (maybe pay a small fee first)… the recipient then gets an email that isn’t the card, but an invitation to go see the card. Click… Click… page load… page load…. Ahhh… the eCard!

I solved the problem with Quio eCards (http://quio.me/cards/ ~ shameless plug). The cards by various artists sit directly on your computer. If you want to send a quick, nicely formatted card BOOM, there it is. Click, type and hit send. That’s all there is to it. The recipient gets the card exactly as it appears and instantly in their inbox. Tons up PHP, ASP, JS, VBscript and a plethora of proprietary work-around schemes were used to create this phenomenal product. Now I would be knows as Josh, the guy who solved the global eCard headache!

In the months it took to develop, design, code and market the product along came Facebook. Now no one sends eCards. Quick thank-you, birthday wishes and the like are Facebooked. To date though, this is my best product ever and has turned out to be a fantastic marketing tool for artists, photographers and small businesses. However fewer and fewer people visit my web sites these days. Traffic from products I’ve created runs steadily through it in the background far away from a browser interface.

This is where I get to the “why am I here” part of the article’s title.

So, where did the internet go these past 14 years? From where I sit, no self respecting developer, artist, photographer, writer, businessman, fill-in-the-blank, would ever use anything but their own domain. Not only that, the site would be built by hand in a text editor without the use of a WYSWIG, template or 8th grader taking a class on web page design. Here is my epiphany: The internet is right here; on this page in front of you and me. Whatever domain name is in the address field of your browser right now, it isn’t one I own. The internet is moving where capitalism meets social behavior; where your friends and acquaintances have recommended it be; where smaller communities have formed out of the Internet.

As the WWW interface on the internet grows daily, it’s segments are growing smaller and more close nit. While no one knew what to do with the internet in the beginning, it’s working itself out and mimicking exactly the way our societies form naturally. While I didn’t like this concept at the onset of writing this article, I’m growing to like it.

I’ll still use Textpad from Helios Software that I’ve carried the unlock code to from computer to computer with a copyright of 1997 for all the coding I do. I’m really excited about the new Facebook and Android apps I’m working on. I’m stuck glued to new technology trends. Even if I’m a day late and a dollar short on the next great software product, I’ll enjoy the journey in the new era of the Social Network Internet.