I am very new to AHK programming, so please bear with me.
In the following code, when text can be copied to Clipboard, MsgBox displays the text. However, it does not work ("Hi" not displayed) if there is no text copied (so Clipboard is null). Any suggestion? Thanks.
F10::
Clipboard := ""
Send ^a
Send ^c
ClipWait
strTM := Clipboard
if (Clipboard = "") {
MsgBox Hi
}
else {
MsgBox %strTM%
}
return
Problem using If statement
Re: Problem using If statement
Hallo,
try:
try:
Code: Select all
F10::
Clipboard := ""
Send ^a
Send ^c
ClipWait,1
strTM = %Clipboard%
if (strTM = "") {
MsgBox Hi
}
else {
MsgBox %strTM%
}
return
Re: Problem using If statement
You're going to kick yourself, but it's hanging at the ClipWait command. When nothing is copied to the clipboard, ClipWait does its job and waits for something to be in the clipboard before proceeding. Remove the ClipWait command and the hotkey works as you designed it.
Re: Problem using If statement
Problem solved. Thanks folks.
Who is online
Users browsing this forum: balawi28, Chunjee, Google [Bot], moltenchees and 267 guests