Saturday, November 6, 2010

AHK (AutoHotKey) Script to control Dialog Box

iWeb_Init()
SetTitleMatchMode,2
ControlGet,hWnd,Hwnd,,Internet Explorer_Server1,ahk_class Internet Explorer_TridentDlgFrame
pDoc:=IE_GetDocument(hWnd)
pWin := iWeb_DomWin(pDoc)
COM_Invoke(pWin,"Document.all.item['btnID'].click")
COM_Release(pwin)
WinWaitClose, Web Page Dialog
SoundPlay, *64
Com_Release(pDoc)
iWeb_Term()
return

Note: the three indented lines can be replaced with
iWeb_clickDomObj(pDoc,"btnCancel")
accomplishes the same thing but I left the three lines in as a demonstration of how to inject javascript into an AHK script.(There isn't an iWeb function for everything)

Note: You have to #include COM.ahk and iWeb.ahk for this to work, and I commented out the MsgBox line in the COM_Error() function within COM.ahk in order to stop useless error messages from popping up. These libraries were not designed for dialog boxes, but they work, and the error messages just get in the way. Normally calling COM_Error(0) does the same thing except the iWeb functions keep calling COM_Error(1)

Note: ['btnID'] can be replaced with ['387'] or whatever the element index number is.
Notice the WinWaitClose to wait for the Dialog to close, and the Sound alert command. You can also use WinWait to just wait for the Web Browser Object to get focus.

Monday, November 1, 2010

Access to Snow Leopard MAMP server and AHK server from a Windows Domain

For months I have been using a MacBook Pro with OSX 10.4 as a server at work to house my MAMP scripts and AHK scripts. In a previous post I described how to network a MacBook Pro with OS X 10.4 to a windows domain. IT TURNS OUT THOSE INSTRUCTIONS DO NOT WORK FOR SNOW LEOPARD (OS X 10.6). I brought in a back up MacBook Pro and much internet research did not generate a solution for weeks. Until Now.

The secret: On the Mac go to System Preferences>Network>Advanced>WINS>NETBIOS Name. This is where the name of the computer resides. I had been putting the name of the computer into my windows domain machines as specified in System Preferences>Sharing>File Sharing for weeks in a futile effort to connect. It was the wrong name. Thus, for MAMP server the URL is http://netbiosname:8888/MAMP and for the AHK scripts the server is \\netbiosname\macusername. It's that simple. I swear, nobody in the universe knows this little factoid.

Whether it made a difference or not, some other system adjustments were made according to "internet advice". They may be necessary too, I am not sure. All I know is I did them before I found that last little secret and the whole system works very nicely. Those other things included setting the workgroup to to MACPC (not sure why that would matter, all of the windows machines are in a domain, not a workgroup), of course making sure the mac is connected to the correct wireless router with the same network as the other machines (again, not sure if it matters, since most of the machines are connected by ethernet to the network), and I used my "Launcher" on my mac to run "Directory Utility" and put a checkmark in the "Activate Directory" box. For what it's worth. And I went into aforementioned sharing and did everything in my previous post, plus activated privileges for guests, added myself as a user, activated ftp, etc. (Note- the "Windows Sharing" pane present in 10.4 doesn't exist in 10.6) Have fun with this. Networking is a real bear.