?
Solved

HotKey to run script in Safari

Posted on 2011-09-13
4
Medium Priority
?
331 Views
Last Modified: 2012-05-12

I'm trying to write a little applescript or MAC automater action that I can trigger with a hot key.

The html code for the website is below and in the area "<input name="EmployeeNumber" type="text" size=8>"

I need the program to enter 4-digits then hit "enter."

I'm on a MAC with Snow Leopard usually running Safari. Thanks.


<form name="SignIn" method="post" action="http://fmweb/.....xsl">
    <p>
        <input type="hidden" name="-script" value="SetOfficeLocator" />
        <input type="hidden" name="-db" value="TRG%20Check%20In%20Log" />
        <input type="hidden" name="-lay" value="Webcheckin" />
        <input type="hidden" name="-grammar" value="fmresultset" />
        <input type="hidden" name="-encoding" value="UTF-8" />
        <input type="hidden" name="InOut" value="In">
    </p>
    <p>
        <font face="Arial, Helvetica, sans-serif" size="2">Enter (optional) from where (e.g.,
            client meeting, doctor, lunch).</font>
        <input name="Return When" type="text" value="" size="25">
        <br>
    </p>
    <p>
        <font face="Arial, Helvetica, sans-serif" size="2">Please enter your employee number</font>
        <input name="EmployeeNumber" type="text" size="8">
        <font face="Arial, Helvetica, sans-serif" size="2">&nbsp;then <font color="#FF0000">
            click-&gt;</font></font>
        <input type="submit" name="-new" value="Sign In" />
        <br>
    </p>
    </form>

Open in new window

0
Comment
Question by:wilcor14
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 36530928
try this :
<script>
window.onload = function() {
    document.getElementsByName("EmployeeNumber")[0].value = "1234"; // 4 digits
    document.forms[0].submit(); // ENTER KEY
}
</script>

Open in new window

0
 

Author Comment

by:wilcor14
ID: 36530999
Thanks for the info. This will execute on page load right? Is there a way to call this with a hotkey such as alt z or something? Thanks.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 36531127
document.onkeydown = function(e) {
    if(window.event) {
        var ctrlPressed = window.event.ctrlKey;
        var key = window.event.keyCode;    
    }
    else {
        var ctrlPressed = e.ctrlKey;
        var key = e.whiche;    
        
    }
    if( key == 90 && ctrlPressed) {
        document.getElementsByName("EmployeeNumber")[0].value = "1234"; // 4 digits
        document.forms[0].submit(); // ENTER KEY
    }
}

Open in new window

0
 

Author Closing Comment

by:wilcor14
ID: 36554637
Sorry for the delay. Needed some time to test. Works perfect thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question