AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trying to use InputBox command string for typing

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
TThot



Joined: 20 Nov 2009
Posts: 1

PostPosted: Fri Nov 20, 2009 3:13 pm    Post subject: Trying to use InputBox command string for typing Reply with quote

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
View user's profile Send private message
TLM



Joined: 21 Aug 2006
Posts: 767
Location: The Shell

PostPosted: Fri Nov 20, 2009 3:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
Guest






PostPosted: Fri Nov 20, 2009 3:54 pm    Post subject: Reply with quote

Thanks for wide answer Smile

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

PostPosted: Fri Nov 20, 2009 4:33 pm    Post subject: Reply with quote

Anonymous wrote:
Get me to think several thinks..

Quotable of the day Laughing

Hey you could have just probably just kept it simple with
Code:
Send %lette]%012345
Wink
_________________

Off diving into dll functions..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group