2
votes

Is there a way to write an autohotkey within an autohotkey? For instance, I have an autohotkey that opens some websites in tabs at work for me & I have an autohotkey that when typed puts in my username & password for some of those sites. Is there a way to put the password autohotkey (actd(at symbol)) inside the IE tabs autohotkey? I did some searching, & it doesn't look like {@} can be sent, so I wasn't sure if there was another way to do it.

4
Have you tried combining them into one script? Please post your code (modify any usernames/passwords as well).Elliot DeNolf

4 Answers

8
votes

Your AutoHotKey script can #Include other scripts, assuming they are not #Persistent. You could loop through your list of tabs, and then call one or more other scripts.

As far as sending the @ sign, you should be able to use the Send command without problems. If you do encounter a strange problem, then you can try using the SendRaw command or use the syntax: Send {raw}@

If this doesn't answer your question, please paste some code of what you are trying to get working.

3
votes

What you can do is write two separate scripts. One does not have an autohotkey assigned, but gets called by the initial script. In your case, you have said that you already have a tabopening hotkey, so I will use a VERY rudimentary example of both scripts, but demonstrate how to send the @ symbol and call another script from within a hotkey.

The two scripts I would use are: tabOpener.ahk, and passwordEntry.ahk

And they would appear as follows:

tabOpener.ahk

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; hotkey is set as WinowsKey+t and checks if FireFox exists, if so, it makes it active, if not, it starts FireFox
~#t::
IfWinExist, ahk_class MozillaWindowClass
{   WinActivate
    Send ^t
} else run firefox

;Upon opening a new tab in FireFox, the address bar has already got focus, 
;so send the web address (You can use COM functions for this, and are highly 
;recommended, but out of the scope of this example)
Send, hotmail.com{Enter}

;Waits until page is loaded.  Again COM functions are available as they can tell 
;when a page is finished loading, but that is a more involved example.
Sleep 5000

;Calls the password entry script.
Run passwordEntry.ahk
return

passwordEntry.ahk

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;When using send, adding the {Raw} tag will literally interpret every 
;character in the remainder of a string.  For instance ^ will send ^ 
;instead of a Control keypress.
Send {Raw}[email protected]
Send {Tab} {Raw}Password

Hopefully that helps. This example showed the use of the {Raw} tag for sending special characters (http://www.autohotkey.com/docs/commands/Send.htm), in addition to calling a separate script from within one's existing hotkey using Run / Runwait (http://www.autohotkey.com/docs/commands/Run.htm).

1
votes
;~ Alt+1 to send username (email format) and password
!1::Send, [email protected]{tab}myPassword{enter}
0
votes

depending on you web browser you could use COM objects to handle this very easily. You would find the user id password fields and then for example:

url := "http://yourwebsite.com"
wb := ComObjCreate("InternetExplorer.Application") ; create broswer object
wb.navigate(url)
wb.visible := true ; sets the browser as visible, defaults as not
While (wb.busy || wb.readyState <> 4)
    Sleep 100<br>
wb.document.all.username.value := "[email protected]"
wb.document.all.password.value := "Pa$$word15"
wb.document.all.btnLogin.click()

this however depends on if you are using IE to access your site or not. Look at COM objects in the docs a bit to get a feel for it, and you will learn some really basic things about the DOM, here: Basic DOM MSDN. where I set the "username" & "password" and "btnLogin" control ids in our javascript, would need to be discovered by looking at your page. you should also check out out this tutorial: AHK Basic COM/JavaScript Tutorial