AutoHotkey Community

It is currently May 27th, 2012, 6:05 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 73 posts ]  Go to page Previous  1, 2, 3, 4, 5
Author Message
 Post subject:
PostPosted: October 16th, 2010, 4:56 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
Rapte_Of_Suzaku wrote:
Code:
regex:="s).*-{14}(.*?)Thanks$"
RegExMatch(text,regex,match)
MsgBox  %match1%


I'm no expert on AutoHotkey by any means, and While I have tested your code above to make sure exactly what it was doing, I don't fully understand how... Rapte_Of_Suzaku, could you break down for me how this is "parsing" the text and coming up with %match1%? When I first looked at you code I thought it was simply finding the 1 match but after doing the editing I did in the previous post it appears that it is finding the last match, I was going to suggest using StringSplit command and a loop to find the last match, but your RegEx appears to be doing it automatically...


Last edited by samhnky on October 16th, 2010, 5:41 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2010, 5:21 pm 
Offline

Joined: September 26th, 2010, 6:16 pm
Posts: 135
I *think* I've got it. The RegEx stuff is not working for me. Sounds like user error. :cry:

You can probably see what I'm trying to accomplish here:

Code:
newpos = %Length% - %pos% - 29


How would I make this work? Seems like a comma or colon is not in there. :/

Length is the total length of the selection.
pos is the first time in that selection you find the dashes.
29 should be the number to cut out of the first of the selection.

That *should* work and *should * work for the other responses I get from CRT. :? :?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2010, 5:56 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
AHK Newbie wrote:
I *think* I've got it. The RegEx stuff is not working for me. Sounds like user error. :cry:


I tell you it really urks people trying to help you when you state something is not working for you and do not give an explenation, other than "I'm a newbie, so here is what I'm trying to do instead"...

AHK Newbie wrote:
You can probably see what I'm trying to accomplish here:

Code:
newpos = %Length% - %pos% - 29

I have no clue what you are doing here because I have no before/after code...

Now please tell me what your problem with RegEx is, so that we can address the problem... Based on what you have explained that you want to do here, it is the solution "Period"...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2010, 6:09 pm 
Offline

Joined: September 26th, 2010, 6:16 pm
Posts: 135
Everything is right there and was explained in my reply.

Quote:
newpos = %Length% - %pos% - 29


How would I make this work? Seems like a comma or colon is not in there. :/

Length is the total length of the selection.
pos is the first time in that selection you find the dashes.
29 should be the number to cut out of the first of the selection.


I want to save the variable into newpos. %Length% minus %pos% minus 29. I explained everything below my code. I also explained that using RegEx was confusing and was not working for me. The entire code:

Code:
^+LButton::

   MouseMove, 45, 705, 4
   Sleep, 250
   Click, Down
   Sleep, 150
   MouseMove, 13, 400, 20
   Sleep, 150
   Click, Up
   ClipWait, 2
   
text := Clipboard

Length := StrLen(text)
pos := InStr(text, "---------------------------")
newpos = %Length% - %pos% - 29
StringTrimLeft, OutputVar, text, newpos
MsgBox Length:`n%Length%
MsgBox pos:`n%pos%
MsgBox newpos:`n%newpos%
Msgbox OutputVar:`n%OutputVar%
Msgbox clipboard:`n%clipboard%


I've searched all morning and did not find a clear way to do a simple subtraction.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2010, 6:36 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
I really wish you would say why its not working, or how its not working, instead of "its not working"
Try:
Code:
Send, ^a
ClipWait, 2
text := Clipboard
regex:="s).*-{14}(.*?)Thanks$"
RegExMatch(text,regex,match)
MsgBox  %match1%


Do not use your Mouse moves with the above script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2010, 8:34 pm 
Offline

Joined: September 26th, 2010, 6:16 pm
Posts: 135
The above code has and still gives me a blank message box.

If I do not select the text by mouse, how do I select the text?

As far as saying "it doesn't work", I think it's obvious what I'm trying to do here:
Code:
newpos = %Length% - %pos% - 29


The variable Length minus the variable pos minus the number 29. Put all that math into the variable newpos. I think I have the rest of the script working, so I did not post the entire script, only the line I had the issue with.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2010, 8:47 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
Try:
Code:
Send, !ea^c ;Sending "Alt+E"(opens the edit window)"A"(Select All)"Control+C"(Copy, this is needed since the auto copy on select is based off of Mouse select.)
ClipWait, 2
text := Clipboard
regex:="s).*-{14}(.*?)Thanks$"
RegExMatch(text,regex,match)
MsgBox  %match1%


Again, no mouse movements required.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2010, 8:52 pm 
Offline

Joined: September 26th, 2010, 6:16 pm
Posts: 135
As previously explained, 'select all' selects the ENTIRE contents. Not just what is inside the window, but the 5 miles of text above it. I would use it if I could.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2010, 8:57 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
AHK Newbie wrote:
As previously explained, 'select all' selects the ENTIRE contents. Not just what is inside the window, but the 5 miles of text above it. I would use it if I could.


As I have previously tried to state (Posted: Sat Oct 16, 2010 11:42 am) the RegEx command is scanning through the entire clipboard and only grabbing the text at the end of the clipboard that matches

    Last Name,

    3 lines of text.

    Addy1
    Addy2
    Addy3
    Addy4

    3 lines of text.

    Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2010, 9:14 pm 
Offline

Joined: September 26th, 2010, 6:16 pm
Posts: 135
"The above code has and still gives me a blank message box. "

"As far as saying "it doesn't work", I think it's obvious what I'm trying to do here:
Code:
newpos = %Length% - %pos% - 29"

Okay, RegEx is not working for me. We'll try this. How do you subtract two variables?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2010, 10:00 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
I think it is because you have 15 "-" try...

Code:
Send, !ea^c ;Sending "Alt+E"(opens the edit window)"A"(Select All)"Control+C"(Copy, this is needed since the auto copy on select is based off of Mouse select.)
ClipWait, 2
text := Clipboard
regex:="s).*-{15}(.*?)Thanks$" ;Changed the 14 to 15 to account for 15"-"
RegExMatch(text,regex,match)
MsgBox  %match1%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2010, 2:16 am 
Offline

Joined: September 26th, 2010, 6:16 pm
Posts: 135
I counted 27 -'s so I put 27 in there. Still not working. :/ But I finally tweaked this enough to get it to work.

Code:
text := Clipboard

length := StrLen(text)
pos := InStr(text, "---------------------------")
newpos := (length - pos - 32)
newpos2 := length - newpos
StringTrimLeft, OutputVar, text, newpos2

Msgbox OutputVar:`n"%OutputVar%"


Length is not the same as length. Out of desperation, I put the variable in all lowercase. Doesn't make total sense to me, but that did the trick.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2010, 2:42 am 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
That's why I asked earlier if you got 15 of them every time...

Code:
Send, !ea^c
ClipWait, 2
text := Clipboard
regex:="s).*-{15,}(.*?)Thanks$" ;Adding the "," makes the code say 15 or more.
RegExMatch(text,regex,match)
MsgBox  %match1%


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 73 posts ]  Go to page Previous  1, 2, 3, 4, 5

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Bing [Bot], dra, HotkeyStick, migz99, mKnight, Wicked, XstatyK and 54 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group