Solved

HotKey to run script in Safari

Posted on 2011-09-13
4
324 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to Popup 2 50
connect a series of circles by line based on clicks 4 38
Create a new template 9 21
Asp.net mvc 5 5 16
Apple's Mac OS X has become an official member of the malware club. The Flashback Trojan has affected over half million Macs, worldwide. It is behavior that ultimately gets malware onto a person’s computer. Obsolete or out-of-date software helps…
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:…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now