 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
scamper_22
Joined: 15 May 2009 Posts: 12
|
Posted: Fri May 15, 2009 5:30 pm Post subject: what am I doing wrong... send text to notepad? |
|
|
Hi all,
I'm writing my first script.
-------
Run, Notepad.exe, C:\My Documents, max
IfWinExist, Notepad
{
WinActivate
SendInput, Dude, what the hell. this is notepad
}
------
What I get is notepad opens, but there is no text being sent to notepad.
What am I missing here?
I have tried Send instead of SendInput
I have also tried to setfocuscontrol.
I am sure it is a simple thing.
Thanks, |
|
| Back to top |
|
 |
scott257us
Joined: 01 Jul 2008 Posts: 34 Location: Ohio
|
Posted: Fri May 15, 2009 5:47 pm Post subject: Try this work good for me |
|
|
| Code: | DetectHiddenText, On
SetTitleMatchMode 2
SetTitleMatchMode Slow
Run, Notepad.exe, C:\My Documents, max
WinWaitActive, Notepad
SendInput, Dude, what the hell. this is notepad
|
It works pretty fast and is very slick. |
|
| Back to top |
|
 |
Guest
|
Posted: Fri May 15, 2009 5:47 pm Post subject: Re: what am I doing wrong... send text to notepad? |
|
|
| scamper_22 wrote: | Hi all,
Run, Notepad.exe, C:\My Documents, max
IfWinExist, Notepad
{
WinActivate - Notpad
SendInput, Dude, what the hell. this is notepad
}
return
|
|
|
| Back to top |
|
 |
Guest23 Guest
|
Posted: Fri May 15, 2009 5:48 pm Post subject: |
|
|
your title is not correct...: IfWinExist, Notepad
Open up Notepad manually and see what the window title is. |
|
| Back to top |
|
 |
badmojo
Joined: 11 Nov 2005 Posts: 202
|
Posted: Fri May 15, 2009 5:49 pm Post subject: |
|
|
try this:
| Code: |
SendMode, Input
SetTitleMatchMode 2
Run, notepad.exe, C:\My Documents, max
WinWait, Notepad
if ErrorLevel <>
{
WinActivate
Send, Dude, what the hell. this is notepad
}
|
Last edited by badmojo on Fri May 15, 2009 6:23 pm; edited 1 time in total |
|
| Back to top |
|
 |
anon Guest
|
Posted: Fri May 15, 2009 6:03 pm Post subject: |
|
|
You should wait fot the Notepad window to be created before sending keys to it. The help file for Run says: | Quote: | | After the Run command retrieves a PID, any windows to be created by the process might not exist yet. To wait for at least one window to be created, use WinWait ahk_pid %OutputVarPID% |
This works reliably:
| Code: | run, Notepad.exe, C:\My Documents, max, notePadPID
WinWait, ahk_pid %notepadPID%WinActivate
SendInput, Dude, what the hell. this is notepad
|
|
|
| Back to top |
|
 |
anon Guest
|
Posted: Fri May 15, 2009 6:06 pm Post subject: |
|
|
hmm, had a paste problem...
| Code: | run, Notepad.exe, C:\My Documents, max,notePadPID
WinWait, ahk_pid %notepadPID%
WinActivate
SendInput, Dude, what the hell. this is notepad
|
|
|
| Back to top |
|
 |
scamper_22
Joined: 15 May 2009 Posts: 12
|
Posted: Fri May 15, 2009 6:18 pm Post subject: |
|
|
anon,
no, I tried that (exactly copied and pasted)... still no text in notepad.
Right now it is in this state:
--------------
DetectHiddenText, On
SetTitleMatchMode 2
SetTitleMatchMode Slow
run, Notepad.exe, C:\My Documents, max,notePadPID
WinWait, ahk_pid %notepadPID%
WinActivate
SendInput, Dude, what the hell. this is notepad
return
--------------
I am trying this at work. Is it possible there is some security thing blocking this? Running Windows XP SP3 with Semantic Endpoint Protection... ?
Thanks |
|
| Back to top |
|
 |
scamper_22
Joined: 15 May 2009 Posts: 12
|
Posted: Fri May 15, 2009 6:22 pm Post subject: this kind of works.... |
|
|
badmojo's one works. For some reason
The top two lines of his scrpit would not work
---
SendMode, Input, C:\My Documents, max
---
So I ran this:
-----
Run, notepad.exe
WinWait, Notepad, , 3
if ErrorLevel <>
{
WinActivate
Send, Dude, what the hell. this is notepad
}
----
It creates a new notepad window
but then sends the text to my notepad++ window  |
|
| Back to top |
|
 |
badmojo
Joined: 11 Nov 2005 Posts: 202
|
Posted: Fri May 15, 2009 6:25 pm Post subject: |
|
|
sorry just realised that i had pasted in the wrong place.. it should be just
i had edited the above post and corrected it.  |
|
| Back to top |
|
 |
scamper_22
Joined: 15 May 2009 Posts: 12
|
Posted: Fri May 15, 2009 6:26 pm Post subject: okie... this works now... |
|
|
---
SetTitleMatchMode 2
Run, notepad.exe
;WinWait, Notepad, , 3
WinWait , Notepad, , 3, ++,
if ErrorLevel <>
{
WinActivate
Send, Dude, what the hell. this is notepad
}
----
I exclude notepad++ with the ++ exclude title variable. |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Fri May 15, 2009 6:26 pm Post subject: |
|
|
Try this:
| Code: | Run, Notepad.exe
WinWait, ahk_class Notepad
WinActivate, ahk_class Notepad
ControlSend, Edit1, what the hell. this is notepad, ahk_class Notepad
return |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
scamper_22
Joined: 15 May 2009 Posts: 12
|
Posted: Fri May 15, 2009 6:29 pm Post subject: |
|
|
Thanks for the help guys.
Badmojo... just for record, the issue with my original script was that it was not waiting for the window to come up? The ifwinexist would check before the window came up and it would not execute the send.
correct? |
|
| Back to top |
|
 |
badmojo
Joined: 11 Nov 2005 Posts: 202
|
Posted: Fri May 15, 2009 6:35 pm Post subject: |
|
|
| @scamper_22: yes the 'IfWinExist' only checks if the specified window already exists. if there was a delay, then it'd skip over to the next line. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|