Jump to content

Recommended Posts

Posted

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.

Posted (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 by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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.

 
Posted

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

Posted

The real question is "why" :D

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.

Posted

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 Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Posted
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.

  • 3 weeks later...
Posted
On 5/20/2023 at 4:08 PM, 636C65616E said:

The real question is "why" :D

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.

 

Posted

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" :(

  • 3 weeks later...
Posted
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

:unsure:

Thanks for help. But it does not work for me :(

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
  • Recently Browsing   0 members

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