Jump to content

hotkeyset (to help me enter repetitive data into app)


Recommended Posts

in my job as tech support rep, each time i call a customer i need to make a notation in our web-based 'customer management system'.

ive figured out how to take a boilerplate hotkeyset script and ive added a hot key combination...

HotKeySet("^+1}", "LM") ; control-shift-1

each time i hit the keyboard combination control-shift-1 my script basically sends output into the proper fields of this web form.

the problem is that after the script 'Send' s the data into the form, i might want to enter more data myself into certain form fields by typing keys of the keyboard.

for whatever reason, any additional keys i manually type are no longer sent from the keyboard to the web forms - its as if i am not typing anything.

the 'fix' is to stop the script (either using yet another hotkeyset (expressely to terminate the script), or task manager killing autoit3.exe.

but that defeats the entire point of the script - my aimpoint here is to start the script once at beginning of my work day, then selectively - only as needed, hit the hot key combination to cause this autoit generated content to fill into the form. then return control of my keyboard to work as normal, until such time i hit the special control-shift-1 hot key combination.

am i missing something here about how this is supposed to work? or was the boilerplate script i found on the internet, missing some important code that returns normal keyboard functionality in between invocations of the special hot keys?

heres my script, its a work in progress...

; Press Esc to terminate script

HotKeySet("^+1}",    "LM")                     ; control-shift-1 (lm time)
HotKeySet("^+y}",    "ShowMessage")   ; control-shift-y
HotKeySet("^+z",     "Terminate")          ; control-shift-z

While 1
    Sleep(100)
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc   ;==>ShowMessage

Func LM()

    ; tab to 'status' field of web page (a drop down selection form field), then change status='In Progress' (by sending 'I' key)
    Send("{TAB 6}")
    Send("I")

    ; tab to 'subject' field of web page, insert a '(left phone message notation hour:minute) '
    Send("{TAB 2}")
    Send("{LEFT}")
    Send("(lm " & @HOUR & ":" & @MIN & ") ")

    ; tab to 'description' field of web page, insert 'year-month-day hour:minute ga, LM(newline)' phrase
    Send("{TAB 1}")
    Send("{LEFT}")
    Send(@YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & " ga, LM" & "{ENTER}")

EndFunc   ;==>LM
Edited by Melba23
Added code tags
Link to comment
Share on other sites

thanks for catching my syntax error. ive made the correction, and 'pasted back' into the script code that 'paused' the execution of the script - thinking that perhaps the script needs to be 'paused' to enable normal keyboard activity. the revised script may be tested in an open 'notepad' application widow. note the odd behavior. if once the script is launched, i depress the 'pause' button - the up-left corner of my windows desktop displays 'this script is paused', i press the 'pause' key a 2nd time and the message goes away, i can hit pause any number of times and cause the state of script to pause or execute. however once i hit control-shift-1 the text and tabs i output DO PROPERLY output. however keyboard activity after that point in time simply fails to be interpreted by windows normally ! note fhat if you test this in notepad, that from that point on, that hitting the 'pause' key no longer puts the script into pause mode (how to explain this?). and to merely type additional characters manually into notepad doesnt work. there must be something here that i dont understand about how this hotkeyset is designed to work. its not clearly specified exactly what the behavior is suppsoed to be - my assumption was that i could hit normal keys (that arent 'hotkeys' ) and these should be received by windows 'normally' and only when a 'hotkey' is pressed, should the matching hotkey functions be executed. but this doesnt seem to be happenning for me. if it matters i am using windows 7 pro 64 bits.

; to be used on a 'salesforce.com' crm web session (but may be tested in an open 'notepad' window a well)

; control-shift-1  Salesforce Case already in Edit Mode, cursor in 'Contact Name' field - this script will:
;                     a. change status to 'In Progress',
;                     b. insert "(lm h:mm) " at begin of 'Subject' field,
;                     c. insert "yyyy-mm-dd h:mm ga, LM(enter)" at begin of 'Description' field.


Global $Paused
HotKeySet("{PAUSE}", "TogglePause")  ; toggle the script executation state by 'pausing'
HotKeySet("^+1",     "LM")           ; control-shift-1 (lm time)
HotKeySet("^+y",     "ShowMessage")  ; control-shift-y
HotKeySet("^+z",     "Terminate")    ; control-shift-z

;;;; main loop is required ;;;;

While 1
    Sleep(100)
WEnd

;;;;

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc   ;==>ShowMessage

Func LM()

    ; tab to 'status' field (a drop-down selection field), then change value to 'status'='In Progress' (by sending the 'I' key)
    Send("{TAB 6}")
    Send("I")

    ; tab to 'subject' field (which highlights everything in field), send LEFT key (to de-select the highlighted text), then insert '(lm hour:minute) '
    Send("{TAB 2}")
    Send("{LEFT}")
    Send("(lm " & @HOUR & ":" & @MIN & ") ")

    ; tab to 'description' field (which highlights everything in field), send LEFT key (to de-select the highlighted text), then insert 'year-month-day hour:minute ga, LM(newline)'
    Send("{TAB 1}")
    Send("{LEFT}")
    Send(@YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & " ga, LM" & "{ENTER}")

EndFunc   ;==>LM
Edited by Melba23
Added code tags
Link to comment
Share on other sites

  • Moderators

greginsandiego,

The problem was that the "Shft" and "Ctrl" keys were becoming stuck down - this is a known problem that can happen when using HotKeys to Send without any intermediate steps. I have added a small loop that waits until those keys are released before Sending. It works fine on my machine - how about on yours:

; to be used on a 'salesforce.com' crm web session (but may be tested in an open 'notepad' window a well)

; control-shift-1  Salesforce Case already in Edit Mode, cursor in 'Contact Name' field - this script will:
;                     a. change status to 'In Progress',
;                     b. insert "(lm h:mm) " at begin of 'Subject' field,
;                     c. insert "yyyy-mm-dd h:mm ga, LM(enter)" at begin of 'Description' field.

#include <Misc.au3> ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Global $Paused

Global $hDLL = DllOpen("user32.dll") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

HotKeySet("{PAUSE}", "TogglePause") ; toggle the script executation state by 'pausing'
HotKeySet("^+1", "LM") ; control-shift-1 (lm time)
HotKeySet("^+y", "ShowMessage") ; control-shift-y
HotKeySet("^+z", "Terminate") ; control-shift-z

;;;; main loop is required ;;;;

While 1
    Sleep(100)
WEnd

;;;;

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    DllClose($hDLL) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Exit 0
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc   ;==>ShowMessage

Func LM()

    While _IsPressed("10", $hDLL) Or _IsPressed("11", $hDLL) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Sleep(10) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    WEnd ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    ; tab to 'status' field (a drop-down selection field), then change value to 'status'='In Progress' (by sending the 'I' key)
    Send("{TAB 6}")
    Send("I")

    ; tab to 'subject' field (which highlights everything in field), send LEFT key (to de-select the highlighted text), then insert '(lm hour:minute) '
    Send("{TAB 2}")
    Send("{LEFT}")
    Send("(lm " & @HOUR & ":" & @MIN & ") ")

    ; tab to 'description' field (which highlights everything in field), send LEFT key (to de-select the highlighted text), then insert 'year-month-day hour:minute ga, LM(newline)'
    Send("{TAB 1}")
    Send("{LEFT}")
    Send(@YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & " ga, LM" & "{ENTER}")

EndFunc   ;==>LM

Look for the <<<<<<<<<<<<<< lines. :)

