SteveM8 Posted January 12, 2007 Posted January 12, 2007 Okay, I admit it. I haven't done my tutorial as I should but I have made a lot of useful scripts for my job. Scripts that move files around in the database; log off stale accounts; parse credit card info; even some simple ones to save users some keystrokes. But, this one has got me stumped. I can do WinGetTitle and then display the $text in a MsgBox. But what I need to do is get the title into Notepad, edit it and then paste it directly into the advertisement. We run classified ads and want to grab the ad number that appears in the Title Bar of our ads app. and paste that along with "@careerz.com" into the ad. Below is what I have so far but I can't figure out how to paste the $text into Notepad instead of displaying a MsgBox (don't wanna do that!) WinWait("AdPower! - ","") If Not WinActive("AdPower! -","") Then WinActivate("AdPower! - ","") WinWaitActive("AdPower! - ","") $text = WinGetTitle("AdPower! - ", "") MsgBox(0, "", $text) I know I'm gonna be embarrassed when I find out how easy this is. :"> Steve
therks Posted January 12, 2007 Posted January 12, 2007 A simple idea would be to use ClipPut($text) instead of the MsgBox. Then just open Notepad and paste. You could also try opening Notepad (or any text editor) making sure it has focus, and then use Send($text, 1). My AutoIt Stuff | My Github
xcal Posted January 12, 2007 Posted January 12, 2007 (edited) Are you writing to a text file specifically for editing the string? You could do something along the lines of (and skip writing it to notepad - then paste it to your ad): $str = 'this is some number 123456781011121314 in some window title' $num = StringRegExp($str, '[0-9]+', 2) MsgBox(0, '', $num[0] & '@careerz.com') Edited January 12, 2007 by xcal How To Ask Questions The Smart Way
SteveM8 Posted January 12, 2007 Author Posted January 12, 2007 (edited) Wow! Both solutions work great. I have Saunders' working with Notepad but having it flash on the screen is kind of cumbersome. Will work with xcal's tomorrow and see if it's more elegant. The title is "AdPower! - Classified Ad# : 012345678" and I just need the ad # but have to trim off the leading 0. Thanks so much, this is one really wonderful place. Steve Edited January 12, 2007 by SteveM8
Moderators SmOke_N Posted January 12, 2007 Moderators Posted January 12, 2007 (edited) MsgBox(64, 'Info', _DontKnowWhatToCallThis()) Func _DontKnowWhatToCallThis() $OptWTMM = Opt('WinTitleMatchMode', 2) Local $sTitle = WinGetTitle("AdPower!") Opt('WinTitleMatchMode', $OptWTMM) If Not $sTitle Then Return SetError(1, 0, '') Local $aArray = StringRegExp($sTitle, '(?i)AdPower! - Classified Ad# : 0*(\d+)', 1) If IsArray($aArray) Then Return $aArray[0] Return SetError(2, 0, '') EndFunc Edited January 12, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
SteveM8 Posted January 13, 2007 Author Posted January 13, 2007 (edited) Okay, Smoke_N... way above my head but I'm sure it would work elegant. Here's what I have come up with. BlockInput(1) WinWait("AdPower!","") If Not WinActive("AdPower!","") Then WinActivate("AdPower!","") WinWaitActive("AdPower!","") $text = WinGetTitle("AdPower!", "") $text = StringRight($text, 6) $email = ("@applypd.com") Send($text) Send($email) BlockInput(0) This works fine as long as the AdPower! application is running. But when the app is not up, BlockInput causes the PC to appear locked. I'll have to get into the manual and figure this one out, still learning the language. Thanks again for all the great help. Steve Mate Edited January 13, 2007 by SteveM8
SteveM8 Posted January 13, 2007 Author Posted January 13, 2007 Okay, I spoke too soon. I found a simple solution that works nice. BlockInput(1) WinActivate("AdPower!","") If Not WinActive("AdPower!","") Then Exit $text = WinGetTitle("AdPower!", "") $text = StringRight($text, 6) $email = ("@applypd.com") Send($text) Send($email) BlockInput(0) I do believe that this makes me happy.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now