R_A Posted May 19, 2023 Posted May 19, 2023 I'm trying to use a simple script as a word sender: _Example() Exit ; Finished! Func _Example() Send ( "h") Send ( "e") Send ( "l") Send ( "l") Send ( "o") Send ( "w") Send ( "o") Send ( "r") Send ( "l") Send ( "d") EndFunc ;==>_Example Could you please help to understand why the first letter is missing in some windows (notepadd++) and can't be inserted in some windows (browser) ? And I would appreciate it if you could give me some tips on how I can improve this simple script.
bogQ Posted May 19, 2023 Posted May 19, 2023 (edited) try adding WinActivate("some title name of np++ window") before sending fist key (had no problem using WinActivate("new 1") in my case) edit: or WinActivate("[CLASS:Notepad++]") by the way you can use send like send("helloworld") Edited May 19, 2023 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
Danyfirex Posted May 19, 2023 Posted May 19, 2023 Hello. 1. Maybe You don't have your window active when sending the keys. 2. Maybe You need admin rights. 3. Some application needs the keys to be send with more delay (Opt("SendKeyDelay")) Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
mistersquirrle Posted May 20, 2023 Posted May 20, 2023 Another option is also ControlSend: Global $iNotepadPid = Run('notepad.exe') WinWait('Untitled - Notepad', '', 3) ControlSend('Untitled - Notepad', '', '', 'Hello World!') Sleep(5000) ProcessClose($iNotepadPid) We ought not to misbehave, but we should look as though we could.
636C65616E Posted May 20, 2023 Posted May 20, 2023 The real question is "why" I'm sorry but this kind of posts always triggers me ... for many reasons : 1. if we know what you want to achieve i can bet there's better way to handle the problem than sending inputs, 2. it always looks sus (about some not-so-legal-and-authorized-here automation) anyway as statted before : if the window is not active it will not work this way.
Skeletor Posted May 22, 2023 Posted May 22, 2023 Using your Send() method: _Example() Func _Example() Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") Send("hello world") Sleep(1000) Exit EndFunc ;==>_Example ControlSend() doesn't work for me. Not sure if it works for others. Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI
Andreik Posted May 22, 2023 Posted May 22, 2023 2 hours ago, Skeletor said: Using your Send() method: _Example() Func _Example() Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") Send("hello world") Sleep(1000) Exit EndFunc ;==>_Example ControlSend() doesn't work for me. Not sure if it works for others. Of course it works for you also. Try this: AutoItSetOption('WinTitleMatchMode', 2) $PID = Run('notepad.exe') WinWait('Notepad', '', 3) ControlSend('Notepad', '', 'RichEditD2DPT1', 'Hello World!') Sleep(5000) ProcessClose($PID) Note: Replace RichEditD2DPT1 with Edit1 for Win10 (I think) and below.
R_A Posted June 11, 2023 Author Posted June 11, 2023 On 5/20/2023 at 4:08 PM, 636C65616E said: The real question is "why" I'm sorry but this kind of posts always triggers me ... for many reasons : 1. if we know what you want to achieve i can bet there's better way to handle the problem than sending inputs, 2. it always looks sus (about some not-so-legal-and-authorized-here automation) anyway as statted before : if the window is not active it will not work this way. I am just trying my script as macros for my mouse (logi M650). For this mouse, I can use my script as .exe application to insert my password for any login dialog windows. That's all.
R_A Posted June 11, 2023 Author Posted June 11, 2023 And for some windows, for some reason, one letter is lost. Notepad++ just was as example. But thank you guys for your answers. Unfortunately, it did not work for me. I mean "winactive" and "controlSend" :(
ioa747 Posted June 12, 2023 Posted June 12, 2023 Sleep(100) ; Retrieve the window title of the active window. Local $sText = WinGetTitle("[ACTIVE]") ConsoleWrite("$sText=" & $sText & @CRLF) _Example() Exit ; Finished! Func _Example() Send ( "h") Send ( "e") Send ( "l") Send ( "l") Send ( "o") Send ( "w") Send ( "o") Send ( "r") Send ( "l") Send ( "d") EndFunc ;==>_Example I know that I know nothing
R_A Posted July 1, 2023 Author Posted July 1, 2023 On 6/12/2023 at 6:33 PM, ioa747 said: Sleep(100) ; Retrieve the window title of the active window. Local $sText = WinGetTitle("[ACTIVE]") ConsoleWrite("$sText=" & $sText & @CRLF) _Example() Exit ; Finished! Func _Example() Send ( "h") Send ( "e") Send ( "l") Send ( "l") Send ( "o") Send ( "w") Send ( "o") Send ( "r") Send ( "l") Send ( "d") EndFunc ;==>_Example Thanks for help. But it does not work for me
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