M23

P.S. When you post code please use Code tags - put [autoit] before and [/autoit] after your posted code. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

dear m23, you my friend - are a god... thanks immensely for your expertise here. while i dont claim to totally understand what the extra lines of code actually do - but without your help i NEVER would have gotten this to work.

such useful information youve provided here should probably be added to the official 'hotkeyset' documentation page.

m23, can i ask you a somewhat related question? using autoit on a web form - do you have any suggestion for how autoit can 'click' a form button? if i can learn how to find and click a button or hyperlink, then i can really streamline my workflow with my day job.

i now see the true value of using autoit - its such a cool tool.

greg

Link to comment
Share on other sites

  • Moderators

greginsandiego,

It is already in the FAQ. ;)

To automate IE take a look at the IE functions within AutoIt - you can do practically anything on a web page with it. And there is a FireFox UDF as well if you use that browser. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

This same issue continues to allude me. Why is it that we cannot add this code to the existing Send() function?

I agree with the OP, as it should at least be in the help file on how to fix the issue, and maybe a link to the FAQ. Is the reason for not putting those couple of lines to make sure that the keys have been release, a secret? I would not think of even looking, for a KNOWN issue in the FAQ, as it should be listed in the helpfile under the function that has the issue?

If I need to report this in the helpfile posts - I will, but it seems like a no-brainer to either fix the BUG or list it and the FIX in the helpfile.

EDIT - I am sure there are a lot more, but here are some of the ones I found - in fact the first link, has a few as well, not sure if those listed were the ones I found:

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

  • Moderators

nitekram,

The function does not have "that issue" - the problem arises on certain machines under certain circumstances (most commonly after Send("{###DOWN}")), and the function works perfectly in the vast majority of cases. :)

So adding those particular code lines would not necessarily be the solution - nor correct in all cases as you can see there are other suggestions in the Wiki too. But I agree that mention could be made in the Help file of the possibility of having strange keyboard symptoms post Send, so I encourage you to make the request. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...