DragonBall Posted November 2, 2011 Posted November 2, 2011 I am trying to do the following: When I type 0~9 or a~z or A~Z ( in fact more, like space, backspace...) in an editor ( for example : Notepad), then it will send "Ctrl + s " to save the file. I have found a solution on internet as following: While 1 sleep(100) For $i = 32 to 127 if ( _IsPressed(Hex(8)) OR _IsPressed(Hex($i)) ) Then Send("{F9}") EndIf Next WEnd But I don't like it, because each time when I type a letter, it will try to test the for loop i = 32 ~ 127. But I don't care which letter I typed, I just need to send "Ctrl + s" each time I type a letter, no matter which one. But I didn't find a way to do this. It would be much better if it doesn't need to do sleep(100) during the while loop, instead it waits me to press the next key and send "Ctrl+S".
nitekram Posted November 2, 2011 Posted November 2, 2011 This sounds like a keylogger and is not a subject that the AutoIt forums like to answer. Please read the rules about posting these types of posts. 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
DragonBall Posted November 2, 2011 Author Posted November 2, 2011 Also, I hope this script works only when I type in Notepad. I tried the following script, but it doesn't work: While WinActive("Untitled - Notepad") sleep(100) For $i = 32 to 127 if ( _IsPressed(Hex(8)) OR _IsPressed(Hex($i)) ) Then Send("^s") EndIf Next WEnd
DragonBall Posted November 2, 2011 Author Posted November 2, 2011 This is not a keylogger because I don't want to know which key I typed.
nitekram Posted November 2, 2011 Posted November 2, 2011 Then - why not write to the editor and when finished save it. Why would you want to save the file after each letter/char is entered? 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
DragonBall Posted November 2, 2011 Author Posted November 2, 2011 Ok, the reason is : I use WinEdt as latex editor, but I like the "continuous preview" feature, see "Bakoma" for what this feature means. So I tried to make WinEdt has this feature. I use sumatraPDF as pdf viewer and set F9 as shortcut for compile by pdflatex. Finally, I use autoit to send F9 when each letter is entered. Now, everything is very good. I just hope I could make it a little bit fast and fewer cpu resource consummation by improving the above script.
careca Posted November 2, 2011 Posted November 2, 2011 If you want it faster, why dont you remove "sleep(100)" or reduce the time? the number is miliseconds. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
DragonBall Posted November 2, 2011 Author Posted November 2, 2011 Sure, but it will use more cpu resource.....
careca Posted November 2, 2011 Posted November 2, 2011 (edited) Your script closes by itself, dont you want to keep it running until you close it? Edit: all you need is your script to simulate ctrl+s in each key you press right? and now it is simulating that when you press F9. Edited November 2, 2011 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
careca Posted November 2, 2011 Posted November 2, 2011 (edited) Check this one out, it checks for the notepad process instead of window, because the caption changes depending on the file that is open,and when you press F9, it saves, meaning it presses Ctrl+S. It stays on tray, until you close it.See how it works for you#requireadmin #Include <WinAPI.au3> Local $save $save = 0 HotKeySet ("{F9}", "save") Func save() If ProcessExists ("Notepad.exe") then Send("^s") _WinAPI_Beep(1500, 100) EndIf EndFunc Do sleep(100) Until $save = 1EDIT: oh, and the beep thingy is so that you know that the hotkey was pressed, otherwise you might not be sure, anyhow, if you dont want that, just delete it. Edited November 7, 2011 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
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