Welcome Guest.   Make a donation to an author on the site August 19, 2014, 11:53:03 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Free DonationCoder.com Member Kit: Submit Request.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Sending user-supplied text  (Read 2802 times)
ralphkru
Participant
*
Posts: 5


View Profile Give some DonationCredits to this forum member
« on: June 12, 2012, 01:08:43 AM »

Prime newby to AHK and programming of any sort.  I think this question is ground-level basic.  I would like to send text to an application (say Word), with part of the text being a value I supply.  For instance, I might want to put in an identification number of some sort off of a list of such numbers.  Real basic data entry.  I've read about AHK's Input box, but, frankly, didn't understand it very well.  Anybody explain this in easy level tech words?  Thanks. 
Logged
MilesAhead
Member
**
Posts: 4,765



View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: June 12, 2012, 04:04:32 PM »

To send text see the help for Send, SendRaw etc..

Also if you search here:
http://www.autohotkey.com...5a51e849838013c5ed6a8e81d

It's probably already been answered.
Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
ralphkru
Participant
*
Posts: 5


View Profile Give some DonationCredits to this forum member
« Reply #2 on: June 12, 2012, 09:39:05 PM »

Yeah, I'm doing that.  Don't always understand everything I'm reading.  Looking for examples in other people's scripts of how those commands are used.
Logged
MilesAhead
Member
**
Posts: 4,765



View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: June 12, 2012, 09:49:22 PM »

AHK isn't the easiest first language. AHK_L helps somewhat. But the syntax is funky. Maybe give AutoIt a try. It's another macro language.  It has a Send() function that's similar, but the language syntax may be easier to catch onto if you are new to programming. I've been programming PCs since 1986 and AHK still throws me.

http://www.autoitscript.com/forum/index.php?
Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
ralphkru
Participant
*
Posts: 5


View Profile Give some DonationCredits to this forum member
« Reply #4 on: June 12, 2012, 10:16:00 PM »

Good suggestion.  I did look at Autoit before I got into AHK_L.  The learning curves seemed pretty similar.  But there were some AHK scripts (real simple ones) that I could figure out just by looking at them.  That's what made me decide to try AHK.  Autoit's syntax seems a tad more formal, if that's the word I want.  I'll stick with AHK for a while longer anyway, but thanks.

Here's a question out of the command help.  For InputBox they show InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default].  I assume the [ ] brackets mean the commands, I guess I mean parameters, are optional.  The question is, from the examples they show, you have to put a comma followed by a space for every one of those parameters you don't want to use.  That is, if you want to include parameter #1 and 3, but not #2, you have to put the comma+space between 1 and 3.  Correct?  And if you don't want to use any parameters after #3, you can just stop?
Logged
Target
Honorary Member
**
Posts: 1,394



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: June 12, 2012, 10:27:04 PM »

Here's a question out of the command help.  For InputBox they show InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default].  I assume the [ ] brackets mean the commands, I guess I mean parameters, are optional.  The question is, from the examples they show, you have to put a comma followed by a space for every one of those parameters you don't want to use.  That is, if you want to include parameter #1 and 3, but not #2, you have to put the comma+space between 1 and 3.  Correct?  And if you don't want to use any parameters after #3, you can just stop?

correct - so this would look like

[copy or print]
  input box, VarName, Par#1,,Par#3

Logged

"Look wise, say nothing, and grunt. Speech was given to conceal thought" - Sir William Osler
MilesAhead
Member
**
Posts: 4,765



View Profile WWW Give some DonationCredits to this forum member
« Reply #6 on: June 12, 2012, 11:43:20 PM »

The best thing to do is create a script that does as close to what you want as you can get, then post it in the Support forum.  Explain what you are trying to do. Plenty of AHK programmers will offer suggestions and code snippets. The traffic will be at least an order of magnitude greater than on this thread.

http://www.autohotkey.com...f4db5ea37362128d6bb672472

Also it's good to follow these suggestions:
http://www.autohotkey.com...wtopic.php?f=1&t=4986

