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 

Help with string replacement

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



Joined: 01 Sep 2008
Posts: 10

PostPosted: Sun Sep 07, 2008 4:51 pm    Post subject: Help with string replacement Reply with quote

I have a web based form that continually fill out during the day, in the form are several text boxes that holds certain data. What I want to do is to be able to create a script where when I click on the right mouse button while it hovers over one of the text boxes it will automatically put the data in. I've looked in the help file at the StringReplace command but I cannot figure out how to get the script to read what is in the text then replace it with the data.
I've also looked into using the auto replace method but again need to figure out how to get the control read. Any help in getting me started would be appreciated.
_________________
Bob Carruth
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Icarus



Joined: 24 Nov 2005
Posts: 507

PostPosted: Mon Sep 08, 2008 9:35 am    Post subject: Re: Help with string replacement Reply with quote

Not sure what exactly you are looking for, but maybe this will help.

In the below code, you can right click on a field (provided by a sample GUI, can also be an HTML field) and then it will copy the text currently in it, so that it can be evaluated and according to its contents, paste an alternative text.

StringReplace is intended to replace specific characters inside a string.

Code:


#SingleInstance Force
DataStart := "Right click this field"
Data1     := "Hello World"
Data2     := "I am the second one"

Gui Add, Edit, w200, %DataStart%
Gui Show

Return

RButton::
  Clipboard := ""                 ; Empty the clipboard
  Send {LButton}{End}+{Home}^c    ; Copy the selected text in the field
  ClipWait 2
  If( Not ErroLevel ) {
    If( Clipboard = DataStart )   ; See what we copied and act accordingly
      Send %Data1%
    Else
      Send %Data2%
  }
Return

_________________
Sector-Seven (Music and Utilities)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
rcarruth



Joined: 01 Sep 2008
Posts: 10

PostPosted: Mon Sep 08, 2008 11:27 pm    Post subject: Reply with quote

Thanks Icarus, the code you sent me worked the way I wanted, just had to make a few tweaks to it to suit my exact needs. But I now understand how to read the data in the fields which was my major problem before. Thanks again.
_________________
Bob Carruth
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
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