Jump to content

ControlSend


Recommended Posts

Hi Guys,

I am still having trouble sending. I initially wanted to test send keystrokes to a screen while I was logged off, I read that ControlSend can do that. Since the I have been battling to even get ControlSend to work while im logged on, let alone off!!!

I have tried different variations from ControlSetTest, ControlCommand but none seem to do anything, am I being that stupid!!! Probably but anyway, does anyone have suggestions for me - keep in mind I am using ControlSend because Send was not working on my script when I was logged off the machine and thats really what I need, I have created a test script below but cant get that to work.

THANKS:

Run("c:\Windows\system32\notepad.exe")

WinWait("Untitled - Notepad")

While WinExists("Untitled - Notepad")

sleep(100)

wend

AutoItSetOption("WinTitleMatchMode", 4)

; Get the handle of a notepad window

$handle1 = WinGetHandle("Untitled - Notepad")

$handle2 = ControlGetHandle ($handle1 , "" ,"Edit1")

; Send some text directly to this window's edit control

;ControlFocus ($handle1, "", $handle2)

;ControlSetText ($handle1, "", $handle2, "AbCdE")

ControlSend($handle1, "", $handle2, "AbCdE")

Link to comment
Share on other sites

Make sure you read up in the helpfile its really well put together. Try this example;

Run("notepad.exe")
WinWait("Untitled - Notepad")
ControlSend("Untitled", "", "Edit1", "This is a line of text in the notepad window")

that will open notepad and enter some text. In your code, you don't need to get the windows handle and then get the control's handle, also wintitlematchmode 4 isn't necessary to use handles.

Also, why do you have a While/Wend in there? In fact what your telling your script to do is while the notepad window exists, sleep. Since at the top of your script notepad is run your script is just going to sleep indefinitely. I would suggest reading up on controls and don't worry you'll get the hang of it. Welcome to the forum!

EDIT: Some bad spelling and worse grammer

Edited by someone
While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

It's trapped in the While loop. You never got as far as the ControlSend() functions...

:D

'Someone' was faster... I wonder who? :)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

It's trapped in the While loop. You never got as far as the ControlSend() functions...

:D

'Someone' was faster... I wonder who? :)

Ok I feel really stupid, sat till three in the morning trying to figure that one out. It was the while loop thanks SO much guys, my process does write to the logon screen now and have tested while also being logged of and it works perfect.

Thanks again,

Stuntman

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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