AHK Webpage Search

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

AHK Webpage Search

22 Sep 2017, 13:51

VERY NEW TO SCRIPTING..
Hi I am trying to create a Script to find Words on our 911 Dispatching Site to send a MsgBox when found.
I have tried coping to clipboard and searching it but its not working right. I am wanting to search for the words "Status: Dispatched". If found Create MsgBox Stating the Words that follow "Call Type: " And "Location: "
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Status: Dispatched "Find" If Found Then, Find Call Type
Call Number: 0
Call Type: Structure Fire "Find" MsgBox with following words or 20 Letters. Include Location:
Beat:
Location: 123 Forest ST "Also" with following words or 20 Letters
Secondary Location:

Example MsgBox
Dispatched
Structure Fire
123 Forest ST
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The Following Never Change, Just what Follows.
Status:
Call Number:
Call Type:
Beat:
Location:
Secondary Location:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If Anyone is able to assist Please Help. Thanks
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: AHK WEBPAGE SEARCH

22 Sep 2017, 16:57

Show what You tried so far. use [ code=autohotkey ] tag for that.

So, this is your sample input?:

Code: Select all

Status: Dispatched
Call Number: 0
Call Type: Structure Fire
Beat:
Location: 123 Forest ST
Secondary Location:
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

Re: AHK WEBPAGE SEARCH

22 Sep 2017, 18:36

no this is one of the Scripts i have tried

