Want to copy a line of text with a "wildcard" in it (a number) then use that value to perform actions off of it

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sjdheunaskdf9384348
Posts: 14
Joined: 29 Dec 2015, 16:52

Want to copy a line of text with a "wildcard" in it (a number) then use that value to perform actions off of it

23 Feb 2016, 17:10

Hello everyone! I'm new to AHK for the most part, and have been piecing together things for a few small projects over time.

Right now, I want to copy a line of text that is basically formatted as, "Watch X more videos" where X is the value I want to capture. I've seen Regex and I think that is how I'd have to do it, but to be completely honest it seemed way too complicated for me. Maybe I'm looking at it wrong...?

Anyway, from there, I'd like to keep track of that X value by either copying the contents of the page and looking for that string (which I've done something like that before, just not with an unknown variable like X). It will go down over time (since once a video is completed, the value changes). In certain cases I need to use that number to change how the script works. As of right now, fetching the X value seems to be the best way for accomplishing what I want to do.

Any ideas? I'd really appreciate any help I can get.
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: Want to copy a line of text with a "wildcard" in it (a number) then use that value to perform actions off of it

23 Feb 2016, 17:30

Code: Select all

string := "Watch 13 more videos"
RegExMatch(string, "Watch (\d+) more videos", m)
msgbox % m1
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
sjdheunaskdf9384348
Posts: 14
Joined: 29 Dec 2015, 16:52

Re: Want to copy a line of text with a "wildcard" in it (a number) then use that value to perform actions off of it

23 Feb 2016, 19:39

Thank you so much, I seriously appreciate your help. I can't believe how simple that was... now I feel stupid. I'm going to start learning RegEx because it seems incredibly powerful and useful in many situations.

In case anyone was wondering, this is how I made it work for the website:

Code: Select all

WinActivate, %websitesVariableNameHere%
SendInput {CTRL down}
sleep, miniRoll
SendInput {a}{CTRL up}
sleep, miniRoll
SendInput {CTRL down}
sleep, miniRoll
SendInput {c}{CTRL up}
ClipWait

string := Clipboard
RegExMatch(string, "Watch (\d+) more videos", m)
msgbox % m1


Note, miniRoll is one of the variables I have that is randomized to avoid being detected as a computer (i.e exactly every 5 seconds a task is completed). Also, I'm pretty sure there is a better (shorter and cleaner) way to write those copy inputs, but I've had trouble in the past with some inputs.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Draken, Google [Bot] and 215 guests