Jump to content

Can I paste WinGetTitle $text into Notepad?


SteveM8
 Share

Recommended Posts

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

Link to comment
Share on other sites

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 by xcal
Link to comment
Share on other sites

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 by SteveM8
Link to comment
Share on other sites

  • Moderators

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 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.

Link to comment
Share on other sites

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 by SteveM8
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...