Send message to discord by gui button
Posted: 21 Jan 2022, 14:25
I'm trying to make a gui panel to simplify the usage of bot-commands in my server. However, no message is sent. Very noob on AHK so I'm not really sure what to look for. The script I got is copy-pasted together from examples. The result I'm looking for is that the message blaaaaaah is sent to discord when I press the button.
Grateful for any pointers
Grateful for any pointers
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
gui, add, button, x5 y5 h20 w70 gsub1, Subroutine 1
gui, add, button, x5 y30 h20 w70 gexit, Exit Script
gui, show, w80
WinGetActiveTitle, Window_name
Win_Discord := "DISCORD"
Found_Discord := InStr( Window_name, Win_Discord, false ) ;AHK builtin function
return
sub1:
{
If !( Found_Discord >= 1 )
{
MsgBox, 1,!!WARNING!! ,The Client Window "%Win_Discord%" NOT Found. Found "%Window_name%"%lf_char%%lf_char%Press ENTER Key to Ignore Warning and Continue., 5 ; -seconds before timeout.
IfMsgBox, Cancel
exit ; User pressed the "Cancel" button.
IfMsgBox, Timeout
{
SplashTextOn,,, Script EXITING Now
Sleep 2000
SplashTextOff
exit ; i.e. Assume "Cancel" if it timed out.
}
}
WinActivate, Window_name
Send blaaaaaah
}
return
guiclose:
exit:
{
exitapp
}
return