How Can I select some text and replace in URL in parts like place holder

Get help with using AutoHotkey and its commands and hotkeys
himanshu
Posts: 2
Joined: 03 Jul 2020, 02:38

How Can I select some text and replace in URL in parts like place holder

03 Jul 2020, 03:45

Hello Sirs,

I am new to AHK and I would like to simplify the process of searching some shipment's operational status from some particular websites for given AWB number.
I have the format in which target website front end sends query to the database.

Target URL: http www.cargocel.in:8080 /tt/celebi/CargoTrackingdetailBeforeLogin.aspx?awbpfx=607&cod_awb_num=89381703&pageno=0&VTSrno=0&totVT=0

An AWB number is 11 Digits with Initial 3 digits represents the airline code i.e - 607-89381703 in this 607 is IATA code of Etihad airline and rest 8 digits are AWB number). In above target URL, AWB Prefix and AWB number is in UNDERLINE.

My specific requirement is to copy the AWB number from outlook or any current open application; and then run the target website with copied AWB number (like placeholder in prefix and AWB number)

Please help me generating the AHK script for this.

Thank You.

Himanshu
User avatar
elModo7
Posts: 167
Joined: 01 Sep 2017, 02:38
GitHub: elModo7
Location: Spain
Contact:

Re: How Can I select some text and replace in URL in parts like place holder

03 Jul 2020, 05:05

Long time I don't hear anything about AWBs, I had a lot of fun making apps for a pair of delivery companies, this should fit your need.
You copy AWB and it instantly runs the page you sent in your first post with correct format.

Code: Select all

#NoEnv
#Persistent
#SingleInstance Force
; ==============================================================================
OnClipboardChange("GenerateLink")
GenerateLink()
{
	if(StrLen(Clipboard) = 11)
	{
		awb := []
		awb.awb := Clipboard
		awb.country := SubStr(awb.awb, 1, 3)
		awb.code := SubStr(awb.awb, 4, 8)
		web := "http://www.cargocel.in:8080/tt/celebi/CargoTrackingdetailBeforeLogin.aspx?awbpfx=" awb.country "&cod_awb_num=" awb.code "&pageno=0&VTSrno=0&totVT=0"
		Run, % web
	}
}
:beer:
himanshu
Posts: 2
Joined: 03 Jul 2020, 02:38

Re: How Can I select some text and replace in URL in parts like place holder

03 Jul 2020, 05:47

elModo7 wrote:
03 Jul 2020, 05:05
Long time I don't hear anything about AWBs, I had a lot of fun making apps for a pair of delivery companies, this should fit your need.
You copy AWB and it instantly runs the page you sent in your first post with correct format.

Code: Select all

#NoEnv
#Persistent
#SingleInstance Force
; ==============================================================================
OnClipboardChange("GenerateLink")
GenerateLink()
{
	if(StrLen(Clipboard) = 11)
	{
		awb := []
		awb.awb := Clipboard
		awb.country := SubStr(awb.awb, 1, 3)
		awb.code := SubStr(awb.awb, 4, 8)
		web := "http www.cargocel.in:8080 /tt/celebi/CargoTrackingdetailBeforeLogin.aspx?awbpfx="  Broken Link for safety awb.country "&cod_awb_num=" awb.code "&pageno=0&VTSrno=0&totVT=0"
		Run, % web
	}
}
Thank you @ elModo7 Seven blessings to you!
Just needed to modify the StrLen(Clipboard) value to 12 due to total length including Hyphen becomes 13.

Is there a way to omit the Hyphen or the white spaces from selection so that no matter in which format AWB number has been selected on screen, so it always omits the hyphen and the white spaces.

For Example, any one can write an AWB number as per below as per their convenience:
607-89381670
607-8938-1670
607-8938 1670
607 8938 1670
60789381670

Thank you once again for your help
User avatar
elModo7
Posts: 167
Joined: 01 Sep 2017, 02:38
GitHub: elModo7
Location: Spain
Contact:

Re: How Can I select some text and replace in URL in parts like place holder

04 Jul 2020, 04:34

Replace awb.awb := Clipboard with awb.awb := StrReplace(Clipboard, "-")
That will remove the hyphen.
:beer:

Return to “Ask For Help”

Who is online

Users browsing this forum: Gorgrak, markhavemann, neo256, Tomo2407 and 45 guests