Failing to copy selected text after using findtext.ahk

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
theworstahkuserever
Posts: 1
Joined: 29 Sep 2022, 23:45

Failing to copy selected text after using findtext.ahk

Post by theworstahkuserever » 29 Sep 2022, 23:53

The text below is being used to automate parts of my WFH job so I have more free time, but one the copy commands after findtext are failing to copy. Can anyone help me understand why?

Code: Select all

If (Open1 = 1)
{
if WinExist("Finale")
{ coordmode, pixel, window

WinActivate 
Sleep 200
WinMaximize 
Sleep 200
WinGetPos, finalewindowx, finalewindowy, finalewidth, finaleheight, Finale
PixelSearch, SalesLogox, SalesLogoy, finalewindowx, finalewindowy, finalewidth, finaleheight, 0xACD360, 3, Fast RGB
MouseMove, SalesLogox, SalesLogoy, 0
MouseMove, 48, 25, 2, r
Click, 2
Sleep 200
Send ^c ;copy order number
Sleep 200
;OrderNumber := ClipBoard
OrderNumber := RegExReplace(Clipboard,"[a-zA-Z,$\h]")  
msgbox, 4, Is this your order number?, %ordernumber%
IfMsgBox No 
Return
Else
send ^{home}
sleep 200
Send ^a
sleep 200
send ^c ; this text remains in the clipboard even after attempting to copy text further down in the script
sleep 200
Pos:=1 ;set starting position
Pos_Found:=RegExMatch(ClipBoard,"i)(?:[\w_0-9\.-]+)@(?:[\w\.-]+)\.(?:[a-z_0-9\.]{2,6})",bcorderemail)
SearchBigCommerce := "microsoft-edge:https://store-dl52lpq.mybigcommerce.com/manage/orders/search/results?advancedSearch=true&keywords=" . bcOrderEmail . "&sortField=orderid&sortOrder=desc&searchByDate=0&orderTo=" . OrderNumber . "&orderFrom=" . OrderNumber . "&searchDeletedOrders=no&preOrders=0,1"
Run %SearchBigCommerce%
Sleep 3000

;the section below works when run by itself, but not in conjunction with the code above

#include findtext.ahk
t1:=A_TickCount, bcfind1:=X1:=Y1:=""
bcfind1:="|<emailsign>*214$20.0000000zzw801300kk0AD0D2M6EX348TV21UEU048013zzk0000008"
if (ok:=FindText(X1, Y1, -1461-150000, 551-150000, -1461+150000, 551+150000, 0, 0, bcfind1))
{
FindText().Click(X1, Y1, "L")
}
mousegetpos, xpos1, ypos1 
#include findtext.ahk
t1:=A_TickCount, bcfind2:=X2:=Y2:=""
bcfind2:="|<manualtaxsign>*219$20.0003zw1U3UE0w40BV03AHaTZd1tOk2Kf0Yps91G2EaUY8k9002M01Xzzk000U"
if (ok:=FindText(X2, Y2, -1462-150000, 845-150000, -1462+150000, 845+150000, 0, 0, bcfind2))
{
FindText().Click(X2, Y2, "L")
}				
mousegetpos, xpos2, ypos2  
mouseclickdrag left, xpos1, ypos1,xpos2, ypos2, 2
sleep 100
sendinput {ctrl down}c{ctrl up}
msgbox %clipboard%
return

User avatar
boiler
Posts: 17065
Joined: 21 Dec 2014, 02:44

Re: Failing to copy selected text after using findtext.ahk

Post by boiler » 30 Sep 2022, 03:43

How could it work at all when you #Include FindText.ahk twice? That shouldn’t be able to run without a duplicate function error.

Rohwedder
Posts: 7679
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Failing to copy selected text after using findtext.ahk

Post by Rohwedder » 30 Sep 2022, 04:16

Hallo,
see https://www.autohotkey.com/docs/commands/_Include.htm#Remarks
#Include ensures that FileName is included only once, even if multiple inclusions are encountered for it.

Code: Select all

;  FindText - Capture screen image into text and then find it
;  https://autohotkey.com/boards/viewtopic.php?f=6&t=17834
#include findtext.ahk
#include findtext.ahk
MsgBox, Hallo
TheWorstAhkUserEver shows a broken part of a script which somehow doesn't work on one side!
(I hope he doesn't go to the optician with one of his mother's eyes to buy glasses for her.)

User avatar
boiler
Posts: 17065
Joined: 21 Dec 2014, 02:44

Re: Failing to copy selected text after using findtext.ahk

Post by boiler » 30 Sep 2022, 04:42

Ah, thanks.

Post Reply

Return to “Ask for Help (v1)”