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.
Want to copy a line of text with a "wildcard" in it (a number) then use that value to perform actions off of it
-
- Posts: 14
- Joined: 29 Dec 2015, 16:52
- 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
Code: Select all
string := "Watch 13 more videos"
RegExMatch(string, "Watch (\d+) more videos", m)
msgbox % m1
Courses on AutoHotkey
My Autohotkey Blog
-
- 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
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:
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.
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.
-
- Posts: 319
- Joined: 23 Jan 2016, 23:03
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
If you want you can try out RegExstar, a RegEx tool designed specifically for AutoHotKey.
Who is online
Users browsing this forum: Google [Bot], JKJadan, Psych0p4th and 270 guests