According to https://autohotkey.com/docs/commands/Loop.htm
I should be able to run a loop where Count is a variable.
Likewise, according to https://autohotkey.com/docs/misc/Clipboard.htm and https://autohotkey.com/board/topic/8630 ... -variable/
I should be able to set a variable using contents of the clipboard in order to use that variable (those clipboard contents) elsewhere in a script.
However, I cannot get it to work.
I am new to AHK. My script is to manipulate an OpenOffice Calc project.
I have run my script countless times trying to debug the problem. I am at a loss.
This script excerpt works
Code: Select all
; /******************************/ ; get row number and set RepeatCount
send, {Home}
sleep, 20
send, {end}
sleep, 20
send, {=}{r}{o}{w}{(}{)}{enter}
sleep, 20
send, {up}
Clipboard = ; Must start off blank for detection to work.
RepeatCount = ;
send, {Lcontrol down}{x}{lcontrol up} ; Cut text into Clipboard
ClipWait, 2
sleep, 5500
clipboard = %clipboard% ; Convert any formatted text to plain text.
sleep, 500
; /******************************/ test it with notepad (to make sure that the data is being copied to the clipboard)
send, #r
sleep, 300
send, notepad{enter}
WinActivate, Untitled - Notepad ahk_class SALFRAME
; WinWaitActive, Untitled - Notepad ahk_class SALFRAME
sleep, 500
send, ^v
sleep, 500
send, !fx
sleep, 100
send, {enter}
sleep, 500
send, output{enter}
sleep, 500
; /******************************/ a quick break to check the notepad output
MsgBox, 4,, First section complete,<br>Would you like to continue? (press Yes or No)<br>This Message will timeout in 120 seconds, 120
IfMsgBox Timeout
MsgBox You didn't press YES or NO within the 120-second period.
else IfMsgBox No
ExitApp
; /******************************/
WinActivate, bak-AltecLansing.ods - OpenOffice Calc ahk_class SALFRAME
; WinWaitActive, bak-AltecLansing.ods - OpenOffice Calc ahk_class SALFRAME
sleep, 1500
; RepeatCount := Clipboard ; Fetch the text into variable
; Loop, Clipboard {
; Loop, %RepeatCount% {
Loop, 247 {
send, {home}
Sleep, 50
send, {LShift Down}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{LShift Up}
Sleep, 50
send, {LAlt Down}{o}{e}{y}{LAlt Up}
Sleep, 50
Send, {Up}
}
; /******************************/ did it loop?
MsgBox, 4,, Second section complete,<br>Would you like to continue? (press Yes or No)<br>This Message will timeout in 10 seconds, 10
IfMsgBox Timeout
MsgBox You didn't press YES or NO within the 10-second period.
else IfMsgBox No
ExitApp
; /******************************/
Code: Select all
; /******************************/ ; get row number and set RepeatCount
send, {Home}
sleep, 20
send, {end}
sleep, 20
send, {=}{r}{o}{w}{(}{)}{enter}
sleep, 20
send, {up}
Clipboard = ; Must start off blank for detection to work.
RepeatCount = ;
send, {Lcontrol down}{x}{lcontrol up} ; Cut text into Clipboard
ClipWait, 2
sleep, 5500
clipboard = %clipboard% ; Convert any formatted text to plain text.
sleep, 500
; /******************************/ test it with notepad (to make sure that the data is being copied to the clipboard)
send, #r
sleep, 300
send, notepad{enter}
WinActivate, Untitled - Notepad ahk_class SALFRAME
; WinWaitActive, Untitled - Notepad ahk_class SALFRAME
sleep, 500
send, ^v
sleep, 500
send, !fx
sleep, 100
send, {enter}
sleep, 500
send, output{enter}
sleep, 500
; /******************************/ a quick break to check the notepad output
MsgBox, 4,, First section complete,<br>Would you like to continue? (press Yes or No)<br>This Message will timeout in 120 seconds, 120
IfMsgBox Timeout
MsgBox You didn't press YES or NO within the 120-second period.
else IfMsgBox No
ExitApp
; /******************************/
WinActivate, bak-AltecLansing.ods - OpenOffice Calc ahk_class SALFRAME
; WinWaitActive, bak-AltecLansing.ods - OpenOffice Calc ahk_class SALFRAME
sleep, 1500
RepeatCount := Clipboard ; Fetch the text into variable
; Loop, Clipboard {
Loop, %RepeatCount% {
; Loop, 247 {
send, {home}
Sleep, 50
send, {LShift Down}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{LShift Up}
Sleep, 50
send, {LAlt Down}{o}{e}{y}{LAlt Up}
Sleep, 50
Send, {Up}
}
; /******************************/ did it loop?
MsgBox, 4,, Second section complete,<br>Would you like to continue? (press Yes or No)<br>This Message will timeout in 10 seconds, 10
IfMsgBox Timeout
MsgBox You didn't press YES or NO within the 10-second period.
else IfMsgBox No
ExitApp
; /******************************/
Code: Select all
; /******************************/ ; get row number and set RepeatCount
send, {Home}
sleep, 20
send, {end}
sleep, 20
send, {=}{r}{o}{w}{(}{)}{enter}
sleep, 20
send, {up}
Clipboard = ; Must start off blank for detection to work.
RepeatCount = ;
send, {Lcontrol down}{x}{lcontrol up} ; Cut text into Clipboard
ClipWait, 2
sleep, 5500
clipboard = %clipboard% ; Convert any formatted text to plain text.
sleep, 500
; /******************************/ test it with notepad (to make sure that the data is being copied to the clipboard)
send, #r
sleep, 300
send, notepad{enter}
WinActivate, Untitled - Notepad ahk_class SALFRAME
; WinWaitActive, Untitled - Notepad ahk_class SALFRAME
sleep, 500
send, ^v
sleep, 500
send, !fx
sleep, 100
send, {enter}
sleep, 500
send, output{enter}
sleep, 500
; /******************************/ a quick break to check the notepad output
MsgBox, 4,, First section complete,<br>Would you like to continue? (press Yes or No)<br>This Message will timeout in 120 seconds, 120
IfMsgBox Timeout
MsgBox You didn't press YES or NO within the 120-second period.
else IfMsgBox No
ExitApp
; /******************************/ if we're continuing, then yes, the notepad output is correct
WinActivate, bak-AltecLansing.ods - OpenOffice Calc ahk_class SALFRAME
; WinWaitActive, bak-AltecLansing.ods - OpenOffice Calc ahk_class SALFRAME
sleep, 1500
; RepeatCount := Clipboard ; Fetch the text into variable
Loop, Clipboard {
; Loop, %RepeatCount% {
; Loop, 247 {
send, {home}
Sleep, 50
send, {LShift Down}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{LShift Up}
Sleep, 50
send, {LAlt Down}{o}{e}{y}{LAlt Up}
Sleep, 50
Send, {Up}
}
; /******************************/ did it loop?
MsgBox, 4,, Second section complete,<br>Would you like to continue? (press Yes or No)<br>This Message will timeout in 10 seconds, 10
IfMsgBox Timeout
MsgBox You didn't press YES or NO within the 10-second period.
else IfMsgBox No
ExitApp
; /******************************/
Any help at all would be greatly appreciated, im running out of hair to pull out.