Sign in to follow this  
Followers 0
SteveM8

Can I paste WinGetTitle $text into Notepad?

7 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by xcal

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by SteveM8

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by SteveM8

Share this post


Link to post
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
Sign in to follow this  
Followers 0