AutoHotkey Community

It is currently May 27th, 2012, 1:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: November 20th, 2009, 4:13 pm 
Offline

Joined: November 20th, 2009, 3:58 pm
Posts: 2
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 4:25 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
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

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 4:54 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 5:33 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Anonymous wrote:
Get me to think several thinks..

Quotable of the day :lol:

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

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, iDrug, Ohnitiel, Yahoo [Bot] and 23 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group