{
Sleep, 5000
Send,^a
Send,^c
ClipWait,2
clip = %clipboard%
Haystack = Status: Dispatched
Needle = Status: Dispatched
IfInString, Haystack, %Needle%
MsgBox, The string was found.
return
else,
Sleep, 1
User avatar
Xtra
Posts: 2744
Joined: 02 Oct 2015, 12:15

Re: AHK WEBPAGE SEARCH

22 Sep 2017, 22:05

Code: Select all

1::
    Clipboard := ""
    Send,^a
    Send,^c
    ClipWait,2
    MsgBox % CheckStatus(Clipboard)
return

CheckStatus(textString)
{
    items := StrSplit(textString,"`n","`r")
    if InStr(items.1, "Status: Dispatched")
        return strReplace(items.1,"Status: ") . "`n" 
             . strReplace(items.3,"Call Type: ") . "`n" 
             . strReplace(items.5,"Location: ")
    return false
}

/*
Status: Dispatched
Call Number: 0
Call Type: Structure Fire
Beat:
Location: 123 Forest ST
Secondary Location:
*/
HTH
Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

Re: AHK WEBPAGE SEARCH

24 Sep 2017, 08:14

To: Xtra
This Script brings back a MsgBox with just a "0". Do i need to add this to what i already have or edit it slightly?
I have tried changing Dispatched to Enroute due to having plenty of Enroute pages to test with. Still just gives "0".
could you maybe explain the setup for CheckStatus?
Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

Re: AHK WEBPAGE SEARCH

24 Sep 2017, 08:51

I have Corrected Script. The problem was I deleted parts of what copies to Clipboard from website, do to Private information. The following is how it copies to clipboard. Works great Except for It brings up MsgBox and Include the following, At Hospital Time:, Arrived At Patient Time:. Due to following after Status and Call Type. Is there away to ignore At Hospital Time: And Arrived At Patient Time:. Maybe Ignore After Two Consecutive Spaces? There Are two Spaces Between Available And At Hospital Time:. and same for Call Type:. Thanks

Line,1
Line,2 Welcome FD
Line,3 Current Calls Cleared Call Search Map
Line,4 CAD Web View
Line,5 Unit: FD
Line,6 ORI: 0000000 Staged Time:
Line,7 Officer: Transport Time:
Line,8 Status: Available At Hospital Time:
Line,9 Call Number: 0 Depart Hospital Time:
Line,10 Call Type: Arrived At Patient Time:
Line,11 Beat: En Route Time:
Line,12 Location:
Line,13 Secondary Location:
Line,14 Unit Log: 15 rows
Line,15 Date: to
Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

Re: AHK WEBPAGE SEARCH

24 Sep 2017, 14:08

The following Code works, But it Displays a MsgBox when Nothing is found. Change Available to Dispatched and it will display a blank Box. I would like it to have no MsgBox until Dispatched is found.
Thanks anyone's help is greatly appreciated.
___________________________________________________________________________________________________________
"Code"
Loop
{
Sleep, 2000
Send, {F5}
Sleep, 3000
Clipboard := ""
Send,^a
Send,^c
ClipWait,2
MsgBox % CheckStatus(Clipboard)

CheckStatus(textString)
{

items := StrSplit(textString,"`n","`r")
if InStr(items.8, "Status: Available")
return strReplace(items.25,"Status: ") . "`n"

}

}
Return

_______________________________________________________________________________________________________________
"Clipboard"
Items.1
Items.2 Welcome fd
Items.3 Current Calls Cleared Call Search Map
Items.4 CAD Web View
Items.5 Unit: FD
Items.6 ORI: 0000000 Staged Time:
Items.7 Officer: Transport Time:
Items.8 Status: Available At Hospital Time:
Items.9 Call Number: 0 Depart Hospital Time:
Items.10 Call Type: Arrived At Patient Time:
Items.11 Beat: En Route Time:
Items.12 Location:
Items.13 Secondary Location:
Items.14 Unit Log: 15 rows
Items.15 Date: to
Items.16
Items.17
Items.18
Items.19
Items.20
Items.21
Items.22
Items.23 Available 2017-00000939 09/24/2017 01:08:03 Unit Cleared From Call Unit Cleared
Items.24 Available 2017-00000939 09/24/2017 01:08:03 CLR Unit Status Change
Items.25 Dispatched 2017-00000939 09/24/2017 01:05:10 DSP Call Number: 590, Location: 210 ABCDEFG TRL, City, Call Type:
egocarib
Posts: 100
Joined: 21 May 2015, 18:21

Re: AHK WEBPAGE SEARCH

24 Sep 2017, 14:33

I would do this with Regex, though it is probably harder to understand if you are not familiar with Regex.

Code: Select all

Clipboard := ""
Send,^a
Send,^c
ClipWait,2
startPosition := 1
Loop
{
	foundPos := RegExMatch(Clipboard, "O)Status: Dispatched[\S\s]*?(Call Type:.*)[\S\s]*?(Location:.*)", match, startPosition)
	if !foundPos
		Break ;no more matches
	MsgBox(match[1] . "`n" . match[2])
	startPosition := foundPos + match.Len[0]
}
Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

Re: AHK WEBPAGE SEARCH

10 Oct 2017, 17:08

How do i Start with Regex i cant found it anywhere for scripting
User avatar
boiler
Posts: 16771
Joined: 21 Dec 2014, 02:44

Re: AHK WEBPAGE SEARCH

10 Oct 2017, 17:31

Click on the command "RegExMatch" in the code egocarib posted to see the documentation for that command.
Mprobiz3
Posts: 15
Joined: 22 Sep 2017, 13:24

AHK Webpage Search and Copy

08 Oct 2019, 18:33

Good Afternoon,
I am trying to copy information out of excel file, and past in another window.
I have tried using a way to copy webpage then search for information, but i am unable to find a solve.
if anyone can help i would be very thankful
Attachments
Excel Save.ahk
AHK for coping from webpage
(188 Bytes) Downloaded 24 times

[The extension xlsx has been deactivated and can no longer be displayed.]

hd0202
Posts: 183
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: AHK Webpage Search

09 Oct 2019, 01:24

to avoid empty message boxes:

Code: Select all

...
ClipWait,2
If CheckStatus(Clipboard)
	MsgBox % CheckStatus(Clipboard)
Hubert

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 143 guests