Hewittdude303 Posted August 6, 2020 Share Posted August 6, 2020 Hello everyone, I have just started using AutoIt so my knowledge is very basic. I have been really wanting to use it to automate part of my job. The program I work in is in google chrome and I have to enter text and numbers letter by letter, and advance manually using the left or right arrow keys, as sometimes the text I need to enter has to be entered from right to left. I was hoping I could have a script that runs continuously in the background, and every time I press a key is would automatically press the left or right arrow key. I would like to be able to specify what key it presses before I enter my text by pressing the left or right arrow keys myself. If I press the right arrow key it will advance right, and vice versa. It would also be handy for me to be able to pause and unpause the script using the backslash key. I'm sure something like this is possible, but at my current knowledge level I have no clue how to make something like this. Can one of you help me out here? It would be greatly appreciated. Link to comment Share on other sites More sharing options...
TheXman Posted August 6, 2020 Share Posted August 6, 2020 (edited) 30 minutes ago, Hewittdude303 said: Can one of you help me out here? What exactly do you mean by "help me out here"? Are you asking for help in learning AutoIt in order for you to be able to write your own script or are you asking for someone to write it for you? If it is the former, then what issue are you having a problem with or need a better understanding of? Edited August 6, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Hewittdude303 Posted August 6, 2020 Author Share Posted August 6, 2020 9 minutes ago, TheXman said: What exactly do you mean by "help me out here"? Are you asking for help in learning AutoIt in order for you to be able to write your own script or are you asking for someone to write it for you? I would prefer to learn how to write something like this myself, but if something like this is too complicated to explain easily someone can write it for me. Link to comment Share on other sites More sharing options...
TheXman Posted August 6, 2020 Share Posted August 6, 2020 How is someone supposed to know what is "too complicated" for you to understand? Why don't you show us what you have come up with so far so we can see and understand where you are in your AutoIt abilities and understanding. If you haven't come up with anything yet, then come back when you've taken the time to learn more about the basics and have something to build upon. As far as having someone write it for you, as someone new to AutoIt, that's just plain disrespectful to all of the people who have not taken such shortcuts and have taken the time to learn the language and become proficient at it. Although there are some in this forum that will probably write it for you, I certainly am not one of them. However, if you are truly interested in learning the language, I would be more than happy to assist you. Musashi 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Hewittdude303 Posted August 6, 2020 Author Share Posted August 6, 2020 4 minutes ago, TheXman said: How is someone supposed to know what is "too complicated" for you to understand? Why don't you show us what you have come up with so far so we can see and understand where you are in your AutoIt abilities and understanding. If you haven't come up with anything yet, then come back when you've taken the time to learn more about the basics and have something to build upon. As far as having someone write it for you, as someone new to AutoIt, that's just plain disrespectful to all of the people who have not taken such shortcuts and have taken the time to learn the language and become proficient at it. Although there are some in this forum that will probably write it for you, I certainly am not one of them. However, if you are truly interested in learning the language, I would be more than happy to assist you. I did not mean to be disrespectful to you and everyone here on this forum. I completely understand what you are talking about here, and I am truly interested in learning about this program and how to use it. I am majoring in mechatronics and learning anything coding related is going to be beneficial to me. What I meant is if taking the time to explain everything to me would be more trouble than just writing the thing yourself than you do not have to explain it all to me. Link to comment Share on other sites More sharing options...
Nine Posted August 6, 2020 Share Posted August 6, 2020 That is enough begging for one day, don't you think ? As it was told to you, show some effort and provide a basic script if you want anybody here to help you. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
TheXman Posted August 6, 2020 Share Posted August 6, 2020 (edited) 54 minutes ago, Hewittdude303 said: What I meant is if taking the time to explain everything to me would be more trouble than just writing the thing yourself than you do not have to explain it all to me. I do not totally understand the requirements of your script as stated. Given how new you are to AutoIt, it will definitely be more "trouble" and time-consuming for me to help you learn the skills needed to write your script than it would take for me to write it. To me, an ex-CTO, it is my belief that the time taken to help someone learn a new skill so that they can become self-sufficient -- no matter how tedious -- is much more beneficial and rewarding than just providing them answers that they can't understand or maintain. Of course, this assume that the person truly wants to learn those new skills and has the aptitude to do so. I guess the choice is yours now. You can continue to ask and wait for someone to write the script you are looking for or you can start learning AutoIt so that you can write this and any other scripts that you may need in the future. If you choose to learn AutoIt, there are numerous people here, including myself, that will help you overcome any obstacles that you may encounter. Edited August 6, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Hewittdude303 Posted August 6, 2020 Author Share Posted August 6, 2020 (edited) Alright, I have done some work on this. I based it off of the basic example in the _IsPressed info section as I thought that would be a good starting point. I did some modification to get it to move over when I pressed the L key, but unfortunately the program will only enter L once the key is released. I tried to fix this by adding the sleep function so I could get a delay between when I pressed the key and when I lifted it so it would type the L and then move over. Sadly that did not work. I need something that will check to see if the _IsPressed function is false and then if so press the right arrow. I'm thinking an If...ElseIf...Else...EndIf statement might work. What do you guys think? Attached is what I have so far. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Misc.au3> #include <MsgBoxConstants.au3> Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("4C", $hDLL) Then Sleep(1) Send("{RIGHT}") ElseIf _IsPressed("1B", $hDLL) Then MsgBox($MB_SYSTEMMODAL, "_IsPressed", "The Esc Key was pressed, therefore we will close the application.") ExitLoop EndIf Sleep(250) WEnd Next key press.au3 Edited August 6, 2020 by Jos just post code inline with <> Link to comment Share on other sites More sharing options...
TheXman Posted August 6, 2020 Share Posted August 6, 2020 (edited) 2 hours ago, Hewittdude303 said: The program I work in is in google chrome and I have to enter text and numbers letter by letter, and advance manually using the left or right arrow keys, as sometimes the text I need to enter has to be entered from right to left. What is the name and/or URL of this web app? In general, automating web apps is a bit different than automating desktop apps. Like I said before, I don't have a good understanding of what you are trying to achieve. It sounds similar to a keylogger, which would is a topic that is prohibited. Can you give a better explanation of what it is you are looking for and maybe an example? Why when you press "L", why would you want to send the right arrow? If you enter letters and numbers into this application, "L" is never going to be one of the letters that you would normally enter? Or are you trying to simulate entering data from right to left, so that when you enter a letter, you move the cursor to the left of that character? If so, is this right to left entry for all characters or just a certain set of characters? This doesn't make sense and needs a better explanation. Edited August 6, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Nine Posted August 6, 2020 Share Posted August 6, 2020 Also take a look at _WinAPI_SetWindowsHookEx in help file. There is a great example of how to intercept keys. If you need to check for multiple keys, this might be a better solution for you than using _IsPressed. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Hewittdude303 Posted August 11, 2020 Author Share Posted August 11, 2020 On 8/6/2020 at 2:48 PM, TheXman said: What is the name and/or URL of this web app? In general, automating web apps is a bit different than automating desktop apps. Like I said before, I don't have a good understanding of what you are trying to achieve. It sounds similar to a keylogger, which would is a topic that is prohibited. Can you give a better explanation of what it is you are looking for and maybe an example? Why when you press "L", why would you want to send the right arrow? If you enter letters and numbers into this application, "L" is never going to be one of the letters that you would normally enter? Or are you trying to simulate entering data from right to left, so that when you enter a letter, you move the cursor to the left of that character? If so, is this right to left entry for all characters or just a certain set of characters? This doesn't make sense and needs a better explanation. The web app is called VisioStack Applications, what I'm doing is surrounding individual letters from images of railroad tracks with bounding boxes and typing in what that letter is. I have made a basic representation of what the interface looks like, since I do not want to take a screenshot of the actual interface. I used the letter L just for the purposes of testing out my script. You move between the bounding boxes with the arrow keys, so it would be much faster to have this automated instead of having to press the arrow key between typing every letter. I have also worked on my script a bit and it works partially, if you press the keys too quickly it doesn't respond so you have to type methodically and it really slows you down. I've tried playing with the sleep times and that didn't fix the issue. I'm sure there is a way to improve the response times, do you have any suggestions? Next key press L.au3 Link to comment Share on other sites More sharing options...
TheXman Posted August 11, 2020 Share Posted August 11, 2020 (edited) Looking at your script and the description of what you are looking to do in your initial post, I think using HotKeySet may be a better route. The example that I have supplied below only monitors the "L" key (both upper and lower case). Meaning, if the app is not paused and the "L" is typed, the right or left arrow key will be entered. Pressing ESC will exit the app. Pressing "|" will pause the app. Pressing "\" will change the direction of the arrow key that is enter. Pressing any of those hotkeys will also show a tray tip to show the current status. Hovering over the app's tray icon will also show the current status. Since I still really do not understand what you are trying to do, hopefully this will help give you something to build upon. Note that the "L" will not be sent, it will just move left or right depending on the current state of the app. I specifically wrote it that way because that is how I interpreted your description. Spoiler expandcollapse popup#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> Global $gbPauseEnabled = False, $gbArrowLeft = True Global $gsTrayTipMsg = "" ;Monitored Keys HotKeySet("{esc}", exit_script) ;Press ESC to exit script HotKeySet("|" , toggle_pause) ;Press | to toggle pause state HotKeySet("\" , toggle_arrow_direction) ;Press \ to toggle arrow direction for monitored keys HotKeySet("l" , send_arrow_key) HotKeySet("L" , send_arrow_key) ;Display tray tip and launch message show_tray_tip() MsgBox($MB_TOPMOST + $MB_ICONINFORMATION, "Arrow Key Example", _ "Press ESC to Exit." & @CRLF & _ "Press | to toggle pausing the app." & @CRLF & _ "Press \ to toggle arrow advancement.") ;Loop endlessly to keep script active While 1 Sleep(10) WEnd ;============== Functions ============== Func send_arrow_key() If Not $gbPauseEnabled Then Send(($gbArrowLeft ? "{left}" : "{right}")) EndFunc Func toggle_arrow_direction() $gbArrowLeft = Not $gbArrowLeft show_tray_tip() EndFunc Func toggle_pause() $gbPauseEnabled = Not $gbPauseEnabled show_tray_tip() EndFunc Func show_tray_tip() $gsTrayTipMsg = "ESC to Exit" & @CRLF $gsTrayTipMsg &= "(|) Paused = " & ($gbPauseEnabled ? "True" : "False") & @CRLF $gsTrayTipMsg &= "(\) Arrow direction = " & ($gbArrowLeft ? "Left" : "Right") TraySetToolTip($gsTrayTipMsg) TrayTip("Arrow Key Example", $gsTrayTipMsg, 3, $TIP_ICONASTERISK) EndFunc Func exit_script() Exit EndFunc Edited August 11, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
seadoggie01 Posted August 11, 2020 Share Posted August 11, 2020 (edited) Maybe I'm misunderstanding, but couldn't you take input from the user, reverse the text if needed (handling your strange right to left typing), and slowly send it to the App? Edit: Please note that Sleep(1) will pause the code for 1/1000 of a second... probably not what you're looking for Spoiler expandcollapse popup#include <GUIConstants.au3> Global $hGUI = GUICreate("VisioStack Input", 340, 120, 192, 124) Global $idCancel = GUICtrlCreateButton("Cancel", 160, 75, 75, 25) Global $idOK = GUICtrlCreateButton("OK", 25, 75, 75, 25) Global $idInput = GUICtrlCreateInput("Input1", 65, 15, 256, 21) GUICtrlCreateLabel("Text", 25, 15, 36, 17) Global $idReverse = GUICtrlCreateCheckbox("Reverse Text", 25, 45, 97, 17) GUISetState(@SW_SHOW) Main() Func Main() Local $sText While True Switch GUIGetMsg() Case $idOK $sText = GUICtrlRead($idInput) If $sText = "" Then ContinueLoop If GUICtrlRead($idReverse) = $GUI_CHECKED Then $sText = StringReverse($sText) EndIf ; Do your send stuff here SendKeepActive("Untitled - Notepad") For $i=1 To StringLen($sText) Send(StringMid($sText, $i, 1)) Sleep(1000) Next SendKeepActive("") Case $GUI_EVENT_CLOSE, $idCancel ExitLoop EndSwitch WEnd GUIDelete($hGUI) EndFunc Edited August 11, 2020 by seadoggie01 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
TheXman Posted August 11, 2020 Share Posted August 11, 2020 Just now, seadoggie01 said: Maybe I'm misunderstanding Join the club. I still don't understand exactly what was requested either. I just created an example based on his attempt. seadoggie01 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Hewittdude303 Posted August 11, 2020 Author Share Posted August 11, 2020 Wow, thank you so much. You are amazing. I would have never have been able to make something so complicated. I will have to see what I can do off of this. It never occurred to me to use functions, hahah. 2 hours ago, TheXman said: Looking at your script and the description of what you are looking to do in your initial post, I think using HotKeySet may be a better route. The example that I have supplied below only monitors the "L" key (both upper and lower case). Meaning, if the app is not paused and the "L" is typed, the right or left arrow key will be entered. Pressing ESC will exit the app. Pressing "|" will pause the app. Pressing "\" will change the direction of the arrow key that is enter. Pressing any of those hotkeys will also show a tray tip to show the current status. Hovering over the app's tray icon will also show the current status. Since I still really do not understand what you are trying to do, hopefully this will help give you something to build upon. Note that the "L" will not be sent, it will just move left or right depending on the current state of the app. I specifically wrote it that way because that is how I interpreted your description. Reveal hidden contents expandcollapse popup#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> Global $gbPauseEnabled = False, $gbArrowLeft = True Global $gsTrayTipMsg = "" ;Monitored Keys HotKeySet("{esc}", exit_script) ;Press ESC to exit script HotKeySet("|" , toggle_pause) ;Press | to toggle pause state HotKeySet("\" , toggle_arrow_direction) ;Press \ to toggle arrow direction for monitored keys HotKeySet("l" , send_arrow_key) HotKeySet("L" , send_arrow_key) ;Display tray tip and launch message show_tray_tip() MsgBox($MB_TOPMOST + $MB_ICONINFORMATION, "Arrow Key Example", _ "Press ESC to Exit." & @CRLF & _ "Press | to toggle pausing the app." & @CRLF & _ "Press \ to toggle arrow advancement.") ;Loop endlessly to keep script active While 1 Sleep(10) WEnd ;============== Functions ============== Func send_arrow_key() If Not $gbPauseEnabled Then Send(($gbArrowLeft ? "{left}" : "{right}")) EndFunc Func toggle_arrow_direction() $gbArrowLeft = Not $gbArrowLeft show_tray_tip() EndFunc Func toggle_pause() $gbPauseEnabled = Not $gbPauseEnabled show_tray_tip() EndFunc Func show_tray_tip() $gsTrayTipMsg = "ESC to Exit" & @CRLF $gsTrayTipMsg &= "(|) Paused = " & ($gbPauseEnabled ? "True" : "False") & @CRLF $gsTrayTipMsg &= "(\) Arrow direction = " & ($gbArrowLeft ? "Left" : "Right") TraySetToolTip($gsTrayTipMsg) TrayTip("Arrow Key Example", $gsTrayTipMsg, 3, $TIP_ICONASTERISK) EndFunc Func exit_script() Exit EndFunc Link to comment Share on other sites More sharing options...
TheXman Posted August 11, 2020 Share Posted August 11, 2020 Thanks, I hope that it ends up being useful for you. If nothing else, I hope it sparks your interest in continuing to learn AutoIt and all of its capabilities. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Hewittdude303 Posted August 12, 2020 Author Share Posted August 12, 2020 I certainly has and I cannot thank you enough. I am certainly interested in learning more about this program and I look forward to being able to use this to further automate the entire process of my text entry. This will be fun! Link to comment Share on other sites More sharing options...
Hewittdude303 Posted August 12, 2020 Author Share Posted August 12, 2020 22 hours ago, TheXman said: Thanks, I hope that it ends up being useful for you. If nothing else, I hope it sparks your interest in continuing to learn AutoIt and all of its capabilities. You're welcome, and it certainly has; I cannot thank you enough. I am certainly interested in learning more about this program and I look forward to being able to use this to further automate the entire process of my text entry. This will be fun! TheXman 1 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