If you are trying to do something like Close All Windows and there's a CloseAllWindows function in the help index that you didn't bother too look for, you won't get much sympathy. But if you follow the suggestions many people will try to help you out there.

As for syntax, AHK is the only programming language I'm familiar with that has a string data type that's wrapped in double quotes sometimes, but just written in at other times with no quoting whatever. It drives me nuts.  I think if they ever get to AHK2 strings will be double quoted always. Also they will dump the comma syntax. It's too primitive.

The trouble is it handles context specific hotkeys in a way that AutoIt can't. So I can't ignore it even if I'd like to. smiley


« Last Edit: June 12, 2012, 11:48:39 PM by MilesAhead » Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
rjbull
Charter Member
***
Posts: 2,742

View Profile Give some DonationCredits to this forum member
« Reply #7 on: June 13, 2012, 03:04:39 PM »

OP:  do you mean something like pasting the text of a form letter, with only the name changed?  If so, there are already ways of doing that without actually needing to write your own program.
Logged
ralphkru
Participant
*
Posts: 5


View Profile Give some DonationCredits to this forum member
« Reply #8 on: June 13, 2012, 11:35:17 PM »

Right.  I am, in fact, using a program that allows me to do that kind of thing (http://www.sector-seven.net/software/controlpad), but I'm really interested in trying to learn how to use AHK.  If something useful comes out of this, that would be frosting on the cake.

This program I stole straight out of the docs:
[copy or print]
InputBox, UserInput, Phone Number, Please enter a phone number., , 640, 480
if ErrorLevel
    MsgBox, CANCEL was pressed.
else
    MsgBox, You entered "%UserInput%"
This works fine and the variable containing the user's input does half of what I want.  Instead of the 2nd Msg Box, I want to send a sentence like Your phone number is %UserInput% to Word or Notepad or some other app.  I've tried replacing the 2nd MsgBox line with a Send command.  That didn't work.  I tried assigning a hotkey to the script, so I could actually be sitting in my target app when I called the script up.  That didn't work.  I've been looking at WinActivate, but I'm not sure how to use that.  Mainly, I'm not sure if the problem is in the script (syntax) or that I'm lacking a command.
Logged
Target
Honorary Member
**
Posts: 1,394



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #9 on: June 14, 2012, 12:23:23 AM »

This program I stole straight out of the docs:
[copy or print]
InputBox, UserInput, Phone Number, Please enter a phone number., , 640, 480
if ErrorLevel
    MsgBox, CANCEL was pressed.
else
    MsgBox, You entered "%UserInput%"
This works fine and the variable containing the user's input does half of what I want.  Instead of the 2nd Msg Box, I want to send a sentence like Your phone number is %UserInput% to Word or Notepad or some other app.  I've tried replacing the 2nd MsgBox line with a Send command.  That didn't work.  I tried assigning a hotkey to the script, so I could actually be sitting in my target app when I called the script up.  That didn't work.  I've been looking at WinActivate, but I'm not sure how to use that.  Mainly, I'm not sure if the problem is in the script (syntax) or that I'm lacking a command.

here's a super simple example using 2 hotkeys (one for input, and one for output) -

[copy or print]
#persistent
#singleinstance, ignore

#I::InputBox, UserInput, Enter a phone number,,, 150, 90

#O::sendinput, Your input value was '%userinput%'

WIN+I invokes the input box and populates the var UserInput with a value (or not, if you cancel the dialog)

WIN+O sends the output to wherever the cursor is (so some care may need to be taken)

Of course you can make this a lot more sophisticated depending on your requirements, but this covers the basics of what you're trying to do
Logged

"Look wise, say nothing, and grunt. Speech was given to conceal thought" - Sir William Osler
ralphkru
Participant
*
Posts: 5


View Profile Give some DonationCredits to this forum member
« Reply #10 on: June 14, 2012, 12:49:37 AM »

Sendinput.  I thought I'd read everything relating to Send.  Missed that.  This looks good.  I'll test it tomorrow, when I may have more questions.  Thanks very much.
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.03s | Server load: 0.17 ]