Having trouble with loop

Get help with using AutoHotkey and its commands and hotkeys
hughesb6
Posts: 10
Joined: 12 Apr 2017, 14:55

Having trouble with loop

19 Apr 2017, 14:49

The below code is designed to open a text file on my desktop, then cut the first fax number, and delete the blank space from the first row which will move all of the rows up one.
Then my browser is opened to a specific web site and the number is pasted into the web form field. Next The web form is navigated until the fax is sent. The browser only has to be opened once, because each time a fax is sent, the user is taken back to the location where the fax number is pasted in, automatically. I am trying to get everything before and after "Run, https://control.phone.com/voip/send_fax ... z3jHpbsu2R
WinWait, Send Fax - Phone.com"

to repeat or Loop multiple times, so that I can send a copy of the same fax to different numbers. Any help on where to put the loop would be appreciated.


[code=autohotkey file=Untitled.ahk][#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

clipboard =
Run, c:/Users/Bryan/Desktop/test.txt
Send, {Shift Down}
Send, {End}
Sleep, 3000
Send, {Shift Up}
Sleep, 1000
Send, {Ctrl Down}
Send, x
Send, {Ctrl Up}
Sleep, 3000
Send, {Delete}
Sleep, 3000
Send, {Alt Down}
Send, F
Sleep, 3000
Send, {Alt Up}
Send, X
Sleep, 2000
Send, {Enter}
Sleep, 1000


Run, https://control.phone.com/voip/send_fax ... z3jHpbsu2R
WinWait, Send Fax - Phone.com


Sleep, 3000
Send, {Tab 22}
Sleep, 1000
Send, ^V
Sleep 1000
Send, {Tab}
Sleep, 500
Send, {Space}
Sleep, 1000
Send, {Tab 5}
Sleep, 500
Send, {Enter}
Sleep, 500
Send, Test.txt
Sleep, 500
Send, {Tab}
Sleep, 500
Send, {Enter}
Sleep, 1000
Send, {Tab 2}
Sleep, 500
Send, {Enter}
Sleep, 5000
Send, {Shift Down}
Send, {Tab 5}
Sleep, 1000
Send, {Shift Up}
Send, {Enter}
Sleep, 2000


/code]
User avatar
DyaTactic
Posts: 116
Joined: 04 Apr 2017, 05:52

Re: Having trouble with loop

19 Apr 2017, 15:37

I put the internet site on top. Then run the text file and start the loop. Is this what you asked for?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


My general recommadations:
- Use sleep times from 40 to 400ms. 40 is in my experience already enough. Of course I have no idea about how slow the site or your pc is so set it to your needs.
- Create a safaty in the loop. Something like the code below. This allows stopping the program when things go wrong and prevent things form going any more wrong.
Guest

Re: Having trouble with loop

20 Apr 2017, 13:40

Thank you DyaTactic, that's excellent!
hughesb6
Posts: 10
Joined: 12 Apr 2017, 14:55

Re: Having trouble with loop

20 Apr 2017, 16:08

DyaTactic: I tried to run the script but it isn't doing the send and it isn't looping either. I am trying to send a single newsletter to a bunch of different members' fax numbers. Any ideas??
User avatar
DyaTactic
Posts: 116
Joined: 04 Apr 2017, 05:52

Re: Having trouble with loop

21 Apr 2017, 02:14

If you run the script you can richt click the trayicon and click ‘Open’. This shows the most recent lines executed. Is it correct that the last line, the bottom line, is a WinWait command? If this is the case there is something wrong with the WinTitle. Maybe the ‘ahk_exe notepad.exe’ is a wrong assumption on my side?
hughesb6
Posts: 10
Joined: 12 Apr 2017, 14:55

Re: Having trouble with loop

24 Apr 2017, 14:00

the wintitle seems correct. The script is starting the loop before it finishes the other part of the script.
Here is the most recent update. Please excuse the mess. I need the script execute the last Mouse click and wait a few seconds before doing the loop again.

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.


; First run the website, because this only has to happen once.

Run, https://control.phone.com/voip/send_fax ... V22Au6kmBo
Sleep, 5000
WinWait, Login - Phone.com
MouseClick, left, 698, 544
;Send, {tab 4}
;Sleep, 100
;Send, {Enter}
;WinWait, Send Fax - Phone.com
;Sleep, 3000


clipboard =
Run, c:/Users/Bryan/Desktop/test.txt



Loop 5 ; Set this to the number of faxes you want to send.
{


WinActivate, test.txt - Notepad ;ahk_exe Notepad.exe ; The first run Notepad is probably already active but after the first ;cycle this is ;required.
WinWait, test.txt - Notepad ;ahk_exe Notepad.exe ; Just a safety.
; Take next fax number.

Send, {Shift Down}
Send, {End}
Sleep, 3000
Send, {Shift Up}
Sleep, 1000
Send, {Ctrl Down}
Send, x
Send, {Ctrl Up}
Sleep, 3000
Send, {Delete}
Sleep, 3000
WinMinimize, test.txt
;Send, {Alt Down}
;Send, F
;Sleep, 3000
;Send, {Alt Up}
;Send, X
;Sleep, 2000
;Send, {Enter}
Sleep, 1000

WinActivate, Send Fax - Phone.com ; Activate the already existing web form.
WinWait, Send Fax - Phone.com ; Safety
; Fill in the internet form.
;Sleep, 3000
Send, {Tab 22}
Sleep, 1000
Send, ^V
Sleep 1000
Send, {Tab}
Sleep, 500
Send, {Space}
Sleep, 1000
Send, {Tab 5}
Sleep, 500
Send, {Enter}
Sleep, 500
Send, Test.txt
Sleep, 500
Send, {Tab}
Sleep, 500
Send, {Enter}
Sleep, 2000
Send, {PgDn}
Sleep, 1000
MouseClick, Left, 1155, 681
;Send, {Tab 2}
;Sleep, 2000
;Send, {Enter}
;Sleep, 5000
;WinWait, Send Fax - Phone.com
;Send, {Shift Down}
;Send, {Esc}
Sleep, 100
MouseClick, Left, 1168, 617
Sleep, 1000
;Send, {Shift Up}
;Send, {Enter}
;Sleep, 4000
}
User avatar
DyaTactic
Posts: 116
Joined: 04 Apr 2017, 05:52

Re: Having trouble with loop

25 Apr 2017, 02:37

I cannot resolve your problem. Can you put a comment after the command(s) that is being skipped? Is it the first MouseClick or the last one, in the loop, you were referring to?
Hope I can help you further.


Can you put the code between two lines with [ code ] and [ /code ] (without spaces)? (use the "Code" button).
Example:
[ code ]
; This code appears in a fancy box with nice colors.
[ /code ]

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Return to “Ask For Help”

Who is online

Users browsing this forum: Brunoire and 71 guests