| Server IP : 172.67.134.114 / Your IP : 162.159.115.41 Web Server : Apache/2.4.37 System : Linux almalinux.duckdns.org 4.18.0-553.111.1.el8_10.x86_64 #1 SMP Sun Mar 8 20:06:07 EDT 2026 x86_64 User : ricodeal ( 1046) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/ricodeal/public_html/wp-content/uploads/ |
Upload File : |
#NoEnv
#SingleInstance off
SendMode Input
SetTitleMatchMode 2
#WinActivateForce
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1
; testing area
;~ msgbox, test
;~ gosub, makeClose
;~ test:=Array("test","test2")
;~ Xls := Excel_Objects.Xls()
;~ for index, Xl in Xls
;~ {
;~ msgbox, %index%
;~ for WB in Xl.Workbooksflexible3
;~ {
;~ fullpath:=WB.path . "\" . WB.name
;~ msgbox, %fullpath%`n%localPath%
;~ ;msgbox, %fullpath%`n%v%
;~ if(fullpath=localPath)
;~ {
;msgbox, closing %fullpath%
;~ WB.Close(0)
;~ break
;~ }
;~ }
;~ }
;~ msgbox, end - close me
debug_mode:=false
/*
ADDING NETWORK DRIVES MUST DO THIS FOR OTHER COMPUTERS TO SEE ON THE NETWORK
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
After approaching the address mentioned above, create a new "DWORD Value." For creating the DWORD Value, click right and select the key.
create a new value
Rename the entered value as EnableLinkedConnections and click right for modifying the entered value to 1.
*/
; end of testing area
KEYS_ini = Z:\Formula\Macros\KEYSforAHK.ini
IniRead,secretcode,%KEYS_ini%,Keys,secretcode
IniRead,port1,%KEYS_ini%,KEYS,store_port1
IniRead,port2,%KEYS_ini%,KEYS,store_port2
IniRead,ip,%KEYS_ini%,Keys,store_ip
IniRead,password,%KEYS_ini%,Keys,store_password
IniRead,passwords,%KEYS_ini%,Keys,store_passwords
;;;;;;;file for ip and port and code in Z:\Formula\Macros\KEYSforAHK.ini #####LOOK FOR CODE AND PORT AND IP THERE########
html := UrlDownloadToVar("http://www.google.com")
if html
{
gosub, Warns
}
else
{
ExitApp
;;;;; NO Return Here
}
Warns:
FileCreateDir, %a_appdata%\macro
myDir=%a_appdata%\macro
Alert("COMPLETING TASK","THIS COMPUTER IS AUTOMATING TASK!!! DO NOT TOUCH THE COMPUTER FOR 5 MINUTES.","0", "500")
doneFiles:=[]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;if CLOSE.AHK DOES NOT EXIST, CREATE A FILE IN THE SAME DIRECTORY ------------START---------------;;;;;;;;;;;;;;;;
sleep, 3000
Sendraw, flexible3
sleep, 1000
Send, {Escape}
;~ onexit, exitsub
;~ /*
gosub, makeClose
;~ */
;;;;;;;;;;;;;;checks if directory has files START -------part A;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Returnlabel:
SendMode Input
counter=0
Dir = Z:\Formula\Cancel
Sleep, 2000
CheckDir := IsEmpty(Dir)
;msgbox, dir: %CheckDir%
If CheckDir=0
{
;sleep, 3000flexible3
;FormatTime, Time2, %Time%, hh:mm tt
;~ msgbox, send
;Text := "CANEL script was ran, NO FILES FOUND on " A_DD " " A_MMMM " " A_YYYY " at " Time2 " "
sendRemoteLog("CANCEL script was ran, NO FILES FOUND",ip, port2)
;~ sleep,2000
;MsgBox, 0, , App Exit, 0.001
Sleep,2000
;~ ListLines
ExitApp
}
else
{
Goto, Determine
}
Determine:
Folder_path = Z:\Formula\Cancel
loop,%Folder_path%\*
{
if(HasVal(doneFiles,a_loopfilefullpath))
continue
doneFiles.Push(A_LoopFileFullPath)
sendCheck(["E:\Formula\Inventory.xlsm","Z:\Formula\Inventory.xlsm"]
,["E:\Formula\InventLog.xlsm","Z:\Formula\InventLog.xlsm"])
SplitPath,A_LoopFileFullPath,,,,variable1
Last_letter := SubStr(variable1,-1,1)
;~ msgbox, is this ltr or nmr: %Last_letter%
if Last_letter is number ; if last letter is number
{
fileName:=SubStr(variable1, 3)
;;;msgbox %filename%
folderName:=SubStr(variable1,3,-18)
;;;msgbox %folderName%
JustFolder:=SubStr(variable1, 3)
;;;msgbox %JustFolder%
JustFiles:=SubStr(variable1, 3, -18)
;;;msgbox %JustFiles%
JustInv:=SubStr(variable1, -16)
;;;msgbox %JustInv%
; Last CHARACTER is number -
; can you run it
;;;msgbox, %variable1%`n%filename%`n%foldername%
sendCheck(["E:\TRANSFER\DESIGNS\" folderName . "\Q_" fileName ".xlsm","Z:\TRANSFER\designs\" folderName . "\Q_" fileName ".xlsm"]
,["E:\TRANSFER\DESIGNS\" folderName . "\~$Q_" fileName ".xlsm","Z:\TRANSFER\designs\" folderName . "\~$Q_" fileName ".xlsm"])
gosub, Adjusting
;~ erase(["Z:\Formula\Cancel\" variable1 ".xlsm"],"file")
erase(["Z:\TRANSFER\designs\" JustFiles "\" variable1 ".xlsm","Y:\TRANSFER\designs\" JustFiles "\" variable1 ".xlsm","Z:\Formula\Cancel\" variable1 ".xlsm","Z:\TRANSFER\designs\" JustFiles "\" variable1 ".pdf","Y:\TRANSFER\designs\" JustFiles "\" variable1 ".pdf","Z:\Formula\Invoices\" JustInv ".pdf","Y:\TRANSFER\Formula\Invoices\" JustInv ".pdf"],"file")
sendRemoteLog(A_ComputerName " FOUND FILES " variable1 ".xlsm " ,ip, port2)
; Last CHARACTER is letter - END there is a messagebox somewhere
}
else
{
; Last CHARACTER is letter - START
fileName:=SubStr(variable1, 3)
folderName:=SubStr(variable1,3)
sendCheck(["D:\TRANSFER\DESIGNS\" folderName . "\Q_" fileName ".xlsm","Z:\TRANSFER\designs\" folderName . "\Q_" fileName ".xlsm"]
,["E:\TRANSFER\DESIGNS\" folderName . "\~$Q_" fileName ".xlsm","Z:\TRANSFER\designs\" folderName . "\~$Q_" fileName ".xlsm"])
erase(["Z:\Formula\Cancel\" variable1 ".xlsm"],"file")
erase(["Z:\TRANSFER\designs\" folderName,"Y:\TRANSFER\designs\" folderName],"dir")
sendRemoteLog(A_ComputerName " FOUND FOLDE " variable1 ".xlsm " ,ip, port2)
; Last CHARACTER is letter - END
}
}
;;goto, Returnlabel ;;after it finishes from 'erase'..
return ; not needed
erase(pathList,what:="file",hide:=true)
{
pathStr:=""
for k,v in pathList
{
pathStr.=what "=""" v """ "
}
pathStr:=SubStr(pathStr,1,-1)
;~ cmd=& 'C:\Program Files\Eraser\Eraser.exe' erase /quiet /Gutmann %pathStr% ; ;exit
cmd="C:\Program Files\Eraser\Eraser.exe" erase /quiet /Gutmann %pathStr% ; ;exit
;clipboard:=cmd
;msgbox, %cmd%
; try to run it and lets see what it does
;~ RunWait, PowerShell.exe -NoExit -Command "%cmd%" ;,,% (hide ? "Hide" : "")
RunWait, %comspec% /c "%cmd%",,% (hide ? "Hide" : "")
; RunWait *Runas PowerShell.exe -NoExit -Command "%cmd%",,% (hide ? "Hide" : "")
}
;;it comes back to here thoug..because it does the above function
; there, now it's using cmd instead of ps,
;~ Obtainname:
;~ Run, Z:\Formula\Cancel
;~ Sleep, 1000
;~ Send, {Alt Down}{d}{Alt Up}
;~ Sleep, 1000
;~ Send, {Tab}
;~ Sleep, 500
;~ Send, {Tab}
;~ Sleep, 500
;~ Send, {Tab}
;~ Sleep, 500
;~ Send, {Space}
;~ Sleep, 750
;~ Send, {F2}
;~ Sleep, 1000
;~ Gosub, CopyVar
;~ Sleep, 1000
;~ Send, {Escape}
;~ Sleep, 500
;~ Winclose A
;~ Sleep, 500
;~ sendRemoteLog("" A_ComputerName " FOUND FILES " variable1 ".xlsm " , "sdhome.duckdns.org",5801)
;~ fileName:=SubStr(variable1, 3)
;~ folderName:=SubStr(variable1,3,-17)
;~ msgbox, %variable1%`n%filename%`n%foldername%
;~ sendCheck(["D:\Formula\Inventory.xlsm","Z:\Formula\Inventory.xlsm"]
;~ ,["D:\Formula\InventLog.xlsm","Z:\Formula\InventLog.xlsm"]
;~ ,["D:\TRANSFER\DESIGNS\" folderName . "\Q_" fileName ".xlsm","Z:\TRANSFER\designs\" folderName . "\Q_" fileName ".xlsm"]
;~ ,["D:\TRANSFER\DESIGNS\" folderName . "\~$Q_" fileName ".xlsm","Z:\TRANSFER\designs\" folderName . "\~$Q_" fileName ".xlsm"])
;~ gosub, Inventlog
;~ Sleep, 500
;~ Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;START;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;THIS IS WHERE IT LOOKS FOR FILE ON REMOTE COMPUTER AND CLOSES THE FILE, MUST HAVE THE FILE 'CLOSE.AHK' IN THE SAME FOLDER AS THIS SCRIPT;;;;;;;;;;;;;;;
sendCheck(toCloseFiles*)
{
global myDir,debug_mode
touseDir:=strreplace(myDir,"'","''")
for key,curFile in toCloseFiles
{
localPath:=curFile[1]
remotePath:=curFile[2]
;msgbox, % curFile[1]
psScript :="Get-SmbOpenFile | Format-List | Out-File -FilePath '" . touseDir . "\temp_out.txt'"
;;;Run powershell -Command "taskkill -f -im acrobat.exe"
RunWait *runas PowerShell.exe -Command %psScript%; "taskkill -f -im acrobat.exe",, hide
; Use this call if you want to see PowerShell output
; Run powershell.exe -NoExit -Command %psScript%
fileread, outText, %myDir%\temp_out.txt
if(debug_mode)
msgbox, %outText%
rows:=StrSplit(outText,"`r`n")
for k,v in rows
{
cols:=StrSplit(v," : ")
if(StrReplace(cols[1]," ") == "FileId")
{
thisOne=0
}
if(StrReplace(cols[1]," ") == "Path")
{
;~ msgbox, % StrReplace(cols[2]," ") . "`n" . StrReplace(localPath," ") "`nor`n" StrReplace(remotePath," ")
if(StrReplace(cols[2]," ")=StrReplace(localPath," "))
{
thisOne=1
;msgbox, found match
}
}
if(StrReplace(cols[1]," ") == "ClientComputerName")
{
If(thisOne)
{
;~ msgbox, % "its " . cols[2]
replacedStr:=StrReplace(cols[2]," ")
;fileappend, Sending request to close file to ip %replacedStr% | %A_DD% %A_MMMM% %A_YYYY% at %A_Hour%:%A_Min%`n, closelog.txt
if(debug_mode)
msgbox, closing on ip:%replacedStr%`npath %remotePath% or %localPath%
;~ msgbox, closing file Z:\%folderName%\Q_%fileName%.xlsm on ip %replacedStr%
;~ clipboard=%replacedStr% "Z:\%folderName%\Q_%fileName%.xlsm"
;~ msgbox, clipboard set
SplitPath,remotePath,fileName
thisclosed=1
if(fileName="Inventory.xlsm")
run, %myDir%\close.ahk %replacedStr% "Inventory"
else
{
;~ clipboard=%myDir%\close.ahk %replacedStr% "%remotePath%"
run, %myDir%\close.ahk %replacedStr% "%remotePath%"
}
break
}
}
}
FileDelete, %myDir%\temp_out.txt
;~ msgbox, checking locally
Xls := Excel_Objects.Xls()
for index, Xl in Xls
{
;msgbox, %index%
for WB in Xl.Workbooks
{
fullpath:=WB.path . "\" . WB.name
;~ msgbox, %fullpath%`n%localPath%
;msgbox, %fullpath%`n%v%
if(fullpath=localPath)
{
if(debug_mode)
msgbox, closing %fullpath% locally
WB.Close(0)
break
}
}
}
WinGet, Instances, Count, ahk_class XLMAIN
;~ msgbox, %Instances%
loop, %Instances%
{
WinSet, Top,, ahk_class XLMAIN
WinActivateBottom , ahk_class XLMAIN
curXL:=Excel_Get()
curPath:=curXL.ActiveWorkbook.FullName
;~ msgbox, %curPath%`n%remotePath%`n%localPath%
if(remotePath=curPath || localPath=curPath)
{
;~ msgbox, yes
if(debug_mode)
msgbox, closing %fullpath% locally (2)
curXL.ActiveWorkbook.Close(0)
}
}
;~ msgbox, checked locally
SetTitleMatchMode, 2
SplitPath,localPath,name,dir
;msgbox, % name "-" WinExist(name)
if(WinExist(name)!=0x0)
{
;~ msgbox, winkilling %name%
WinActivate, %name%
Send , ^{f4}
}
if(toCloseFiles[key+1] && thisclosed)
{
thisclosed=0
;~ msgbox, sleeping
sleep, 10000
}
} ; for outer
;~ ClipSaved := ClipboardAll
;~ Runwait %comspec% /c ipconfig /all | clip,,Hide
;~ RegExMatch(Clipboard,"Host Name[\s\.]+: ([\w*\d*\-]+)",match)
;~ hostname := match1
;~ Clipboard := ClipSaved
;~ sendRemoteLog("" A_ComputerName " FOUND FILES OPENED ON " replacedStr " AND CLOSE IT " fileName ".xlsm " , "sdhome.duckdns.org",5801)
;~ sendRemoteLog("" A_ComputerName " FOUND FILES OPENED ON AND CLOSE IT " variable1 ".xlsm " , "sdhome.duckdns.org",5801)
;~ sleep, 1000
}
Obj2Str(obj) {
str := "" , array := true
for k in obj {
if (k == A_Index)
continue
array := false
break
}
for a, b in obj
str .= (array ? "" : "'" a "': ") . (IsObject(b) ? Obj2Str(b) : "'" b "'") . ", "
str := RTrim(str, " ,")
return (array ? "[" str "]" : "{" str "}")
}
HasVal(haystack, needle) {
if !(IsObject(haystack)) || (haystack.Length() = 0)
return 0
for index, value in haystack
if (value = needle)
return index
return 0
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;END;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;THIS IS WHERE IT LOOKS FOR FILE ON REMOTE COMPUTER AND CLOSES THE FILE, MUST HAVE THE FILE 'CLOSE.AHK' IN THE SAME FOLDER AS THIS SCRIPT;;;;;;;;;;
Adjusting:
Run, Z:\Formula\Inventlog.xlsm
Sleep, 5000
WinActivate, A
Sleep, 2000
WinMaximize, A
Sleep, 4000
; --- UNLOCK ---
Sleep, 2000
Send, {Alt Down}{q}{Alt Up}
Sleep, 2000
Send, %passwords%
Sleep, 1000
Send, {Enter}
Sleep, 3000 ; --- VOID ---
Send, !7
Sleep, 1500
StringRight, InvoiceNum, variable1, 17
Sleep, 3000
Send, %InvoiceNum%
Sleep, 2000
Send, {Enter}
Sleep, 2000
Send, {Control Down}{PgUp}{Control Up}
Sleep, 1000
; --- LOCK ---
Send, {Alt Down}{q}{Alt Up}
Sleep, 500
; --- SAVE INV ---
Send, {Alt Down}{9}{Alt Up}
Sleep, 500
Send, %passwords%
Sleep, 500
Send, {Enter}
Sleep, 10000
Send, {Enter}
Sleep, 2000
Send, {Alt Down}{F4}{Alt Up}
;ComObjActive("Excel.Application").ActiveWorkbook.Close
sleep, 1000
WinWaitClose
Sleep, 1000
Return
IsEmpty(Dir)
{
Loop %Dir%\*.*, 0, 1
return 1
return 0
}
UrlDownloadToVar(URL) {
ComObjError(false)
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("GET", URL)
WebRequest.Send()
Return WebRequest.ResponseText
}
CopyVar:
{
counter++
oldclip := Clipboard
empty_Clip()
send,^c
ClipWait,1
Variable%counter% := Clipboard
Clipboard := oldclip
}
return
empty_Clip()
{
Empty_Clip:
Clipboard=
if Clipboard=
sleep,10
else
Goto,Empty_Clip
}
Alert(Title,Message,Timeout,Width := "w120")
{
Progress, %Width% B2 zh0 fs30 Y100 X200 CWFF0000 CT000000, %Message%,,%Title%, ;;;;;;;;;;colors and starting point here
if(Timeout>0)
settimer, killAlert,%Timeout%
}
killAlert:
Progress, off
return
exitsub:
FileDelete, %myDir%\close.ahk
exitapp
return
Excel_Get(WinTitle:="ahk_class XLMAIN", Excel7#:=1) {
static h := DllCall("LoadLibrary", "Str", "oleacc", "Ptr")
WinGetClass, WinClass, %WinTitle%
if !(WinClass == "XLMAIN")
return "Window class mismatch."
ControlGet, hwnd, hwnd,, Excel7%Excel7#%, %WinTitle%
if (ErrorLevel)
return "Error accessing the control hWnd."
VarSetCapacity(IID_IDispatch, 16)
NumPut(0x46000000000000C0, NumPut(0x0000000000020400, IID_IDispatch, "Int64"), "Int64")
if DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", -16, "Ptr", &IID_IDispatch, "Ptr*", pacc) != 0
return "Error calling AccessibleObjectFromWindow."
window := ComObject(9, pacc, 1)
if ComObjType(window) != 9
return "Error wrapping the window object."
Loop
try return window.Application
catch e
if SubStr(e.message, 1, 10) = "0x80010001"
ControlSend, Excel7%Excel7#%, {Esc}, %WinTitle%
else
return "Error accessing the application object."
}
sendRemoteLog(text,ip, port2) ; now just run this and see if it logs
{
global secretcode
;;;formattime, nowtime,,ddd dd-MM-yy hh:mm tt ; is this ok?yes so dd/mm not mm/ddcorrect..this should work2wrong
;;; %a %d %m %y %I %M %p
;~ text=(%A_ComputerName%) %texte% [%nowtime%] <---origianal
;~ text= " this computer " (%A_ComputerName%) %texte%
myTcp := new SocketTCP()
;~ myTcp.connect("70.181.223.112", 5801)
myTcp.connect(ip, port2)
myTcp.onRecv := Func("OnTcpRespond").Bind(secretcode . text)
}
OnTcpRespond(text,this)
{
Repeat_Count = 0
resend:
var=
this.SendText(text)
sleep, 2000
var := this.recvText()
;;MsgBox, 262208, Info, %var%, 5 ;;;;;;;;;THIS MESSAGEBOX WILL APPEAR AND DISAPPEAR AFTER 5 SECONDS IF UNCOMMENTED
if var contains WRITTEN
return
else
{
sleep, 5000
Repeat_Count++
if Repeat_Count >= 8 ;;;########THIS WILL LOOP 8 TIMES TO ATTEMPT TO WRITE AND EXIT WHEATHER SUCCESFULL OR NOT TO END SCRIPT... ATTENTION!!!!###########
Return
;;;MsgBox , testing count: %Repeat_Count% `n%var%
goto,resend
}
Return
}
;~ OpenEraser:
;~ JustFiles:=SubStr(variable1, 3, -17)
;~ JustInv:=SubStr(variable1, -15)
;~ ;erase(["Z:\TRANSFER\designs\" variable1,"Y:\TRANSFER\designs\" variable1],"dir")
;~ erase(["Z:\TRANSFER\designs\" JustFiles "\" variable1 ".xlsm","Y:\TRANSFER\designs\" JustFiles "\" variable1 ".xlsm","Z:\Formula\Cancel\" variable1 ".xlsm","Z:\TRANSFER\designs\" JustFiles "\" variable1 ".pdf","Y:\TRANSFER\designs\" JustFiles "\" variable1 ".pdf","Z:\Formula\Invoices\" JustInv ".pdf","Y:\TRANSFER\Formula\Invoices\" JustInv ".pdf"],"file") ;;; needs extension flexible2
;~ ; you can see this is inside quotes, that will be interpreted literarly. it needs to be outside quotes with a space seperating it
;~ sendRemoteLog("" A_ComputerName " FOUND FILES and FOLDERS " variable1 ".xlsm " , "sdhome.duckdns.org",5801)
;~ goto, ReturnLabel
;~ OpenShred:
;~ Run, C:\Program Files\File Shredder\Shredder.exe
;~ Sleep, 1000
;~ Gosub, Addfiles
;~ Sleep, 1000
;~ Gosub, DriveZ
;~ Sleep, 1000
;~ Gosub, Searchfile
;~ Sleep, 1000
;~ Send, {Enter}
;~ Sleep, 300
;~ Gosub, Addfiles
;~ Sleep, 1000
;~ Gosub, DriveY
;~ Sleep, 1000
;~ Gosub, Searchfile
;~ Sleep, 1000
;~ Send, {Enter}
;~ Sleep, 1000
;~ Gosub, Addfiles
;~ Sleep, 1000
;~ Gosub, OpenInvA
;~ Sleep, 1000
;~ Gosub, SearchInv
;~ Sleep, 1000
;~ Gosub, Addfiles
;~ Sleep, 1000
;~ Gosub, OpenInvB
;~ Sleep, 1000
;~ Gosub, SearchInv
;~ Sleep, 1000
;~ Gosub, Addfiles
;~ Sleep, 1000
;~ Gosub, CanelInv
;~ Sleep, 1000
;~ Gosub, Searchfile
;~ Sleep, 1000
;~ Gosub, SHRRED
;~ Sleep, 500
;~ Gosub, Filelog
;~ Sleep, 1000
;~ DriveZ:
;~ Send, {Alt Down}{d}{Alt Up}
;~ Sleep, 2000
;~ SendRaw, Z:\TRANSFER\designs\
;~ Sleep, 500
;~ StringTrimRight, xfiless, variable1, 17 ;;;;;trimming the file name into folder name
;~ sleep, 1000
;~ Send, % SubStr(xfiless, 3, 45) ;;;;;sending folder name only
;~ Sleep, 500
;~ Return
;~ DriveY:
;~ sleep, 1000
;~ Send, {Alt Down}{d}{Alt Up}
;~ Sleep, 2000
;~ Send, Y:\TRANSFER\designs\
;~ Sleep, 500
;~ StringTrimRight, xfiless, variable1, 17 ;;;;;trimming the file name into folder name
;~ sleep, 1000
;~ Send, % SubStr(xfiless, 3, 45) ;;;;;sending folder name only
;~ Sleep, 500
;~ Return
;~ OpenInvA:
;~ Send, {Alt Down}{d}{Alt Up}
;~ Sleep, 1000
;~ Send, Z:\Formula\Invoices
;~ Sleep, 500
;~ Return
;~ OpenInvB:
;~ Send, {Alt Down}{d}{Alt Up}
;~ Sleep, 1000
;~ Send, Y:\TRANSFER\Formula\Invoices
;~ Sleep, 500
;~ Return
;~ CanelInv:
;~ Send, {Alt Down}{d}{Alt Up}
;~ Sleep, 2000
;~ Send, Z:\Formula\Cancel
;~ Sleep, 500
;~ Return
;~ Searchfile:
;~ Send, {Enter}
;~ sleep, 500
;~ Send, {Control Down}{f}{Control Up}
;~ Sleep, 2000
;~ Send, %variable1%
;~ Sleep, 2000
;~ Send, {Enter}
;~ Sleep, 1000
;~ Send, {Tab 3}
;~ Sleep, 2000
;~ Send, {Space}
;~ Sleep, 2000
;~ Send, {Control Down}{a}{Control Up}
;~ Sleep, 2000
;~ Send, {Alt Down}{o}{Alt Up}
;~ Sleep, 2000
;~ Return
;~ SearchInv:
;~ Send, {Enter}
;~ Sleep, 1000
;~ Send, {Control Down}{f}{Control Up}
;~ Sleep, 1000
;~ StringRight, InvoiceNum, variable1, 16 ;;;;;trim the name to just invoice number
;~ Sleep, 300
;~ Send, %InvoiceNum%
;~ Sleep, 4000
;~ Send, {Enter}
;~ Sleep, 1000
;~ Send, {Down}
;~ Sleep, 1000
;~ Send, {Space}
;~ Sleep, 2000
;~ Send, {Alt Down}{o}{Alt Up}
;~ Return
;~ DelCanel:
;~ Gosub, Addfiles
;~ Send, {Alt Down}{d}{Alt Up}
;~ Sleep, 1000
;~ SendRaw, Desktop\Cancel
;~ Sleep, 1000
;~ Send, {Enter}
;~ Sleep, 2000
;~ Send, {Tab 4}
;~ Sleep, 1000
;~ Send, {Space}
;~ Sleep, 2000
;~ Send, {Alt Down}{o}{Alt Up}
;~ Sleep, 1000
;~ return
;~ SHRRED:
;~ Send, {Tab}
;~ Sleep, 1000
;~ Send, {Enter}
;~ Sleep, 2000
;~ Send, {Enter}
;~ Sleep, 6000
;~ Winclose, A
;~ Sleep, 1000
;~ Return
;~ FileLog:
;~ ;FormatTime, Time2, %Time3%, hh:mm tt
;~ /*
;~ FileDelete K:\macro\errorlogtemp.txt ;;;deletes current log file
;~ FileAppend, CANEL script was ran`, FILES FOUND yyyyyyy on %A_DD% %A_MMMM% %A_YYYY% at %Time2% %variable1%`n, K:\macro\errorlogtemp.txt ;;;file appends line to temporary file
;~ RunWait %comspec% /c copy /b/y K:\macro\errorlogtemp.txt+K:\macro\errorlog.txt K:\macro\errorlogtemp.txt ;;;copies line to top of the line plus previous log
;~ FileMove K:\macro\errorlogtemp.txt, K:\macro\errorlog.txt, 1
;~ */
;~ sendRemoteLog("" A_ComputerName " FOUND FILES AND REMOVED succesfully","sdhome.duckdns.org",5801)
;~ Sleep, 3000
;~ Goto, Returnlabel
;~ Addfiles:
;~ Loop
;~ {
;~ Text:="|<addfiles>*159$100.0003030000k00D030000A0A0003000w0A0w00k0k3znA00300A3k03030DzAk00A00kD00A0A0k030030030w00k0k300A00A00A3w3z3z0A0Akz0kDkADkDwDw0k0n3w30z0n330n0k3znAkAAAA3AAA3A30DzAn0kkkkAkkkAkA0k0nDz33k0n330n0k303AzwAD03DzA3A30A0An00k3kAzwkAkA0k0nA030D0w0n0n0k303Ak0AAA3k3A3A30A0An00kkkD0ADwDw0k0n3z33z3A0kzkzk303ADwADwAU"
;~ }
;~ Until ErrorLevel = 0
;~ if (ok:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, Text))
;~ {
;~ Gosub, foundImage
;~ }
;~ Return
;~ foundImage:
;~ {
;~ CoordMode, Mouse
;~ X:=ok.1.1, Y:=ok.1.2, W:=ok.1.3, H:=ok.1.4, Comment:=ok.1.5, X+=W//2, Y+=H//2
;~ Mousemove, %X%, %Y%
;~ Click, %X%, %Y%
;~ sleep, 500
;~ }
;~ ;;; Functions
;~ class Excel_Objects
;~ {
;~ Xls(Needle := "")
;~ {
;~ Xls := {}
;~ for index, obj in GetActiveObjects()
;~ {
;~ try
;~ Name := obj.Application.ActiveWorkbook.Name
;~ catch
;~ continue
;~ ;msgbox, %Name%
;~ ;;;;;;;;;if (RegExMatch(index, "(^|\\)" Name "$") and RegExMatch(Name, Needle))<-----------------------CANNOT BE HERE
;~ Xls.Push(obj.Application)
;~ }
;~ return Xls
;~ }
;~ Wbs(Needle := "", Visible := "")
;~ {
;~ Wbs := {}
;~ Xls := Excel_Objects.Xls()
;~ for index, Xl in Xls
;~ for Workbook in Xl.Workbooks
;~ if RegExMatch(Workbook.Name, Needle)
;~ if (Visible = 1 and Workbook.Windows(1).Visible)
;~ Wbs.Push(Workbook)
;~ else if (Visible = 0 and not Workbook.Windows(1).Visible)
;~ Wbs.Push(Workbook)
;~ else if (Visible = "")
;~ Wbs.Push(Workbook)
;~ return Wbs
;~ }
;~ }
;~ GetActiveObjects(Prefix:="", CaseSensitive:=false) {
;~ objects := {}
;~ DllCall("ole32\CoGetMalloc", "uint", 1, "ptr*", malloc) ; malloc: IMalloc
;~ DllCall("ole32\CreateBindCtx", "uint", 0, "ptr*", bindCtx) ; bindCtx: IBindCtx
;~ DllCall(NumGet(NumGet(bindCtx+0)+8*A_PtrSize), "ptr", bindCtx, "ptr*", rot) ; rot: IRunningObjectTable
;~ DllCall(NumGet(NumGet(rot+0)+9*A_PtrSize), "ptr", rot, "ptr*", enum) ; enum: IEnumMoniker
;~ while DllCall(NumGet(NumGet(enum+0)+3*A_PtrSize), "ptr", enum, "uint", 1, "ptr*", mon, "ptr", 0) = 0 ; mon: IMoniker
;~ {
;~ DllCall(NumGet(NumGet(mon+0)+20*A_PtrSize), "ptr", mon, "ptr", bindCtx, "ptr", 0, "ptr*", pname) ; GetDisplayName
;~ name := StrGet(pname, "UTF-16")
;~ DllCall(NumGet(NumGet(malloc+0)+5*A_PtrSize), "ptr", malloc, "ptr", pname) ; Free
;~ if InStr(name, Prefix, CaseSensitive) = 1 {
;~ DllCall(NumGet(NumGet(rot+0)+6*A_PtrSize), "ptr", rot, "ptr", mon, "ptr*", punk) ; GetObject
;~ ; Wrap the pointer as IDispatch if available, otherwise as IUnknown.
;~ if (pdsp := ComObjQuery(punk, "{00020400-0000-0000-C000-000000000046}"))
;~ obj := ComObject(9, pdsp, 1), ObjRelease(punk)
;~ else
;~ obj := ComObject(13, punk, 1)
;~ ; Store it in the return array by suffix.
;~ objects[SubStr(name, StrLen(Prefix) + 1)] := obj
;~ }
;~ ObjRelease(mon)
;~ }
;~ ObjRelease(enum)
;~ ObjRelease(rot)
;~ ObjRelease(bindCtx)
;~ ObjRelease(malloc)
;~ return objects
;~ }
;~ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;FEI YUE IMAGE FIND START;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~ FindText( x, y, w, h, err1, err0, text, ScreenShot=1
;~ , FindAll=1, JoinText=0, offsetX=20, offsetY=10 )
;~ {
;~ xywh2xywh(x,y,w,h,x,y,w,h)
;~ if (w<1 or h<1)
;~ return, 0
;~ bch:=A_BatchLines
;~ SetBatchLines, -1
;~ ;-------------------------------
;~ GetBitsFromScreen(x,y,w,h,Scan0,Stride,ScreenShot,zx,zy)
;~ ;-------------------------------
;~ sx:=x-zx, sy:=y-zy, sw:=w, sh:=h
;~ , arr:=[], info:=[], allv:=""
;~ Loop, Parse, text, |
;~ {
;~ v:=A_LoopField
;~ IfNotInString, v, $, Continue
;~ comment:="", e1:=err1, e0:=err0
;~ ; You Can Add Comment Text within The <>
;~ if RegExMatch(v,"<([^>]*)>",r)
;~ v:=StrReplace(v,r), comment:=Trim(r1)
;~ ; You can Add two fault-tolerant in the [], separated by commas
;~ if RegExMatch(v,"\[([^\]]*)]",r)
;~ {
;~ v:=StrReplace(v,r), r1.=","
;~ StringSplit, r, r1, `,
;~ e1:=r1, e0:=r2
;~ }
;~ StringSplit, r, v, $
;~ color:=r1, v:=r2
;~ StringSplit, r, v, .
;~ w1:=r1, v:=base64tobit(r2), h1:=StrLen(v)//w1
;~ if (r0<2 or h1<1 or w1>sw or h1>sh or StrLen(v)!=w1*h1)
;~ Continue
;~ mode:=InStr(color,"-") ? 4 : InStr(color,"#") ? 3
;~ : InStr(color,"**") ? 2 : InStr(color,"*") ? 1 : 0
;~ if (mode=4)
;~ {
;~ color:=StrReplace(color,"0x")
;~ StringSplit, r, color, -
;~ color:="0x" . r1, n:="0x" . r2
;~ }
;~ else
;~ {
;~ color:=RegExReplace(color,"[*#]") . "@"
;~ StringSplit, r, color, @
;~ color:=mode=3 ? ((r1-1)//w1)*Stride+Mod(r1-1,w1)*4 : r1
;~ n:=Round(r2,2)+(!r2), n:=Floor(9*255*255*(1-n)*(1-n))
;~ }
;~ StrReplace(v,"1","",len1), len0:=StrLen(v)-len1
;~ e1:=Round(len1*e1), e0:=Round(len0*e0)
;~ info.Push( [StrLen(allv),w1,h1,len1,len0,e1,e0
;~ ,mode,color,n,comment] ), allv.=v
;~ }
;~ if (allv="")
;~ {
;~ SetBatchLines, %bch%
;~ return, 0
;~ }
;~ num:=info.MaxIndex(), VarSetCapacity(input, num*7*4)
;~ , VarSetCapacity(gs, sw*sh)
;~ , VarSetCapacity(ss, sw*sh), k:=StrLen(allv)*4
;~ , VarSetCapacity(s1, k), VarSetCapacity(s0, k)
;~ , allpos_max:=FindAll ? 1024 : 1
;~ , VarSetCapacity(allpos, allpos_max*4)
;~ ;-------------------------------------
;~ Loop, 2 {
;~ if (JoinText)
;~ {
;~ mode:=info.1.8, color:=info.1.9, n:=info.1.10
;~ , w1:=-1, h1:=info.1.3, comment:="", k:=0
;~ Loop, % num {
;~ i:=A_Index, w1+=info[i].2+1, comment.=info[i].11
;~ Loop, 7
;~ NumPut(info[i][A_Index], input, 4*(k++), "int")
;~ }
;~ ok:=PicFind( mode,color,n,offsetX,offsetY
;~ ,Scan0,Stride,sx,sy,sw,sh,gs,ss,allv,s1,s0
;~ ,input,num*7,allpos,allpos_max )
;~ Loop, % ok
;~ pos:=NumGet(allpos, 4*(A_Index-1), "uint")
;~ , rx:=(pos&0xFFFF)+zx, ry:=(pos>>16)+zy
;~ , arr.Push( [rx,ry,w1,h1,comment] )
;~ }
;~ else
;~ {
;~ For i,j in info
;~ {
;~ mode:=j.8, color:=j.9, n:=j.10, comment:=j.11
;~ , w1:=j.2, h1:=j.3, v:=SubStr(allv, j.1+1, w1*h1)
;~ Loop, 7
;~ NumPut(j[A_Index], input, 4*(A_Index-1), "int")
;~ NumPut(0, input, "int")
;~ ok:=PicFind( mode,color,n,offsetX,offsetY
;~ ,Scan0,Stride,sx,sy,sw,sh,gs,ss,v,s1,s0
;~ ,input,7,allpos,allpos_max )
;~ Loop, % ok
;~ pos:=NumGet(allpos, 4*(A_Index-1), "uint")
;~ , rx:=(pos&0xFFFF)+zx, ry:=(pos>>16)+zy
;~ , arr.Push( [rx,ry,w1,h1,comment] )
;~ }
;~ }
;~ if (err1=0 and err0=0 and !arr.MaxIndex())
;~ {
;~ err1:=err0:=0.1
;~ For i,j in info
;~ if (j.6=0 and j.7=0)
;~ j.6:=Round(j.4*err1), j.7:=Round(j.5*err0)
;~ }
;~ else Break
;~ }
;~ SetBatchLines, %bch%
;~ return, arr.MaxIndex() ? arr:0
;~ }
;~ PicFind(mode, color, n, offsetX, offsetY
;~ , Scan0, Stride, sx, sy, sw, sh
;~ , ByRef gs, ByRef ss, ByRef text, ByRef s1, ByRef s0
;~ , ByRef input, num, ByRef allpos, allpos_max)
;~ {
;~ static MyFunc, Ptr:=A_PtrSize ? "UPtr" : "UInt"
;~ if !MyFunc
;~ {
;~ x32:="5557565383EC788B8424CC0000008BBC24CC000000C7442"
;~ . "424000000008B40048B7F148944243C8B8424CC000000897C2"
;~ . "42C8BBC24CC0000008B40088B7F18894424348B8424CC00000"
;~ . "0897C24308B400C89C6894424288B8424CC0000008B401039C"
;~ . "6894424200F4DC68944241C8B8424D000000085C00F8E15010"
;~ . "0008BB424CC0000008B44242489F78B0C868B7486048B44870"
;~ . "88974241085C0894424180F8ED700000089CD894C2414C7442"
;~ . "40C00000000C744240800000000C744240400000000890C248"
;~ . "D76008DBC27000000008B5C24108B7424088B4C24148B54240"
;~ . "C89DF89F029F101F78BB424C000000001CE85DB7E5E8B0C248"
;~ . "9EB893C2489D7EB198BAC24C800000083C70483C00189548D0"
;~ . "083C101390424742C83BC248C0000000389FA0F45D0803C063"
;~ . "175D48BAC24C400000083C70483C00189549D0083C30139042"
;~ . "475D48B7424100174241489DD890C2483442404018BB424B00"
;~ . "000008B442404017424088BBC24A4000000017C240C3944241"
;~ . "80F8554FFFFFF83442424078B442424398424D00000000F8FE"
;~ . "BFEFFFF83BC248C000000030F84A00600008B8424A40000008"
;~ . "BB424A80000000FAF8424AC0000008BBC248C0000008D2CB08"
;~ . "B8424B00000008BB424A4000000F7D885FF8D0486894424100"
;~ . "F84F702000083BC248C000000010F845F08000083BC248C000"
;~ . "000020F84130900008B8424900000008B9C24940000000FB6B"
;~ . "C24940000000FB6B42490000000C744241800000000C744242"
;~ . "400000000C1E8100FB6DF0FB6D08B84249000000089D10FB6C"
;~ . "4894424088B842494000000C1E8100FB6C029C101D08904248"
;~ . "B442408894C24408B4C240801D829D9894424088D043E894C2"
;~ . "40489F129F9894424148BBC24B40000008B8424B0000000894"
;~ . "C240C89E98B6C2440C1E00285FF894424380F8EBA0000008BB"
;~ . "424B000000085F60F8E910000008B8424A00000008B5424240"
;~ . "39424BC00000001C8034C243889CF894C244003BC24A000000"
;~ . "0EB3D8D76008DBC2700000000391C247C3D394C24047F37394"
;~ . "C24087C3189F30FB6F33974240C0F9EC3397424140F9DC183C"
;~ . "00483C20121D9884AFF39F8741E0FB658020FB648010FB6303"
;~ . "9DD7EBE31C983C00483C201884AFF39F875E28BBC24B000000"
;~ . "0017C24248B4C24408344241801034C24108B442418398424B"
;~ . "40000000F8546FFFFFF8B8424B00000002B44243C8944240C8"
;~ . "B8424B40000002B442434894424600F884D0900008B4424288"
;~ . "BBC24C40000008B74243CC744241000000000C744243800000"
;~ . "000C7442434000000008D3C8789C583EE01897C246C8974247"
;~ . "48B44240C85C00F88E70000008B7C24388B8424AC000000BE0"
;~ . "0000000C704240000000001F8C1E0108944246889F82B84249"
;~ . "C0000000F49F08B84249C000000897424640FAFB424B000000"
;~ . "001F8894424708974245C8DB6000000008B04240344241089C"
;~ . "1894424088B442430394424200F84AA0100008B5C241C89C60"
;~ . "38C24BC00000031C08B54242C85DB0F8EC8010000897424048"
;~ . "B7C2420EB2D39C77E1C8BB424C80000008B1C8601CB803B007"
;~ . "40B836C240401782B8D74260083C0013944241C0F849101000"
;~ . "039C57ECF8BB424C40000008B1C8601CB803B0174BE83EA017"
;~ . "9B9830424018B04243944240C0F8D68FFFFFF83442438018BB"
;~ . "424B00000008B44243801742410394424600F8DEFFEFFFF8B4"
;~ . "C243483C47889C85B5E5F5DC250008B8424900000008BB424B"
;~ . "4000000C744240C00000000C744241400000000C1E8100FB6C"
;~ . "08904248B8424900000000FB6C4894424040FB684249000000"
;~ . "0894424088B8424B0000000C1E00285F68944242489E88BAC2"
;~ . "4940000000F8E24FEFFFF8B9C24B000000085DB7E758B9C24A"
;~ . "00000008B7424148BBC24A000000003B424BC00000001C3034"
;~ . "424248944241801C78D76008DBC27000000000FB643020FB64"
;~ . "B012B04242B4C24040FB6132B5424080FAFC00FAFC98D04400"
;~ . "FAFD28D04888D045039C50F930683C30483C60139DF75C98BB"
;~ . "C24B0000000017C24148B4424188344240C01034424108B742"
;~ . "40C39B424B40000000F8566FFFFFFE985FDFFFF85ED7E358B7"
;~ . "424088BBC24BC00000031C08B54242C8D1C378BB424C400000"
;~ . "08B0C8601D9803901740983EA010F8890FEFFFF83C00139C57"
;~ . "5E683BC24D0000000070F8EAA0100008B442474030424C7442"
;~ . "44007000000896C2444894424288B8424CC00000083C020894"
;~ . "4243C8B44243C8B9424B00000008B7C24288B0029C28944245"
;~ . "08B84249800000001F839C20F4EC289C68944244C39FE0F8C0"
;~ . "90100008B44243C8B700C8B78148B6808897424148B7010897"
;~ . "C245489C7897424248BB424B40000002B700489F08B7424703"
;~ . "9C60F4EC68BB424C4000000894424188B47FC89442404C1E00"
;~ . "201C6038424C8000000894424588B4424648B7C2428037C245"
;~ . "C3B442418894424040F8F8700000085ED7E268B8C24BC00000"
;~ . "08B54242431C08D1C398B0C8601D9803901740583EA01784A8"
;~ . "3C00139C575EA8B4424148B4C245439C8747E85C07E7A8B9C2"
;~ . "4BC000000896C244831C08B6C245801FBEB0983C0013944241"
;~ . "4745C8B54850001DA803A0074EC83E90179E78B6C244890834"
;~ . "424040103BC24B00000008B442404394424180F8D79FFFFFF8"
;~ . "3442428018B4424283944244C0F8D4CFFFFFF830424018B6C2"
;~ . "4448B04243944240C0F8D7EFCFFFFE911FDFFFF8B4424288B7"
;~ . "4245083442440078344243C1C8D4430FF894424288B4424403"
;~ . "98424D00000000F8F7FFEFFFF8B6C24448B7C24348B0424038"
;~ . "424A80000008BB424D40000000B4424688D4F01398C24D8000"
;~ . "0008904BE0F8ED8FCFFFF85ED7E278B7424088BBC24BC00000"
;~ . "08B8424C40000008D1C378B74246C8B1083C00401DA39F0C60"
;~ . "20075F283042401894C24348B04243944240C0F8DDEFBFFFFE"
;~ . "971FCFFFF89F68DBC27000000008B8424B0000000038424A80"
;~ . "000002B44243C894424248B8424AC000000038424B40000002"
;~ . "B442434398424AC000000894424380F8F520400008B8424A40"
;~ . "000008BB424A80000000FAF8424AC000000C74424180000000"
;~ . "08D04B0038424900000008BB424A0000000894424348B44242"
;~ . "4398424A80000000F8F2B0100008B8424AC000000C1E010894"
;~ . "4243C8B442434894424148B8424A8000000894424088B44241"
;~ . "40FB67C060289C52BAC2490000000893C240FB67C0601897C2"
;~ . "4040FB63C068B44241C85C00F8E140100008B4424308944241"
;~ . "08B44242C8944240C31C0EB5D394424207E4A8B9C24C800000"
;~ . "08B0C8301E90FB6540E020FB65C0E012B14242B5C24040FB60"
;~ . "C0E0FAFD20FAFDB29F98D14520FAFC98D149A8D144A3994249"
;~ . "4000000720C836C2410017865908D74260083C0013944241C0"
;~ . "F84A3000000394424287E9D8B9C24C40000008B0C8301E90FB"
;~ . "6540E020FB65C0E012B14242B5C24040FB60C0E0FAFD20FAFD"
;~ . "B29F98D14520FAFC98D149A8D144A3B9424940000000F865BF"
;~ . "FFFFF836C240C010F8950FFFFFF834424080183442414048B4"
;~ . "42408394424240F8DF6FEFFFF838424AC000000018BBC24A40"
;~ . "000008B442438017C24343B8424AC0000000F8DA0FEFFFF8B4"
;~ . "C241883C4785B5E89C85F5DC250008D7426008B7C24188B442"
;~ . "43C0B4424088B9C24D40000008D4F013B8C24D80000008904B"
;~ . "B0F8D84FAFFFF894C2418EB848B8424900000008B8C24B4000"
;~ . "000C7042400000000C74424040000000083C001C1E00789C78"
;~ . "B8424B0000000C1E00285C98944240889E889FD0F8ECFF8FFF"
;~ . "F8B9424B000000085D27E5F8B8C24A00000008B5C2404039C2"
;~ . "4BC00000001C1034424088944240C038424A000000089C70FB"
;~ . "651020FB641010FB6316BC04B6BD22601C289F0C1E00429F00"
;~ . "1D039C50F970383C10483C30139F975D58BBC24B0000000017"
;~ . "C24048B44240C83042401034424108B342439B424B40000007"
;~ . "582E94CF8FFFF8B8424B0000000C7042400000000C74424040"
;~ . "0000000C1E002894424088B8424B400000085C00F8E9200000"
;~ . "08B8424B000000085C07E6F8B8C24A00000008B5C24048BB42"
;~ . "4B800000001E9036C240801DE039C24BC000000896C240C03A"
;~ . "C24A00000000FB651020FB6410183C1040FB679FC83C60183C"
;~ . "3016BC04B6BD22601C289F8C1E00429F801D0C1F8078846FFC"
;~ . "643FF0039CD75CC8BB424B0000000017424048B6C240C83042"
;~ . "401036C24108B0424398424B40000000F856EFFFFFF83BC24B"
;~ . "4000000020F8E80F7FFFF8B8424BC000000038424B00000008"
;~ . "BAC24B800000003AC24B0000000C7442404010000008944240"
;~ . "88B8424B400000083E8018944240C8B8424B000000083C0018"
;~ . "944241083BC24B0000000027E798B44241089E92B8C24B0000"
;~ . "0008B5C240889EA8D34288D45FE8904240FB642010FB63A038"
;~ . "4249000000039F87C360FB67A0239F87C2E0FB6790139F87C2"
;~ . "60FB63E39F87C1F0FB63939F87C180FB6790239F87C100FB67"
;~ . "EFF39F87C080FB67E0139F87D04C643010183C20183C30183C"
;~ . "10183C6013B0C2475A3834424040103AC24B00000008B44240"
;~ . "48BB424B0000000017424083944240C0F8558FFFFFFE98FF6F"
;~ . "FFF83C47831C95B89C85E5F5DC2500090909090909090"
;~ x64:="4157415641554154555756534881EC88000000488B84245"
;~ . "0010000488BB42450010000448B94245801000089542428448"
;~ . "944240844898C24E80000008B40048B76144C8BBC244001000"
;~ . "04C8BB42448010000C74424180000000089442430488B84245"
;~ . "00100008974241C488BB424500100008B40088B76188944243"
;~ . "C488B842450010000897424388B400C89C789442440488B842"
;~ . "4500100008B401039C7894424100F4DC74585D289442454488"
;~ . "B84245001000048894424200F8ECB000000488B442420448B0"
;~ . "8448B68048B400885C0894424040F8E940000004489CE44890"
;~ . "C244531E431FF31ED0F1F8400000000004585ED7E614863142"
;~ . "4418D5C3D0089F848039424380100004589E0EB1D0F1F0083C"
;~ . "0014D63D94183C0044183C1014883C20139C34789149E74288"
;~ . "3F9034589C2440F45D0803A3175D783C0014C63DE4183C0048"
;~ . "3C6014883C20139C34789149F75D844012C2483C50103BC241"
;~ . "80100004403A42400010000396C24047582834424180748834"
;~ . "424201C8B442418398424580100000F8F35FFFFFF83F9030F8"
;~ . "43D0600008B8424000100008BBC24080100000FAF842410010"
;~ . "0008BB424000100008D3CB88B842418010000F7D885C9448D2"
;~ . "C860F841101000083F9010F842008000083F9020F84BF08000"
;~ . "08B742428C744240400000000C74424180000000089F0440FB"
;~ . "6CEC1E8104589CC0FB6D84889F08B7424080FB6D44189DB89F"
;~ . "0440FB6C64889F1C1E8100FB6CD89D60FB6C08D2C0A8B94242"
;~ . "00100004129C301C3438D040129CE4529C48904248B8424180"
;~ . "10000C1E00285D2894424080F8E660100004C89BC244001000"
;~ . "0448BBC24180100004585FF0F8E91040000488B8C24F800000"
;~ . "04863C74C6354241831D24C03942430010000488D440102EB3"
;~ . "A0F1F80000000004439C37C4039CE7F3C39CD7C384539CC410"
;~ . "F9EC044390C240F9DC14421C141880C124883C2014883C0044"
;~ . "139D70F8E2D040000440FB6000FB648FF440FB648FE4539C37"
;~ . "EBB31C9EBD58B5C2428448B8C242001000031ED4531E44889D"
;~ . "84189DB0FB6DB0FB6F48B84241801000041C1EB10450FB6DBC"
;~ . "1E0024585C98904240F8EA10000004C89BC24400100004C89B"
;~ . "42448010000448B7C2408448BB424180100004585F67E60488"
;~ . "B8C24F80000004D63D44C039424300100004863C74531C94C8"
;~ . "D440102410FB600410FB648FF410FB650FE4429D829F10FAFC"
;~ . "029DA0FAFC98D04400FAFD28D04888D04504139C7430F93040"
;~ . "A4983C1014983C0044539CE7FC4033C244501F483C5014401E"
;~ . "F39AC2420010000758C4C8BBC24400100004C8BB4244801000"
;~ . "08B8424180100002B4424308904248B8424200100002B44243"
;~ . "C894424680F88540800008B7C24404D89F5488BAC243001000"
;~ . "0448B7424104C89FEC74424040000000048C74424280000000"
;~ . "0C74424200000000089F883E801498D4487044189FF4889442"
;~ . "4088B44243083E801894424788B042485C00F88D9000000488"
;~ . "B5C24288B8424100100004D89EC448B6C245401D8C1E010894"
;~ . "4247089D82B8424F000000089C7B8000000000F49C731FF894"
;~ . "4246C0FAF842418010000894424648B8424F000000001D8894"
;~ . "42474908B442404897C24188D1C388B4424384139C60F84AB0"
;~ . "000004189C131C04585ED448B44241C7F36E9C30000000F1F4"
;~ . "0004139CE7E1B418B148401DA4863D2807C150000740B4183E"
;~ . "901782E0F1F4400004883C0014139C50F8E920000004139C78"
;~ . "9C17ECC8B148601DA4863D2807C15000174BD4183E80179B74"
;~ . "883C701393C240F8D7AFFFFFF4D89E54883442428018B9C241"
;~ . "8010000488B442428015C2404394424680F8DFCFEFFFF8B4C2"
;~ . "42089C84881C4880000005B5E5F5D415C415D415E415FC3458"
;~ . "5FF7E278B4C241C4C8B4424084889F28B0201D84898807C050"
;~ . "001740583E90178934883C2044939D075E583BC24580100000"
;~ . "70F8EE60100008B442478488B8C24500100000344241844896"
;~ . "C2450448BAC241801000044897C24404883C1204889742410C"
;~ . "744243C07000000448974244448897C24484989CF895C247C8"
;~ . "9C64C89642430418B074489EA29C28944245C8B8424E800000"
;~ . "001F039C20F4EC239F0894424580F8CD0000000418B47148BB"
;~ . "C2420010000412B7F0449635FFC458B4F08458B670C8944246"
;~ . "08B442474458B771039C70F4FF8488B44241048C1E3024C8D1"
;~ . "41848035C24308B442464448D04068B44246C39F84189C37F7"
;~ . "2904585C97E234489F131D2418B04924401C04898807C05000"
;~ . "1740583E90178464883C2014139D17FE28B4424604139C40F8"
;~ . "4AA0000004585E40F8EA100000089C131D2EB0D4883C201413"
;~ . "9D40F8E8E0000008B04934401C04898807C05000074E483E90"
;~ . "179DF4183C3014501E84439DF7D8F83C601397424580F8D6EF"
;~ . "FFFFF488B7C2448448B7C2440448B742444448B6C2450488B7"
;~ . "424104C8B6424304883C701393C240F8D97FDFFFFE918FEFFF"
;~ . "F6690037C240844017C241883442404014401EF8B442404398"
;~ . "424200100000F854DFBFFFF4C8BBC2440010000E996FCFFFF8"
;~ . "B44245C8344243C074983C71C8D7406FF8B44243C398424580"
;~ . "100000F8F87FEFFFF448B7C2440448B742444448B6C2450488"
;~ . "B7C24488B5C247C488B7424104C8B64243048634424208B542"
;~ . "418039424080100004C8B9C24600100000B5424708D4801398"
;~ . "C2468010000418914830F8E9AFDFFFF4585FF7E1D4C8B44240"
;~ . "84889F08B104883C00401DA4C39C04863D2C64415000075EB4"
;~ . "883C701393C24894C24200F8DBAFCFFFFE93BFDFFFF0F1F440"
;~ . "0008B842418010000038424080100002B442430894424308B8"
;~ . "42410010000038424200100002B44243C39842410010000894"
;~ . "424440F8F230400008B8424000100008BBC24080100000FAF8"
;~ . "42410010000448B642440448B6C24544C8B8C24F8000000C74"
;~ . "42420000000008D04B8034424288944243C8B4424303984240"
;~ . "80100000F8F2F0100008B8424100100008B6C243CC1E010894"
;~ . "424408B8424080100008904248D450289EF2B7C24284585ED4"
;~ . "898450FB61C018D45014898410FB61C014863C5410FB634010"
;~ . "F8E140100008B442438894424188B44241C8944240431C0EB6"
;~ . "244395424107E4E418B0C8601F98D5102448D41014863C9410"
;~ . "FB60C094863D24D63C0410FB61411470FB6040129F10FAFC94"
;~ . "429DA4129D80FAFD2450FAFC08D1452428D14828D144A39542"
;~ . "4087207836C241801786B4883C0014139C50F8E9E000000413"
;~ . "9C44189C27E96418B0C8701F98D5102448D41014863C9410FB"
;~ . "60C094863D24D63C0410FB61411470FB6040129F10FAFC9442"
;~ . "9DA4129D80FAFD2450FAFC08D1452428D14828D144A3B54240"
;~ . "80F864BFFFFFF836C2404010F8940FFFFFF8304240183C5048"
;~ . "B0424394424300F8DEDFEFFFF83842410010000018BBC24000"
;~ . "100008B442444017C243C3B8424100100000F8D9CFEFFFFE97"
;~ . "CFBFFFF0F1F0048634424208B5424400B1424488BBC2460010"
;~ . "0008D48013B8C24680100008914870F8D56FBFFFF830424018"
;~ . "3C504894C24208B0424394424300F8D82FEFFFFEB93448B5C2"
;~ . "428448B84242001000031DB8B84241801000031F6448B94241"
;~ . "80100004183C30141C1E3074585C08D2C85000000000F8E8CF"
;~ . "9FFFF4585D27E57488B8C24F80000004C63CE4C038C2430010"
;~ . "0004863C74531C0488D4C01020FB6110FB641FF440FB661FE6"
;~ . "BC04B6BD22601C24489E0C1E0044429E001D04139C3430F970"
;~ . "4014983C0014883C1044539C27FCC01EF4401D683C3014401E"
;~ . "F399C24200100007595E91CF9FFFF8B8C24200100008B84241"
;~ . "801000031DB31F6448B8C241801000085C98D2C85000000007"
;~ . "E7D4585C97E694C63C6488B8C24F80000004863C74D89C24C0"
;~ . "38424300100004C0394242801000031D2488D4C0102440FB61"
;~ . "90FB641FF4883C104440FB661FA6BC04B456BDB264101C3448"
;~ . "9E0C1E0044429E04401D8C1F8074188041241C60410004883C"
;~ . "2014139D17FC401EF4401CE83C3014401EF399C24200100007"
;~ . "58383BC2420010000020F8E6CF8FFFF4863B424180100008B9"
;~ . "C24180100008BBC2420010000488D5601448D67FFBF0100000"
;~ . "04889D0480394243001000048038424280100004889D58D53F"
;~ . "D4C8D6A0183BC241801000002488D1C067E7E4989C04D8D5C0"
;~ . "5004989D94929F04889E90FB610440FB650FF035424284439D"
;~ . "27C44440FB650014439D27C3A450FB6104439D27C31450FB61"
;~ . "14439D27C28450FB650FF4439D27C1E450FB650014439D27C1"
;~ . "4450FB651FF4439D27C0A450FB651014439D27D03C60101488"
;~ . "3C0014983C1014883C1014983C0014C39D8759383C7014801F"
;~ . "54889D84139FC0F8562FFFFFFE989F7FFFF31C9E9FAF8FFFF9"
;~ . "0909090909090909090909090"
;~ MCode(MyFunc, A_PtrSize=8 ? x64:x32)
;~ }
;~ return, DllCall(&MyFunc, "int",mode, "uint",color
;~ , "uint",n, "int",offsetX, "int",offsetY, Ptr,Scan0
;~ , "int",Stride, "int",sx, "int",sy, "int",sw, "int",sh
;~ , Ptr,&gs, Ptr,&ss, "AStr",text, Ptr,&s1, Ptr,&s0
;~ , Ptr,&input, "int",num, Ptr,&allpos, "int",allpos_max)
;~ }
;~ xywh2xywh(x1,y1,w1,h1,ByRef x,ByRef y,ByRef w,ByRef h)
;~ {
;~ SysGet, zx, 76
;~ SysGet, zy, 77
;~ SysGet, zw, 78
;~ SysGet, zh, 79
;~ left:=x1, right:=x1+w1-1, up:=y1, down:=y1+h1-1
;~ left:=left<zx ? zx:left, right:=right>zx+zw-1 ? zx+zw-1:right
;~ up:=up<zy ? zy:up, down:=down>zy+zh-1 ? zy+zh-1:down
;~ x:=left, y:=up, w:=right-left+1, h:=down-up+1
;~ }
;~ GetBitsFromScreen(x, y, w, h, ByRef Scan0, ByRef Stride
;~ , ScreenShot=1, ByRef zx="", ByRef zy="", bpp=32)
;~ {
;~ static bits, oldx, oldy, oldw, oldh
;~ static Ptr:=A_PtrSize ? "UPtr" : "UInt", PtrP:=Ptr "*"
;~ if (ScreenShot or x<oldx or y<oldy
;~ or x+w>oldx+oldw or y+h>oldy+oldh)
;~ {
;~ oldx:=x, oldy:=y, oldw:=w, oldh:=h, ScreenShot:=1
;~ VarSetCapacity(bits, w*h*4)
;~ }
;~ Scan0:=&bits, Stride:=((oldw*bpp+31)//32)*4, zx:=oldx, zy:=oldy
;~ if (!ScreenShot or w<1 or h<1)
;~ return
;~ win:=DllCall("GetDesktopWindow", Ptr)
;~ hDC:=DllCall("GetWindowDC", Ptr,win, Ptr)
;~ mDC:=DllCall("CreateCompatibleDC", Ptr,hDC, Ptr)
;~ ;-------------------------
;~ VarSetCapacity(bi, 40, 0), NumPut(40, bi, 0, "int")
;~ NumPut(w, bi, 4, "int"), NumPut(-h, bi, 8, "int")
;~ NumPut(1, bi, 12, "short"), NumPut(bpp, bi, 14, "short")
;~ ;-------------------------
;~ if hBM:=DllCall("CreateDIBSection", Ptr,mDC, Ptr,&bi
;~ , "int",0, PtrP,ppvBits, Ptr,0, "int",0, Ptr)
;~ {
;~ oBM:=DllCall("SelectObject", Ptr,mDC, Ptr,hBM, Ptr)
;~ DllCall("BitBlt", Ptr,mDC, "int",0, "int",0, "int",w, "int",h
;~ , Ptr,hDC, "int",x, "int",y, "uint",0x00CC0020|0x40000000)
;~ DllCall("RtlMoveMemory", Ptr,Scan0, Ptr,ppvBits, Ptr,Stride*h)
;~ DllCall("SelectObject", Ptr,mDC, Ptr,oBM)
;~ DllCall("DeleteObject", Ptr,hBM)
;~ }
;~ DllCall("DeleteDC", Ptr,mDC)
;~ DllCall("ReleaseDC", Ptr,win, Ptr,hDC)
;~ }
;~ MCode(ByRef code, hex)
;~ {
;~ bch:=A_BatchLines
;~ SetBatchLines, -1
;~ VarSetCapacity(code, len:=StrLen(hex)//2)
;~ lls:=A_ListLines=0 ? "Off" : "On"
;~ ListLines, Off
;~ Loop, % len
;~ NumPut("0x" SubStr(hex,2*A_Index-1,2),code,A_Index-1,"uchar")
;~ ListLines, %lls%
;~ Ptr:=A_PtrSize ? "UPtr" : "UInt", PtrP:=Ptr . "*"
;~ DllCall("VirtualProtect",Ptr,&code, Ptr,len,"uint",0x40,PtrP,0)
;~ SetBatchLines, %bch%
;~ }
;~ base64tobit(s)
;~ {
;~ Chars:="0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;~ . "abcdefghijklmnopqrstuvwxyz"
;~ SetFormat, IntegerFast, d
;~ StringCaseSense, On
;~ lls:=A_ListLines=0 ? "Off" : "On"
;~ ListLines, Off
;~ Loop, Parse, Chars
;~ {
;~ i:=A_Index-1, v:=(i>>5&1) . (i>>4&1)
;~ . (i>>3&1) . (i>>2&1) . (i>>1&1) . (i&1)
;~ s:=StrReplace(s,A_LoopField,v)
;~ }
;~ ListLines, %lls%
;~ StringCaseSense, Off
;~ s:=SubStr(s,1,InStr(s,"1",0,0)-1)
;~ s:=RegExReplace(s,"[^01]+")
;~ return, s
;~ }
;~ bit2base64(s)
;~ {
;~ s:=RegExReplace(s,"[^01]+")
;~ s.=SubStr("100000",1,6-Mod(StrLen(s),6))
;~ s:=RegExReplace(s,".{6}","|$0")
;~ Chars:="0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;~ . "abcdefghijklmnopqrstuvwxyz"
;~ SetFormat, IntegerFast, d
;~ lls:=A_ListLines=0 ? "Off" : "On"
;~ ListLines, Off
;~ Loop, Parse, Chars
;~ {
;~ i:=A_Index-1, v:="|" . (i>>5&1) . (i>>4&1)
;~ . (i>>3&1) . (i>>2&1) . (i>>1&1) . (i&1)
;~ s:=StrReplace(s,v,A_LoopField)
;~ }
;~ ListLines, %lls%
;~ return, s
;~ }
;~ ASCII(s)
;~ {
;~ if RegExMatch(s,"\$(\d+)\.([\w+/]+)",r)
;~ {
;~ s:=RegExReplace(base64tobit(r2),".{" r1 "}","$0`n")
;~ s:=StrReplace(StrReplace(s,"0","_"),"1","0")
;~ }
;~ else s=
;~ return, s
;~ }
;~ Pic(comments, add_to_Lib=0)
;~ {
;~ static Lib:=[]
;~ if (add_to_Lib)
;~ {
;~ re:="<([^>]*)>[^$]+\$\d+\.[\w+/]+"
;~ Loop, Parse, comments, |
;~ if RegExMatch(A_LoopField,re,r)
;~ Lib[Trim(r1)]:=r
;~ Lib[""]:=""
;~ }
;~ else
;~ {
;~ Text:=""
;~ Loop, Parse, comments, |
;~ Text.="|" . Lib[Trim(A_LoopField)]
;~ return, Text
;~ }
;~ }
;~ PicN(Number)
;~ {
;~ return, Pic( RegExReplace(Number, ".", "|$0") )
;~ }
;~ PicX(Text)
;~ {
;~ if !RegExMatch(Text,"\|([^$]+)\$(\d+)\.([\w+/]+)",r)
;~ return, Text
;~ w:=r2, v:=base64tobit(r3), Text:=""
;~ c:=StrLen(StrReplace(v,"0"))<=StrLen(v)//2 ? "1":"0"
;~ wz:=RegExReplace(v,".{" w "}","$0`n")
;~ SetFormat, IntegerFast, d
;~ While InStr(wz,c) {
;~ While !(wz~="m`n)^" c)
;~ wz:=RegExReplace(wz,"m`n)^.")
;~ i:=0
;~ While (wz~="m`n)^.{" i "}" c)
;~ i++
;~ v:=RegExReplace(wz,"m`n)^(.{" i "}).*","$1")
;~ wz:=RegExReplace(wz,"m`n)^.{" i "}")
;~ if v!=
;~ Text.="|" r1 "$" i "." bit2base64(v)
;~ }
;~ return, Text
;~ }
;~ ScreenShot()
;~ {
;~ n:=150000
;~ xywh2xywh(-n,-n,2*n+1,2*n+1,x,y,w,h)
;~ GetBitsFromScreen(x,y,w,h,Scan0,Stride,1)
;~ }
;~ FindTextOCR(nX, nY, nW, nH, err1, err0, Text, Interval=20)
;~ {
;~ OCR:="", RightX:=nX+nW-1, ScreenShot()
;~ While (ok:=FindText(nX, nY, nW, nH, err1, err0, Text, 0))
;~ {
;~ For k,v in ok
;~ {
;~ ; X is the X coordinates of the upper left corner
;~ ; and W is the width of the image have been found
;~ x:=v.1, y:=v.2, w:=v.3, h:=v.4, comment:=v.5
;~ ; We need the leftmost X coordinates
;~ if (A_Index=1 or x<LeftX)
;~ LeftX:=x, LeftY:=y, LeftW:=w, LeftH:=h, LeftOCR:=comment
;~ else if (x=LeftX)
;~ {
;~ Loop, 100
;~ {
;~ err:=A_Index/100
;~ if FindText(x, y, w, h, err, err, Text, 0)
;~ {
;~ LeftX:=x, LeftY:=y, LeftW:=w, LeftH:=h, LeftOCR:=comment
;~ Break
;~ }
;~ if FindText(LeftX, LeftY, LeftW, LeftH, err, err, Text, 0)
;~ Break
;~ }
;~ }
;~ }
;~ ; If the interval exceeds the set value, add "*" to the result
;~ OCR.=(A_Index>1 and LeftX-nX-1>Interval ? "*":"") . LeftOCR
;~ ; Update nX and nW for next search
;~ nX:=LeftX+LeftW-1, nW:=RightX-nX+1
;~ }
;~ return, OCR
;~ }
;~ ; Reordering the objects returned from left to right,
;~ ; from top to bottom, ignore slight height difference
;~ SortOK(ok, dy=10) {
;~ if !IsObject(ok)
;~ return, ok
;~ SetFormat, IntegerFast, d
;~ For k,v in ok
;~ {
;~ x:=v.1+v.3//2, y:=v.2+v.4//2
;~ y:=A_Index>1 and Abs(y-lasty)<dy ? lasty : y, lasty:=y
;~ n:=(y*150000+x) "." k, s:=A_Index=1 ? n : s "-" n
;~ }
;~ Sort, s, N D-
;~ ok2:=[]
;~ Loop, Parse, s, -
;~ ok2.Push( ok[(StrSplit(A_LoopField,".")[2])] )
;~ return, ok2
;~ }
;~ ; Reordering according to the nearest distance
;~ SortOK2(ok, px, py) {
;~ if !IsObject(ok)
;~ return, ok
;~ SetFormat, IntegerFast, d
;~ For k,v in ok
;~ {
;~ x:=v.1+v.3//2, y:=v.2+v.4//2
;~ n:=((x-px)**2+(y-py)**2) "." k
;~ s:=A_Index=1 ? n : s "-" n
;~ }
;~ Sort, s, N D-
;~ ok2:=[]
;~ Loop, Parse, s, -
;~ ok2.Push( ok[(StrSplit(A_LoopField,".")[2])] )
;~ return, ok2
;~ }
;~ ; Prompt mouse position in remote assistance
;~ MouseTip(x="", y="") {
;~ if (x="")
;~ {
;~ VarSetCapacity(pt,16,0), DllCall("GetCursorPos","ptr",&pt)
;~ x:=NumGet(pt,0,"uint"), y:=NumGet(pt,4,"uint")
;~ }
;~ x:=Round(x-10), y:=Round(y-10), w:=h:=2*10+1
;~ ;-------------------------
;~ Gui, _MouseTip_: +AlwaysOnTop -Caption +ToolWindow +Hwndmyid +E0x08000000
;~ Gui, _MouseTip_: Show, Hide w%w% h%h%
;~ ;-------------------------
;~ dhw:=A_DetectHiddenWindows
;~ DetectHiddenWindows, On
;~ d:=4, i:=w-d, j:=h-d
;~ s=0-0 %w%-0 %w%-%h% 0-%h% 0-0
;~ s=%s% %d%-%d% %i%-%d% %i%-%j% %d%-%j% %d%-%d%
;~ WinSet, Region, %s%, ahk_id %myid%
;~ DetectHiddenWindows, %dhw%
;~ ;-------------------------
;~ Gui, _MouseTip_: Show, NA x%x% y%y%
;~ Loop, 4 {
;~ Gui, _MouseTip_: Color, % A_Index & 1 ? "Red" : "Blue"
;~ Sleep, 500
;~ }
;~ Gui, _MouseTip_: Destroy
;~ }
;;;;;;;;;;;;;;;;;;;;;;;;;;;Copy Variables to clipboard START;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;use this line of code where to use to copy highlighted text to incrementing variable
;gosub, CopyVar
;this works as a function when you use gosub
;place this anywhere in the script
;;;;;;;;;;;;;;;;;;;;;;;;;;;Copy Variables to clipboard ENDS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;; CLASS SOCKET - it is required in the script *******START*************
class Socket
{
static __eventMsg := 0x9987
__New(s=-1)
{
static init
if (!init)
{
DllCall("LoadLibrary", "str", "ws2_32", "ptr")
VarSetCapacity(wsadata, 394+A_PtrSize)
DllCall("ws2_32\WSAStartup", "ushort", 0x0000, "ptr", &wsadata)
DllCall("ws2_32\WSAStartup", "ushort", NumGet(wsadata, 2, "ushort"), "ptr", &wsadata)
OnMessage(Socket.__eventMsg, "SocketEventProc")
init := 1
}
this.socket := s
}
__Delete()
{
this.disconnect()
}
__Get(k, v)
{
if (k="size")
return this.msgSize()
}
connect(host, port)
{
if ((this.socket!=-1) || (!(faddr := next := this.__getAddrInfo(host, port))))
return 0
while (next)
{
sockaddrlen := NumGet(next+0, 16, "uint")
sockaddr := NumGet(next+0, 16+(2*A_PtrSize), "ptr")
if ((this.socket := DllCall("ws2_32\socket", "int", NumGet(next+0, 4, "int"), "int", this.__socketType, "int", this.__protocolId, "ptr"))!=-1)
{
if ((r := DllCall("ws2_32\WSAConnect", "ptr", this.socket, "ptr", sockaddr, "uint", sockaddrlen, "ptr", 0, "ptr", 0, "ptr", 0, "ptr", 0, "int"))=0)
{
DllCall("ws2_32\freeaddrinfo", "ptr", faddr)
return Socket.__eventProcRegister(this, 0x21)
}
this.disconnect()
}
next := NumGet(next+0, 16+(3*A_PtrSize), "ptr")
}
this.lastError := DllCall("ws2_32\WSAGetLastError")
return 0
}
bind(host, port)
{
if ((this.socket!=-1) || (!(faddr := next := this.__getAddrInfo(host, port))))
return 0
while (next)
{
sockaddrlen := NumGet(next+0, 16, "uint")
sockaddr := NumGet(next+0, 16+(2*A_PtrSize), "ptr")
if ((this.socket := DllCall("ws2_32\socket", "int", NumGet(next+0, 4, "int"), "int", this.__socketType, "int", this.__protocolId, "ptr"))!=-1)
{
if (DllCall("ws2_32\bind", "ptr", this.socket, "ptr", sockaddr, "uint", sockaddrlen, "int")=0)
{
DllCall("ws2_32\freeaddrinfo", "ptr", faddr)
return Socket.__eventProcRegister(this, 0x29)
}
this.disconnect()
}
next := NumGet(next+0, 16+(3*A_PtrSize), "ptr")
}
this.lastError := DllCall("ws2_32\WSAGetLastError")
return 0
}
listen(backlog=32)
{
return (DllCall("ws2_32\listen", "ptr", this.socket, "int", backlog)=0) ? 1 : 0
}
accept()
{
if ((s := DllCall("ws2_32\accept", "ptr", this.socket, "ptr", 0, "int", 0, "ptr"))!=-1)
{
newsock := new Socket(s)
newsock.__protocolId := this.__protocolId
newsock.__socketType := this.__socketType
Socket.__eventProcRegister(newsock, 0x21)
return newsock
}
return 0
}
disconnect()
{
Socket.__eventProcUnregister(this)
DllCall("ws2_32\closesocket", "ptr", this.socket, "int")
this.socket := -1
return 1
}
msgSize()
{
VarSetCapacity(argp, 4, 0)
if (DllCall("ws2_32\ioctlsocket", "ptr", this.socket, "uint", 0x4004667F, "ptr", &argp)!=0)
return 0
return NumGet(argp, 0, "int")
}
send(addr, length)
{
if ((r := DllCall("ws2_32\send", "ptr", this.socket, "ptr", addr, "int", length, "int", 0, "int"))<=0)
return 0
return r
}
sendText(msg, encoding="UTF-8")
{
VarSetCapacity(buffer, length := (StrPut(msg, encoding)*(((encoding="utf-16")||(encoding="cp1200")) ? 2 : 1)))
StrPut(msg, &buffer, encoding)
return this.send(&buffer, length)
}
recv(byref buffer, wait=1)
;SplashTextOn,,,test ;;;;;;CODE MODIFIED START***********************
{
while ((wait) && ((length := this.msgSize())=0)) ;This is a loop. It will loop indefenitely if no data is received.
{
if A_index > 30 ; ;3 secs timeout loop
break
sleep, 100 ;30 multiply by 100 = 3000
}
;SplashTextOff ;;;;;CODE MODIFIED END**********************************
if (length)
{
VarSetCapacity(buffer, length)
if ((r := DllCall("ws2_32\recv", "ptr", this.socket, "ptr", &buffer, "int", length, "int", 0))<=0)
return 0
return r
}
return 0
}
recvText(wait=1, encoding="UTF-8")
{
if (length := this.recv(buffer, wait))
return StrGet(&buffer, length, encoding)
return
}
__getAddrInfo(host, port)
{
a := ["127.0.0.1", "0.0.0.0", "255.255.255.255", "::1", "::", "FF00::"]
conv := {localhost:a[1], addr_loopback:a[1], inaddr_loopback:a[1], addr_any:a[2], inaddr_any:a[2], addr_broadcast:a[3]
, inaddr_broadcast:a[3], addr_none:a[3], inaddr_none:a[3], localhost6:a[4], addr_loopback6:a[4], inaddr_loopback6:a[4]
, addr_any6:a[5], inaddr_any:a[5], addr_broadcast6:a[6], inaddr_broadcast6:a[6], addr_none6:a[6], inaddr_none6:a[6]}
if (conv[host])
host := conv[host]
VarSetCapacity(hints, 16+(4*A_PtrSize), 0)
NumPut(this.__socketType, hints, 8, "int")
NumPut(this.__protocolId, hints, 12, "int")
if ((r := DllCall("ws2_32\getaddrinfo", "astr", host, "astr", port, "ptr", &hints, "ptr*", next))!=0)
{
this.lastError := DllCall("ws2_32\WSAGetLastError")
return 0
}
return next
}
__eventProcRegister(obj, msg)
{
a := SocketEventProc(0, 0, "register", 0)
a[obj.socket] := obj
return (DllCall("ws2_32\WSAAsyncSelect", "ptr", obj.socket, "ptr", A_ScriptHwnd, "uint", Socket.__eventMsg, "uint", msg)=0) ? 1 : 0
}
__eventProcUnregister(obj)
{
a := SocketEventProc(0, 0, "register", 0)
a.remove(obj.socket)
return (DllCall("ws2_32\WSAAsyncSelect", "ptr", obj.socket, "ptr", A_ScriptHwnd, "uint", 0, "uint", 0)=0) ? 1 : 0
}
}
SocketEventProc(wParam, lParam, msg, hwnd)
{
global Socket
static a := []
;Critical <--this is causing problems
if (msg="register")
return a
if (msg=Socket.__eventMsg)
{
if (!isobject(a[wParam]))
return 0
if ((lParam & 0xFFFF) = 1)
return a[wParam].onRecv(a[wParam])
else if ((lParam & 0xFFFF) = 8)
return a[wParam].onAccept(a[wParam])
else if ((lParam & 0xFFFF) = 32)
{
a[wParam].socket := -1
return a[wParam].onDisconnect(a[wParam])
}
return 0
}
return 0
}
class SocketTCP extends Socket
{
static __protocolId := 6 ;IPPROTO_TCP
static __socketType := 1 ;SOCK_STREAM
}
class SocketUDP extends Socket
{
static __protocolId := 17 ;IPPROTO_UDP
static __socketType := 2 ;SOCK_DGRAM
enableBroadcast()
{
VarSetCapacity(optval, 4, 0)
NumPut(1, optval, 0, "uint")
if (DllCall("ws2_32\setsockopt", "ptr", this.socket, "int", 0xFFFF, "int", 0x0020, "ptr", &optval, "int", 4)=0)
return 1
return 0
}
disableBroadcast()
{
VarSetCapacity(optval, 4, 0)
if (DllCall("ws2_32\setsockopt", "ptr", this.socket, "int", 0xFFFF, "int", 0x0020, "ptr", &optval, "int", 4)=0)
return 1
return 0
}
}
;;;;;;;;; CLASS SOCKET - it is required in the script *******END*************
makeClose:
IfNotExist, %myDir%\close.ahk
{
haystack =
#SingleInstance, Force
(LTrim Join`n
;;;;;;;;; CLASS SOCKET - it is required in the script *******START*************
class Socket
{
static __eventMsg := 0x9987
__New(s=-1)
{
static init
if (!init)
{
DllCall("LoadLibrary", "str", "ws2_32", "ptr")
VarSetCapacity(wsadata, 394+A_PtrSize)
DllCall("ws2_32\WSAStartup", "ushort", 0x0000, "ptr", &wsadata)
DllCall("ws2_32\WSAStartup", "ushort", NumGet(wsadata, 2, "ushort"), "ptr", &wsadata)
OnMessage(Socket.__eventMsg, "SocketEventProc")
init := 1
}
this.socket := s
}
__Delete()
{
this.disconnect()
}
__Get(k, v)
{
if (k="size")
return this.msgSize()
}
connect(host, port)
{
if ((this.socket!=-1) || (!(faddr := next := this.__getAddrInfo(host, port))))
return 0
while (next)
{
sockaddrlen := NumGet(next+0, 16, "uint")
sockaddr := NumGet(next+0, 16+(2*A_PtrSize), "ptr")
if ((this.socket := DllCall("ws2_32\socket", "int", NumGet(next+0, 4, "int"), "int", this.__socketType, "int", this.__protocolId, "ptr"))!=-1)
{
if ((r := DllCall("ws2_32\WSAConnect", "ptr", this.socket, "ptr", sockaddr, "uint", sockaddrlen, "ptr", 0, "ptr", 0, "ptr", 0, "ptr", 0, "int"))=0)
{
DllCall("ws2_32\freeaddrinfo", "ptr", faddr)
return Socket.__eventProcRegister(this, 0x21)
}
this.disconnect()
}
next := NumGet(next+0, 16+(3*A_PtrSize), "ptr")
}
this.lastError := DllCall("ws2_32\WSAGetLastError")
return 0
}
bind(host, port)
{
if ((this.socket!=-1) || (!(faddr := next := this.__getAddrInfo(host, port))))
return 0
while (next)
{
sockaddrlen := NumGet(next+0, 16, "uint")
sockaddr := NumGet(next+0, 16+(2*A_PtrSize), "ptr")
if ((this.socket := DllCall("ws2_32\socket", "int", NumGet(next+0, 4, "int"), "int", this.__socketType, "int", this.__protocolId, "ptr"))!=-1)
{
if (DllCall("ws2_32\bind", "ptr", this.socket, "ptr", sockaddr, "uint", sockaddrlen, "int")=0)
{
DllCall("ws2_32\freeaddrinfo", "ptr", faddr)
return Socket.__eventProcRegister(this, 0x29)
}
this.disconnect()
}
next := NumGet(next+0, 16+(3*A_PtrSize), "ptr")
}
this.lastError := DllCall("ws2_32\WSAGetLastError")
return 0
}
listen(backlog=32)
{
return (DllCall("ws2_32\listen", "ptr", this.socket, "int", backlog)=0) ? 1 : 0
}
accept()
{
if ((s := DllCall("ws2_32\accept", "ptr", this.socket, "ptr", 0, "int", 0, "ptr"))!=-1)
{
newsock := new Socket(s)
newsock.__protocolId := this.__protocolId
newsock.__socketType := this.__socketType
Socket.__eventProcRegister(newsock, 0x21)
return newsock
}
return 0
}
disconnect()
{
Socket.__eventProcUnregister(this)
DllCall("ws2_32\closesocket", "ptr", this.socket, "int")
this.socket := -1
return 1
}
msgSize()
{
VarSetCapacity(argp, 4, 0)
if (DllCall("ws2_32\ioctlsocket", "ptr", this.socket, "uint", 0x4004667F, "ptr", &argp)!=0)
return 0
return NumGet(argp, 0, "int")
}
send(addr, length)
{
if ((r := DllCall("ws2_32\send", "ptr", this.socket, "ptr", addr, "int", length, "int", 0, "int"))<=0)
return 0
return r
}
sendText(msg, encoding="UTF-8")
{
VarSetCapacity(buffer, length := (StrPut(msg, encoding)*(((encoding="utf-16")||(encoding="cp1200")) ? 2 : 1)))
StrPut(msg, &buffer, encoding)
return this.send(&buffer, length)
}
recv(byref buffer, wait=1)
;SplashTextOn,,,test ;;;;;;CODE MODIFIED START***********************
{
while ((wait) && ((length := this.msgSize())=0)) ;This is a loop. It will loop indefenitely if no data is received.
{
if A_index > 30 ; ;3 secs timeout loop
break
sleep, 100 ;30 multiply by 100 = 3000
}
;SplashTextOff ;;;;;CODE MODIFIED END**********************************
if (length)
{
VarSetCapacity(buffer, length)
if ((r := DllCall("ws2_32\recv", "ptr", this.socket, "ptr", &buffer, "int", length, "int", 0))<=0)
return 0
return r
}
return 0
}
recvText(wait=1, encoding="UTF-8")
{
if (length := this.recv(buffer, wait))
return StrGet(&buffer, length, encoding)
return
}
__getAddrInfo(host, port)
{
a := ["127.0.0.1", "0.0.0.0", "255.255.255.255", "::1", "::", "FF00::"]
conv := {localhost:a[1], addr_loopback:a[1], inaddr_loopback:a[1], addr_any:a[2], inaddr_any:a[2], addr_broadcast:a[3]
, inaddr_broadcast:a[3], addr_none:a[3], inaddr_none:a[3], localhost6:a[4], addr_loopback6:a[4], inaddr_loopback6:a[4]
, addr_any6:a[5], inaddr_any:a[5], addr_broadcast6:a[6], inaddr_broadcast6:a[6], addr_none6:a[6], inaddr_none6:a[6]}
if (conv[host])
host := conv[host]
VarSetCapacity(hints, 16+(4*A_PtrSize), 0)
NumPut(this.__socketType, hints, 8, "int")
NumPut(this.__protocolId, hints, 12, "int")
if ((r := DllCall("ws2_32\getaddrinfo", "astr", host, "astr", port, "ptr", &hints, "ptr*", next))!=0)
{
this.lastError := DllCall("ws2_32\WSAGetLastError")
return 0
}
return next
}
__eventProcRegister(obj, msg)
{
a := SocketEventProc(0, 0, "register", 0)
a[obj.socket] := obj
return (DllCall("ws2_32\WSAAsyncSelect", "ptr", obj.socket, "ptr", A_ScriptHwnd, "uint", Socket.__eventMsg, "uint", msg)=0) ? 1 : 0
}
__eventProcUnregister(obj)
{
a := SocketEventProc(0, 0, "register", 0)
a.remove(obj.socket)
return (DllCall("ws2_32\WSAAsyncSelect", "ptr", obj.socket, "ptr", A_ScriptHwnd, "uint", 0, "uint", 0)=0) ? 1 : 0
}
}
SocketEventProc(wParam, lParam, msg, hwnd)
{
global Socket
static a := []
;Critical <--this is causing problems
if (msg="register")
return a
if (msg=Socket.__eventMsg)
{
if (!isobject(a[wParam]))
return 0
if ((lParam & 0xFFFF) = 1)
return a[wParam].onRecv(a[wParam])
else if ((lParam & 0xFFFF) = 8)
return a[wParam].onAccept(a[wParam])
else if ((lParam & 0xFFFF) = 32)
{
a[wParam].socket := -1
return a[wParam].onDisconnect(a[wParam])
}
return 0
}
return 0
}
class SocketTCP extends Socket
{
static __protocolId := 6 ;IPPROTO_TCP
static __socketType := 1 ;SOCK_STREAM
}
class SocketUDP extends Socket
{
static __protocolId := 17 ;IPPROTO_UDP
static __socketType := 2 ;SOCK_DGRAM
enableBroadcast()
{
VarSetCapacity(optval, 4, 0)
NumPut(1, optval, 0, "uint")
if (DllCall("ws2_32\setsockopt", "ptr", this.socket, "int", 0xFFFF, "int", 0x0020, "ptr", &optval, "int", 4)=0)
return 1
return 0
}
disableBroadcast()
{
VarSetCapacity(optval, 4, 0)
if (DllCall("ws2_32\setsockopt", "ptr", this.socket, "int", 0xFFFF, "int", 0x0020, "ptr", &optval, "int", 4)=0)
return 1
return 0
}
}
;;;;;;;;; CLASS SOCKET - it is required in the script *******END*************
)
textToWrite := haystack
FileAppend, %textToWrite%,%myDir%\close.ahk
}
return