Hello,
I'm trying to find a way to copy and paste from an Applicant Tracking System onto Gmail and vice-versa, just by highlighting the text. For example:
- I highlight the word "people" in the ATS and it automatically gets copied.
- Then in Gmail, I want the word "cool" to be replaced by "people" by highlighting it.
A few notes - I used Windows Spy to check the Class of the ATS and it's the same as the Gmail one: ahk_exe chrome.exe
My trouble is that the script doesn't work if both classes are ahk_exe chrome.exe so I'm trying to find a way around it.
Any help would be appreciated. Below is the current script I'm using:
#SingleInstance Force
~LButton::
{ KeyWait, LButton, T0.5 ;Wait for half sec to start copying things.
If ErrorLevel
{ SoundBeep, 100, 10
IfWinActive, ahk_exe chrome.exe
{ Keywait, LButton ;Wait for LButton to be released
Send, ^c
} IfWinActive, ahk_exe chrome.exe
{ Keywait, LButton ;Wait for LButton to be released
Send, ^v
} } } Return
~Esc::ExitApp
Help with revising a script Topic is solved
-
- Posts: 6
- Joined: 08 Jul 2019, 13:12
Re: Help with revising a script
Try this Copy from AutoHotkey site & replace in Gmail in Chrome.Edit: A bit of condensation.
Code: Select all
#SingleInstance Force
~LButton::
KeyWait, LButton, T0.5 ;Wait for half sec to start copying things.
If ErrorLevel
{
SoundBeep, 100, 10
WinGetClass, strClass, A
ActUrl:=GetCurrentUrlAcc(strClass)
Keywait, LButton ;Wait for LButton to be released
If WinActive("ahk_exe chrome.exe") && (ActUrl ~= "autohotkey\.com") ;replace with 'ATS' (RegEx!) string
Send, ^c
If WinActive("ahk_exe chrome.exe") && (ActUrl ~= "google\.com/mail") ;this is tested
Send, ^v
}
Return
~Esc::ExitApp
GetCurrentUrlAcc(strClass)
; Found at https://autohotkey.com/boards/viewtopic.php?f=6&t=3702&start=60
;------------------------------------------------------------
{
; static or global?
global nWindow
global accAddressBar
If (nWindow != WinExist("ahk_class " strClass)) ; reuses accAddressBar if it's the same window
{
nWindow := WinExist("ahk_class " strClass)
accAddressBar := GetAddressBar(GetCurrentUrlAccObjectFromWindow(nWindow))
}
Try sURL := accAddressBar.accValue(0)
If (sURL == "")
{
WinGet, nWindows, List, % "ahk_class " strClass ; In case of a nested browser window as in the old CoolNovo (TO DO: check if still needed)
If (nWindows > 1)
{
accAddressBar := GetAddressBar(GetCurrentUrlAccObjectFromWindow(nWindows2))
Try sURL := accAddressBar.accValue(0)
}
}
If ((sURL != "") and (SubStr(sURL, 1, 4) != "http")) ; Modern browsers omit "http://"
sURL := "http://" . sURL
If (sURL == "")
nWindow := -1 ; Don't remember the window if there is no URL
Return sURL
}
;------------------------------------------------------------
;------------------------------------------------------------
GetAddressBar(accObj, accPath:="")
; "GetAddressBar" based in code by stealzy
; Found at https://autohotkey.com/boards/viewtopic.php?p=109548#p109548
; IsUrl in this functions above replaced by my own code LocationIsHttp
;------------------------------------------------------------
{
n := 0
Try If ((accObj.accRole(0) == 42) and StrLen(accObj.accValue(0)) and LocationIsHttp(accObj.accValue(0)))
Return accObj
Try If ((accObj.accRole(0) == 42) and StrLen(accObj.accValue(0)) and LocationIsHttp("http://" . accObj.accValue(0))) ; Modern browsers omit "http://"
Return accObj
For nChild, accChild in GetCurrentUrlAccChildren(accObj)
{
n++
currentPath := accPath . n . "."
If IsObject(accAddressBar := GetAddressBar(accChild, currentPath))
Return accAddressBar
}
}
;------------------------------------------------------------
;------------------------------------------------------------
GetCurrentUrlAccInit()
; Part of the Acc.ahk Standard Library by Sean (updated by jethrow) (via Joe Glines)
; Found at http://autohotkey.com/board/topic/77303-/?p=491516
;------------------------------------------------------------
{
static h
If Not h
h := DllCall("LoadLibrary", "Str", "oleacc", "Ptr")
}
;------------------------------------------------------------
;------------------------------------------------------------
GetCurrentUrlAccObjectFromWindow(hWnd, idObject = 0)
; Part of the Acc.ahk Standard Library by Sean (updated by jethrow) (via Joe Glines)
; Found at http://autohotkey.com/board/topic/77303-/?p=491516
;------------------------------------------------------------
{
GetCurrentUrlAccInit()
If DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr"
, -VarSetCapacity(IID, 16) + NumPut(idObject == 0xFFFFFFF0 ? 0x46000000000000C0 : 0x719B3800AA000C81
, NumPut(idObject == 0xFFFFFFF0 ? 0x0000000000020400 : 0x11CF3C3D618736E0, IID, "Int64"), "Int64"), "Ptr*", pacc) = 0
Return ComObjEnwrap(9, pacc, 1)
}
;------------------------------------------------------------
;------------------------------------------------------------
GetCurrentUrlAccQuery(objAcc)
; Part of the Acc.ahk Standard Library by Sean (updated by jethrow) (via Joe Glines)
; Found at http://autohotkey.com/board/topic/77303-/?p=491516
;------------------------------------------------------------
{
Try Return ComObj(9, ComObjQuery(objAcc, "{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
}
;------------------------------------------------------------
;------------------------------------------------------------
GetCurrentUrlAccChildren(objAcc)
; Part of the Acc.ahk Standard Library by Sean (updated by jethrow) (via Joe Glines)
; Found at http://autohotkey.com/board/topic/77303-/?p=491516
;------------------------------------------------------------
{
If ComObjType(objAcc,"Name") != "IAccessible"
ErrorLevel := "Invalid IAccessible Object"
Else
{
GetCurrentUrlAccInit()
cChildren := objAcc.accChildCount
Children := []
If DllCall("oleacc\AccessibleChildren", "Ptr", ComObjValue(objAcc), "Int", 0, "Int", cChildren, "Ptr"
, VarSetCapacity(varChildren, cChildren * (8 + 2 * A_PtrSize), 0) * 0 + &varChildren, "Int*", cChildren) = 0
{
Loop, %cChildren%
{
i := (A_Index - 1) * (A_PtrSize * 2 + 8) + 8
child := NumGet(varChildren, i)
Children.Insert(NumGet(varChildren, i - 8) = 9 ? GetCurrentUrlAccQuery(child) : child)
(NumGet(varChildren, i - 8) = 9 ? ObjRelease(child) : "")
}
Return (Children.MaxIndex() ? Children : "")
}
Else
ErrorLevel := "AccessibleChildren DllCall Failed"
}
}
;------------------------------------------------------------
;------------------------------------------------------------
LocationIsHTTP(strLocation)
;------------------------------------------------------------
{
return SubStr(strLocation, 1, 7) = "http://" or SubStr(strLocation, 1, 8) = "https://"
}
;------------------------------------------------------------
;------------------------------------------------------------
GetWebPageTitle(strLocation)
;------------------------------------------------------------
{
ToolTip, %lToolTipRetrievingWebPageTitle%
strHTML := Url2Var(strLocation)
ToolTip
RegExMatch(strHTML, "is)<title>(.*?)</title>", strTitle)
StringReplace, strTitle, strTitle, <title>
StringReplace, strTitle, strTitle, </title>
StringReplace, strTitle, strTitle, `r, , A
StringReplace, strTitle, strTitle, `t, %A_Space%, A
StringReplace, strTitle, strTitle, `n, %A_Space%, A
return NumDecode(Trim(strTitle, Chr(160))) ; Chr(160) to also trim non-breaking spaces
}
;------------------------------------------------------------
;------------------------------------------------------------
Url2Var(strUrl)
;------------------------------------------------------------
{
objWebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
/*
if (A_LastError)
; an error occurred during ComObjCreate (A_LastError probably is E_UNEXPECTED = -2147418113 #0x8000FFFFL)
BUT DO NOT ABORT because the following commands will be executed even if an error occurred in ComObjCreate (!)
*/
objWebRequest.Open("GET", strUrl)
objWebRequest.Send()
return (objWebRequest.StatusText() = "OK" ? objWebRequest.ResponseText() : "")
}
;------------------------------------------------------------
;------------------------------------------------------------
NumDecode(str)
; Extracted from Dec_XML() https://autohotkey.com/board/topic/29866-encoding-and-decoding-functions-v11/
; converts "é" or "é" to "é"
;------------------------------------------------------------
{
Loop
If RegexMatch(str, "S)(&#(\d+);)", dec) ; matches: &#[dec];
StringReplace, str, str, %dec1%, % Chr(dec2), All
Else If RegexMatch(str, "Si)(&#x([\da-f]+);)", hex) ; matches: &#x[hex];
StringReplace, str, str, %hex1%, % Chr("0x" . hex2), All
Else
Break
return str
}
;------------------------------------------------------------
-
- Posts: 6
- Joined: 08 Jul 2019, 13:12
Re: Help with revising a script
I apologize but I made in error in explaining what I was trying to do. I initially said:
"A few notes - I used Windows Spy to check the Class of the ATS and it's the same as the Gmail one: ahk_exe chrome.exe
My trouble is that the script doesn't work if both classes are ahk_exe chrome.exe so I'm trying to find a way around it. "
when I really meant to talk about 'Processes' (not Class), which should have read as:
"A few notes - I used Windows Spy to check the Process of the ATS and it's the same as the Gmail one: ahk_exe chrome.exe
My trouble is that the script doesn't work if both 'Processes' are ahk_exe chrome.exe so I'm trying to find a way around it. "
@rommmcek I tried copying and pasting the script you provided but and tried looking at the links, but I'm afraid I don't quite understand - completely a newb when it comes to scripting. I did notice the links you provided talked about Class, rather than Processes, but I'm guessing it's moot now. I also read the tutorial to get a basic understanding of AHK, but that's as far as I got.
Again, thank you for your help. I do appreciate it.
"A few notes - I used Windows Spy to check the Class of the ATS and it's the same as the Gmail one: ahk_exe chrome.exe
My trouble is that the script doesn't work if both classes are ahk_exe chrome.exe so I'm trying to find a way around it. "
when I really meant to talk about 'Processes' (not Class), which should have read as:
"A few notes - I used Windows Spy to check the Process of the ATS and it's the same as the Gmail one: ahk_exe chrome.exe
My trouble is that the script doesn't work if both 'Processes' are ahk_exe chrome.exe so I'm trying to find a way around it. "
@rommmcek I tried copying and pasting the script you provided but and tried looking at the links, but I'm afraid I don't quite understand - completely a newb when it comes to scripting. I did notice the links you provided talked about Class, rather than Processes, but I'm guessing it's moot now. I also read the tutorial to get a basic understanding of AHK, but that's as far as I got.
Again, thank you for your help. I do appreciate it.
Re: Help with revising a script Topic is solved
I thought it was your script!
1. Have running the script posted above.
2. Have opened this site (autohotkey.com..) in Chrome
3. Have opened Gmail in Chrome composing a new message (post) with some editable text.
4. Activate this site (autohotkey.com..) and double click on any word keeping left mouse button down after second click.
5. Wait half of a second to hear short low pitched beep.
6. Release left mouse button
7. Activate Gmail in Chrome composing a new message (post) with some editable text.
8. Double click on any (editable) word keeping left mouse button down after second click.
9. Wait half of a second to hear short low pitched beep.
10. Release left mouse button.
11. Marked word in Gmail should be replaced with the marked word in AutoHotkey.
If it works, you should replaced "autohotkey\.com" string with your desired ATS string (be sure to escape . (dot) with backslash.
bye!
1. Have running the script posted above.
2. Have opened this site (autohotkey.com..) in Chrome
3. Have opened Gmail in Chrome composing a new message (post) with some editable text.
4. Activate this site (autohotkey.com..) and double click on any word keeping left mouse button down after second click.
5. Wait half of a second to hear short low pitched beep.
6. Release left mouse button
7. Activate Gmail in Chrome composing a new message (post) with some editable text.
8. Double click on any (editable) word keeping left mouse button down after second click.
9. Wait half of a second to hear short low pitched beep.
10. Release left mouse button.
11. Marked word in Gmail should be replaced with the marked word in AutoHotkey.
If it works, you should replaced "autohotkey\.com" string with your desired ATS string (be sure to escape . (dot) with backslash.
bye!
-
- Posts: 6
- Joined: 08 Jul 2019, 13:12
Re: Help with revising a script
This works. Thank you!
Who is online
Users browsing this forum: yarsis and 203 guests