greginsandiego Posted March 8, 2013 Share Posted March 8, 2013 (edited) 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 March 8, 2013 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 8, 2013 Share Posted March 8, 2013 First thing I noticed off the bat, you should not have } at the end of your hotkeys 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
greginsandiego Posted March 8, 2013 Author Share Posted March 8, 2013 (edited) 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. expandcollapse popup; 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 March 8, 2013 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 8, 2013 Moderators Share Posted March 8, 2013 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:expandcollapse popup; 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 ;==>LMLook for the <<<<<<<<<<<<<< lines. M23P.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. 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
greginsandiego Posted March 8, 2013 Author Share Posted March 8, 2013 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 More sharing options...
Moderators Melba23 Posted March 8, 2013 Moderators Share Posted March 8, 2013 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nitekram Posted March 9, 2013 Share Posted March 9, 2013 (edited) 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 March 9, 2013 by nitekram 2¢ 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." 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 More sharing options...
Moderators Melba23 Posted March 9, 2013 Moderators Share Posted March 9, 2013 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now