Solved

HotKey to run script in Safari

Posted on 2011-09-13
4
328 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 500 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
How Close unsubmited attempts 10 46
Javascript Regex 7 20
Github api to fetch the number of collaborators in a git repo 1 29
links not working 2 27
This article describes in detail how to set up the iPad in the Enterprise using iPCU aka iPhone Configuration Utility.  This could also be used for the iPhone although I have not detailed out any differences. Preparation as an iPad Administrator:…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

749 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