 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
TThot
Joined: 20 Nov 2009 Posts: 1
|
Posted: Fri Nov 20, 2009 3:13 pm Post subject: Trying to use InputBox command string for typing |
|
|
Hey
Can't get the below script to work the way i want to. I wan't to type some letter on the pop up box and then it would type that letter on notepad, before the numbers.
If i example give a letter A on pop up box, it would type this in notepad: A012345
What this script does at the moment is that, it just types the numbers and not the letter at all: 012345
Thanks for the help at before hand.
| Code: | InputBox, letter[, Alphabet, Give an alphabet `n`n Example: a/b/c, ,300, 100]
Sleep 400
Run, Notepad.exe
Sleep 400
Send %letter%012345
|
|
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 767 Location: The Shell
|
Posted: Fri Nov 20, 2009 3:25 pm Post subject: |
|
|
Try this
| Code: | InputBox, letter, Alphabet, Give an alphabet `n`n Example: a/b/c,,,300, 100
Run, Notepad.exe,, , npPid
WinWait, ahk_pid %npPid%
ControlSetText, Edit1, % letter " 012345", ahk_pid %npPid%s |
A couple of things:
- The pid in run (npPid) gives that specific window an id. This allows WinWait and ControlSetText to apply to the newly run window ONLY (in case theres other Notepads open).
- The WinWait gets rid of the need for sleep.
- The ControlSetText gets rid of the unreliable and interuptable send.
edit:
and then you could...
| Code: | start:
InputBox, letter, Alphabet, Give an alphabet `n`n Example: a/b/c,,, 300, 100,
if Errorlevel ; Exits if cancel is pressed.
{
Msgbox, Process Canceled
ExitApp
}
if letter is not alpha ; Checks to make sure theres letters only.
{
Msgbox, Please enter letters only!
Goto, start
}
Else if !letter ; Checks to make sure that something was written.
{
Msgbox, You did not write anything!
Goto, start
}
Run, Notepad.exe,, , npPid
WinWait, ahk_pid %npPid%
ControlSetText, Edit1, % letter " 012345", ahk_pid %npPid%s |
Also, if you wanted to just have the letter info placed into a new or existing txt file use FileAppend.
hth _________________
Off diving into dll functions.. |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Nov 20, 2009 3:54 pm Post subject: |
|
|
Thanks for wide answer
Get me to think several thinks and while testing your script i realise what was the mistake on my own script, it was the [] marks in InputBox command that were messing it up. Works now the way i need it for the simple case...
But thx for the tips, can surely use them in future for more complex scripts. |
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 767 Location: The Shell
|
Posted: Fri Nov 20, 2009 4:33 pm Post subject: |
|
|
| Anonymous wrote: | | Get me to think several thinks.. |
Quotable of the day
Hey you could have just probably just kept it simple with | Code: | | Send %lette]%012345 |
 _________________
Off diving into dll functions.. |
|
| 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
|