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 

Using ControlGetText and adding it to an edit

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
i<3U
Guest





PostPosted: Wed May 20, 2009 12:17 am    Post subject: Using ControlGetText and adding it to an edit Reply with quote

hmm ok, im trying to make this cool messenger for when im at work( Very Happy) but i can't get the basic function to work. basically what i want is for the script to wait until a message comes , and then retrieve the information form the message, and add it to an edit field in a gui( keeping the older text in the edit aswell). i have achieved everything exept to keep the older text that is; it updates when a new message comes but the older text is removed. also it's kind of glitchy xD, it seems that when i give the gui(with edit field) focus, the text goes back to what it origonaly was , unless i drag somthing over it..it's weird lol ..anyways, here's my script:
Code:

Gui, Add, Edit, x6 y0 w460 h370 +ReadOnly,Wecome To Robbie's Messenger
Gui, Show,  +NoActivate,Messenger By Robbie
loop{
winwait,Messenger Service
controlgettext,oldtxt,edit,Messenger By Robbie
wingettext,newtxt,Messenger Service,from
WinClose , Messenger Service
StringReplace, newtxt, newtxt, OK,, All
fulltxt=%oldtxt%`n %newtxt%
Gui, Add, Edit, x6 y0 w460 h370 +ReadOnly,%fulltxt%
Gui, Show, +NoActivate,Messenger By Robbie
}
GuiClose:
ExitApp

I hope it's somthing simple Smile , thanks for any responses
Back to top
i<3U
Guest





PostPosted: Wed May 20, 2009 12:20 am    Post subject: Reply with quote

Also, for those that don't know, you must enable, and start the messenger service ( Windows XP), and then to test just use "Net Send * Hello" without the quotes in the command prompt.
Back to top
System Monitor



Joined: 09 Mar 2007
Posts: 509
Location: Unknown

PostPosted: Wed May 20, 2009 12:22 am    Post subject: Reply with quote

well if you view the variable oldtext there is nothing in it. this is how I checked
Code:
Gui, Add, Edit, x6 y0 w460 h370 +ReadOnly,Wecome To Robbie's Messenger
Gui, Show,  +NoActivate,Messenger By Robbie
loop{
;winwait,Messenger Service
controlgettext,oldtxt,edit,Messenger By Robbie
msgbox %oldtxt%
}

So you are retreiving the text wrong. You should just keep it in a variable in the beginning instead of retrieving it from the edit box.
Back to top
View user's profile Send private message Visit poster's website
i<3U
Guest





PostPosted: Wed May 20, 2009 12:32 am    Post subject: Reply with quote

hmm thanks for the quick response, i just tried using wingettext instead of control, but i think my problem is that it has a difficult time retrieving text from an edit field. would you, or anyone for that matter, have a suggestion on a better way to keep the old text, and add the new text?
thanks again
Back to top
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Wed May 20, 2009 12:51 am    Post subject: Reply with quote

I don't think your text was ever removed, it was never there because you never got it:

Code:
ControlGetText, oldtxt, Edit1, Messenger By Robbie


And you should be able to pretty much put it back the same way you got it:

Code:
WinGetText, newtxt, Messenger Service
WinClose , Messenger Service
StringReplace, newtxt, newtxt, OK,, All
fulltxt := oldtxt "`n" newtxt
ControlSetText, %fulltxt%, Edit1, Messenger By Robbie

_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
i<3U
Guest





PostPosted: Wed May 20, 2009 1:11 am    Post subject: Reply with quote

hmmm okay well here's the updated script
Code:

Gui, Add, Edit, x6 y0 w460 h370 +ReadOnly,Welcome To Robbie's Messenger
Gui, Show,  +NoActivate,Messenger By Robbie
loop{
winwait,Messenger Service
ControlGetText, oldtxt, Edit1, Messenger By Robbie
wingettext,newtxt,Messenger Service,from
WinClose , Messenger Service
StringReplace, newtxt, newtxt, OK,, All
fulltxt := oldtxt "`n" newtxt
ControlSetText, %fulltxt%, Edit1, Messenger By Robbie
}
GuiClose:
ExitApp

, but now it doesn't update the edit field at all, it just stays "Welcome To Robbie's Messenger " the whole time :p, i hope i can get this working, any other suggestions are greatly appreciated!
Back to top
I<3U
Guest





PostPosted: Wed May 20, 2009 1:33 am    Post subject: Reply with quote

sorry for the double post..again..but i think i am going to take a different approach, i am going to try to save the "newtxt" to a file, and then read the file, and display it. seems simple right? i have a feeling their will be errors >.> :p[/code]
Back to top
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Wed May 20, 2009 1:55 am    Post subject: Reply with quote

Try this:

Code:
Gui, Add, Edit, x6 y0 w460 h370 ,Welcome To Robbie's Messenger ; removed read-only attribute
Gui, Show,  +NoActivate,Messenger By Robbie
loop{
winwait,Messenger Service
ControlGetText, oldtxt, Edit1, Messenger By Robbie
wingettext,newtxt,Messenger Service,from
WinClose , Messenger Service
StringReplace, newtxt, newtxt, OK,, All
fulltxt := oldtxt "`n" newtxt
ControlSetText, %fulltxt%, Edit1, Messenger By Robbie
}
GuiClose:
ExitApp

_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
i<3U
Guest





PostPosted: Wed May 20, 2009 2:35 am    Post subject: Reply with quote

nope, still no dice, i'll try my new method, and let ya know whats up
Back to top
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Wed May 20, 2009 4:00 am    Post subject: Reply with quote

Gah, I did it backwards:

Code:
Gui, Add, Edit, x6 y0 w460 h370 ,Welcome To Robbie's Messenger ; removed read-only attribute
Gui, Show,  +NoActivate,Messenger By Robbie
loop{
winwait,Messenger Service
ControlGetText, oldtxt, Edit1, Messenger By Robbie
wingettext,newtxt,Messenger Service,from
WinClose , Messenger Service
StringReplace, newtxt, newtxt, OK,, All
fulltxt := oldtxt "`n" newtxt
ControlSetText, Edit1, %fulltxt%, Messenger By Robbie
}
GuiClose:
ExitApp

_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
I<3U
Guest





PostPosted: Wed May 20, 2009 7:18 pm    Post subject: Reply with quote

Hey ! , it works! Thanks for this sinkfaze, i really appreciate it!
Back to top
bqw371



Joined: 26 Nov 2008
Posts: 32

PostPosted: Thu May 21, 2009 7:32 pm    Post subject: microsoft messenger chat Reply with quote

Here's an update for you so that you can chat within the same window!

Code:
Gui, Add, Text,, PC name to send messenger msg to.
Gui, Add, Edit, vPCName
Gui, Add, Text,, What do you have to say today?
Gui, Add, Edit, vSpeak

Gui, Add, Button, x10 y95 Default, &Go
Gui, Add, Button, x40 y95  Default, Clear &Log
Gui, Add, Button, x10 y125 Default, Clear &PCName+msgbox
Gui, Add, Edit, x185 y0 w460 h370 ,Welcome To Robbie's Messenger ; removed read-only attribute
Gui, Show,  +NoActivate,Messenger By Robbie

loop{

winwait,Messenger Service
ControlGetText, oldtxt, Edit3, Messenger By Robbie
wingettext,newtxt,Messenger Service,from
WinClose , Messenger Service
StringReplace, newtxt, newtxt, OK,, ;Removed ALL just incase you want to reply with " OK "
fulltxt := oldtxt "`r`n" newtxt
ControlSetText, Edit3, %fulltxt%, Messenger By Robbie

}
GuiClose:
ExitApp

ButtonGo:
Gui, Submit, NoHide
if pcname = ;
{
msgbox, Who are you talking to?
return
}
if speak = ;
{
msgbox, What do you want to say?
Return
}
else
Run, %comspec% /k net send %pcname% %Speak%
sleep, 500
WinClose, %comspec%
EnvSet, PCName,
EnvSet, Speak,
Return

ButtonClearLog:
Gui, Submit, NoHide
ControlSetText, Edit3, , Messenger By Robbie
Return

ButtonClearPCName+msgbox:
Gui, Submit, NoHide
ControlSetText, Edit1, , Messenger By Robbie
ControlSetText, Edit2, , Messenger By Robbie
Return
Back to top
View user's profile Send private message
Display posts from previous:   
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