Autoit Unable to open the script file [closed] - autoit

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am creating a basic installer in autoit. After compiling the script, I got the error Unable to open the script file when trying to run it.
The Script:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\Resources\unnamed.ico
#AutoIt3Wrapper_Outfile=..\..\..\Desktop\Minecraft Server Launcher Installer.exe
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_File_Add=C:\Users\Kristian\SkyDrive\Autoit\Bungee Minecraft Server Launcher.exe, rt_rcdata, Launcher
#AutoIt3Wrapper_Res_File_Add=C:\Users\Kristian\SkyDrive\Autoit\Bungee Server Launcher\Licence.txt, rt_rcdata, Licence
#AutoIt3Wrapper_Add_Constants=n
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <resources.au3>
$msgbox1 = MsgBox(36, "Minecraft Server Launcher Installer", "Do you want to install the Launcher?")
If $msgbox1 = 6 Then
GUICreate("Minecraft Server Launcher Installer", 373, 325)
GUICtrlCreateLabel("Read the following agreement. Scroll down to view the rest of the agreement.", 10, 10)
GUICtrlCreateEdit(_ResourceGetAsString("Licence"), 10, 51, 350, 191, $WS_VSCROLL + $ES_READONLY + $ES_MULTILINE)
GUICtrlCreateLabel("Do you accept all the terms of the license agreement? Selecting No" & #CRLF & "cancels the installation. You must accept the agreement to install.", 10, 250)
$YES = GUICtrlCreateButton("Yes", 204, 296, 75, 23)
$NO = GUICtrlCreateButton("No", 290, 296, 75, 23)
GUISetState(#SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $YES
Choose_Loc()
Case $NO
Exit
EndSwitch
WEnd
EndIf
Func Choose_Loc()
GUIDelete()
GUICreate("Minecraft Server Launcher Installer", 363, 108)
GUICtrlCreateLabel("Choose Install Location", 10, 5)
$INPUT = GUICtrlCreateInput("C:\Program Files (x86)\KnarCraft\Minecraft Server Launcher", 10, 40, 255, 22)
$BROWSE = GUICtrlCreateButton("Browse...", 275, 40, 80, 23)
$CANCEL = GUICtrlCreateButton("Cancel", 275, 75, 80, 23)
$OK = GUICtrlCreateButton("OK", 185, 75, 80, 23)
GUISetState(#SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $CANCEL
Exit
Case $OK
Install($INPUT)
Case $BROWSE
$FOLDER = FileSelectFolder("Choose Install Location...", "", 7)
If Not $FOLDER = "" Then GUICtrlSetData($INPUT, $FOLDER)
EndSwitch
WEnd
EndFunc ;==>Choose_Loc
Func Install($INPUT)
_ResourceSaveToFile(GUICtrlRead($INPUT) & "\Bungee Minecraft Server Launcher.exe", "Launcher", $RT_RCDATA, 0, 1)
FileCreateShortcut(GUICtrlRead($INPUT) & "\Bungee Minecraft Server Launcher.exe", #DesktopDir & "\Bungee Minecraft Server Launcher.ink")
GUIDelete()
If Not #error Then
MsgBox(36, "Finished", "Installation completed with no errors. Please enjoy your new software.")
Else
MsgBox(16, "Finished", "The installation was interrupted by an error and the software may not work.")
EndIf
Exit
EndFunc ;==>Install
I know that it's this line that creates the error:
#AutoIt3Wrapper_Res_File_Add=C:\Users\Kristian\SkyDrive\Autoit\Bungee Server Launcher\Licence.txt, rt_rcdata, Licence
But I don't know why or how to fix it. I had the same problem with:
#AutoIt3Wrapper_Res_File_Add=C:\Users\Kristian\SkyDrive\Autoit\Bungee Minecraft Server Launcher.exe, rt_rcdata, Launcher
I know that it's the Res_Add line because if I remove that line, the error will disappear.

I stopped using the res file stuff, and switched to FileInstall() :
FileInstall("C:\Users\Kristian\SkyDrive\Autoit\Bungee Minecraft Server Launcher.exe",#TEMPDIR & "\Bungee Minecraft Server Launcher.exe")
FileInstall("C:\Users\Kristian\SkyDrive\Autoit\Bungee Server Launcher\Licence.txt",#TEMPDIR & "\Licence.txt")
Then you just use the file. Also, your paths are different:
Autoit\{BUNGEE MINECRAFT SERVER LAUNCHER.EXE}
Autoit\Bungee Server Launcher\{LICENCE.TXT}
Open up a command prompt and check the full path :
cd C:\Users\Kristian\SkyDrive\Autoit & dir licence.txt /b /s
Another solution would be to make the text file a variable. Open the file in SciTE, replace the regular expression ^(.*)$ by "$1" & #CRLF &_, then copy and paste it into the script.
Here is the code with FileInstall() and a couple fixes. I tested with different paths, and it worked. Functions should be self-contained, so I made them mostly internal. Ideally, you'd have them do a Return SetError() and put the MsgBox() outside the function call.
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\Resources\unnamed.ico
#AutoIt3Wrapper_Outfile=..\..\..\Desktop\Minecraft Server Launcher Installer.exe
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Add_Constants=n
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
; Target path of temp files - you should add code to delete these when done
$LAUNCHPATH = #TempDir & "\BMSLauncher.exe"
$LICENCEPATH = #TempDir & "\BMSLicence.txt"
; Check if the install files exist, and if not, output to console
$EXIST1 = FileExists("C:\Users\Kristian\SkyDrive\Autoit\Bungee Minecraft Server Launcher.exe")
$EXIST2 = FileExists("C:\Users\Kristian\SkyDrive\Autoit\Bungee Server Launcher\Licence.txt")
If Not $EXIST1 Or Not $EXIST2 Then
ConsoleWrite("ERROR! FILE(S) NOT FOUND!" & #CRLF)
If Not $EXIST1 Then ConsoleWrite("LAUNCHER FILE NOT FOUND!" & #CRLF)
If Not $EXIST2 Then ConsoleWrite("LICENCE FILE NOT FOUND!" & #CRLF)
EndIf
; Copy files to destination
FileInstall("C:\Users\Kristian\SkyDrive\Autoit\Bungee Minecraft Server Launcher.exe", $LAUNCHPATH, 1)
FileInstall("C:\Users\Kristian\SkyDrive\Autoit\Bungee Server Launcher\Licence.txt", $LICENCEPATH, 1)
; Read licence file to variable
$LICENCE = FileRead($LICENCEPATH)
$msgbox1 = MsgBox(36, "Minecraft Server Launcher Installer", "Do you want to install the Launcher?")
If $msgbox1 = 6 Then
$EULAGUI = GUICreate("Minecraft Server Launcher Installer", 373, 325)
GUICtrlCreateLabel("Read the following agreement. Scroll down to view the rest of the agreement.", 10, 10)
GUICtrlCreateEdit($LICENCE, 10, 51, 350, 191, $WS_VSCROLL + $ES_READONLY + $ES_MULTILINE)
GUICtrlCreateLabel("Do you accept all the terms of the license agreement? Selecting No" & #CRLF & "cancels the installation. You must accept the agreement to install.", 10, 250)
$YES = GUICtrlCreateButton("Yes", 204, 296, 75, 23)
$NO = GUICtrlCreateButton("No", 290, 296, 75, 23)
GUISetState(#SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE, $NO
Exit
Case $YES
GUIDelete($EULAGUI)
Choose_Loc()
EndSwitch
WEnd
EndIf
Func Choose_Loc()
Local $LOCGUI = GUICreate("Minecraft Server Launcher Installer", 363, 108)
GUICtrlCreateLabel("Choose Install Location", 10, 5)
$INPUT = GUICtrlCreateInput("C:\Program Files (x86)\KnarCraft\Minecraft Server Launcher", 10, 40, 255, 22)
$BROWSE = GUICtrlCreateButton("Browse...", 275, 40, 80, 23)
$CANCEL = GUICtrlCreateButton("Cancel", 275, 75, 80, 23)
$OK = GUICtrlCreateButton("OK", 185, 75, 80, 23)
GUISetState(#SW_SHOW)
While 1
; you could make the switch guigetmsg() without $msg, idk what's best practice here
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE, $CANCEL
Exit
Case $OK
Local $INSTALLPATH = GUICtrlRead($INPUT)
If FileExists($INSTALLPATH) Then
GUIDelete($LOCGUI)
Install($LAUNCHPATH, $INSTALLPATH)
EndIf
Case $BROWSE
$FOLDER = FileSelectFolder("Choose Install Location...", "", 7)
If Not $FOLDER = "" Then GUICtrlSetData($INPUT, $FOLDER)
EndSwitch
WEnd
EndFunc ;==>Choose_Loc
Func Install($FPATH, $IPATH)
Local $ERROR
; you should check for a trailing slash on the $IPATH input
$IPATH &= "\Bungee Minecraft Server Launcher.exe"
FileCopy($FPATH, $IPATH)
$ERROR = #error
FileCreateShortcut($IPATH, #DesktopDir & "\Bungee Minecraft Server Launcher.ink")
If Not #error And Not $ERROR Then
MsgBox(64, "Finished", "Installation completed with no errors. Please enjoy your new software.")
Else
MsgBox(16, "Finished", "The installation was interrupted by an error and the software may not work.")
EndIf
Exit
EndFunc ;==>Install

Make sure the file is in the same dir as the script and Try:
#AutoIt3Wrapper_Res_File_Add=Licence.txt, rt_rcdata, Licence
If you still have problems, try to turn off UPX.

Related

python telegram bot, "socket.error: [Errno 98] Address already in use"

Im developing a telegram bot with this api and I tried to use its webhook example to set up my own bot with webhook method.
I have an Ubuntu server and I have set up nginx on it.
now when trying to run my python bot, I get this error:
Traceback (most recent call last):
File "bot.py", line 106, in <module>
router.run(host=WEBHOOK_LISTEN, port=int(WEBHOOK_PORT), ssl_context= (WEBHOOK_SSL_CERT, WEBHOOK_PRIV_CERT), debug=True)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 841, in run
run_simple(host, port, self, **options)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 720, in run_simple
s.bind((hostname, port))
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
so I checked what is using my port 443 and the process is nginx:
root 30734 1 0 Aug21 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
I can't turn off nginx because my website is on it, and I need the port to set up telegram bot.
EDIT: I will put my code here for more clarification:
WEBHOOK_HOST = 'mywebsite.com'
WEBHOOK_PORT = '8443'
WEBHOOK_LISTEN = '0.0.0.0'
WEBHOOK_SSL_CERT = "/etc/letsencrypt/live/mywebsite.com/cert.pem"
WEBHOOK_PRIV_CERT = "/etc/letsencrypt/live/mywebsite.com/privkey.pem"
WEBHOOK_URL_BASE = "https://%s:%s" % (WEBHOOK_HOST, WEBHOOK_PORT)
WEBHOOK_URL_PATH = "/%s/" % (TOKEN.get_token())
router = flask.Flask(__name__)
#router.route('/', methods=['GET', 'HEAD'])
def index():
return 'OK'
#router.route(WEBHOOK_URL_PATH, methods=['POST'])
def webhook():
if flask.request.headers.get('content-type') == 'application/json':
json_string = flask.request.json
print json_string["message"]["text"] # here I get the text of message
return ''
else:
flask.abort(403)
bot.remove_webhook()
time.sleep(3)
bot.set_webhook(url=WEBHOOK_URL_BASE+WEBHOOK_URL_PATH,certificate=open(WEBHOOK_SSL_CERT, 'r'))
router.run(host=WEBHOOK_LISTEN, port=int(WEBHOOK_PORT), ssl_context=(WEBHOOK_SSL_CERT, WEBHOOK_PRIV_CERT), debug=True)

Paramiko ssh to windows with ConnectionResetError: [WinError 10054]

My code below works fine with Linux servers but the script doesn't work with Windows 2008 Server with OpenSSH installed. I have also tested to ssh with teraterm with the same username, password, ipaddress and port22 it worked fine as well.
I am getting the below error.
C:\Users\>python auto-ssh_v1.py
Socket exception: An existing connection was forcibly closed by the remote host (10054)
Traceback (most recent call last):
File "auto-ssh_v1.py", line 71, in <module>
results = executer.execute()
File "auto-ssh_v1.py", line 53, in execute
stdin, stdout, stderr = ssh.exec_command(self.command)
File "C:\Anaconda3\lib\site-packages\paramiko\client.py", line 405, in exec_command
chan.exec_command(command)
File "C:\Anaconda3\lib\site-packages\paramiko\channel.py", line 60, in _check
return func(self, *args, **kwds)
File "C:\Anaconda3\lib\site-packages\paramiko\channel.py", line 229, in exec_command
self._wait_for_event()
File "C:\Anaconda3\lib\site-packages\paramiko\channel.py", line 1086, in _wait_for_event
raise e
File "C:\Anaconda3\lib\site-packages\paramiko\transport.py", line 1726, in run
ptype, m = self.packetizer.read_message()
File "C:\U\Anaconda3\lib\site-packages\paramiko\packet.py", line 386, in read_message
header = self.read_all(self.__block_size_in, check_rekey=True)
File "C:\Anaconda3\lib\site-packages\paramiko\packet.py", line 249, in read_all
x = self.__socket.recv(n)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
The code is
#Modules
import paramiko
#Variables
USER = 'Administrator'
PSWD = 'Passw0rd'
#Classes and Functions
class InputReader:
def __init__(self, commands_path, hosts_path):
self.commands_path = commands_path
self.hosts_path = hosts_path
def read(self):
self.commands = self.__readlines(self.commands_path)
self.hosts = self.__readlines(self.hosts_path)
def __readlines(self, path):
with open(path) as f:
return [v.strip() for v in f.readlines()] #List comprehension
class CommandExecuter:
def __init__(self, host, command):
self.host = host
self.command = command
def execute(self):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(self.host, username=USER, password=PSWD)
stdin, stdout, stderr = ssh.exec_command(self.command)
errors = stderr.readlines()
if len(errors) != 0:
raise Exception(errors)
lines = [v.strip() for v in stdout.readlines()]
ssh.close()
return lines
#Main Procedure
if __name__ == '__main__':
reader = InputReader("commands.txt", "systems.txt")
reader.read()
for h in reader.hosts:
for c in reader.commands:
executer = CommandExecuter(h, c)
results = executer.execute()
print("{0}({1}):".format(h, c))
for i in results:
print(i)
print('\n')
You can try to run paramiko line by line to ssh to your windows server and see the trace.
Hope that will help,
Trinh

autoit it possible to use "PixelSearch" and "ControlClick" and "PixelGetColor" on bluestacks

possible to use "PixelSearch" and "ControlClick" and "PixelGetColor" on bluestacks in hind windows
i want to run bot in bluestacks and hind windows but PixelSearch can only use on Windows
i want to use PixelSearch to find colour if true to click on other point and working in hind windows
Local $hwnd, $Cor
$hwnd = WinGetHandle("WindowsForms10.Window.8.app.0.33c0d9d")
While 1
$Cor = PixelSearch(460, 271, 511, 323, 0x9D6F47,$hwnd )
If Not #error Then
ControlClick ( "BlueStacks App Player","","", "left" , 1 , 477, 277 )
sleep(200)
EndIf
$Cor = PixelSearch( 546, 212, 598, 267, 0x431567,$hwnd )
If Not #error Then
ControlClick ( "BlueStacks App Player","","", "left" , 1 , 608, 512 )
sleep(200)
EndIf
WEnd
i try this code it works when bluestacks on fornt but i move screen or hind bluestacks is not works
You can't catch a pixel on an hidden windows. What you can make it's make it appear quickly (
the time to make a capture) an then search forthe pixel in memory.
That's a very quick process. Take a look at this :
http://www.autoitscript.com/forum/topic/126430-advanced-pixel-search-library/

RDP session launch applications

I have opened an RDP session using AutoIt. Here is the code:
$host = "" ; <---- IP
$hGUI = GUICreate("Terminal Serveur", 952, 675, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$oRDP = ObjCreate("MsTscAx.MsTscAx.2")
$oRDP_Ctrl = GUICtrlCreateObj($oRDP, 64, 44, 800, 600)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlSetStyle($oRDP_Ctrl , $WS_VISIBLE)
$oRDP.DesktopWidth = 800
$oRDP.DesktopHeight = 600
$oRDP.Fullscreen = False
$oRDP.ColorDepth = 16
$oRDP.AdvancedSettings3.SmartSizing = True
$oRDP.Server = $host
$oRDP.UserName = "" ; <--- Username
$oRDP.Domain = ""
$oRDP.AdvancedSettings2.ClearTextPassword = "" ; <--- Password
$oRDP.ConnectingText = "Connecting to " & $host
$oRDP.DisconnectedText = "Disconnected from " & $host
$oRDP.StartConnected = True
$oRDP.Connect()
$oShel = ObjCreate("shell.application")
$oShel_Ctrl = GUICtrlCreateObj($oShel, 64, 44, 800, 600)
GUICtrlSetStyle($oShel_Ctrl , $WS_VISIBLE)
GUISetState(#SW_SHOW, $hGUI)
Send ("#r") ; !!
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
$oRDP.Disconnect()
Exit
EndSwitch
WEnd
Now, I want to launch an application in the RDP session. I tried " Send(#r) " in order to send the path with a function like SendKeys but this command is execute on my computer and not on the remote computer.
How can I do please?
Send alt + home. This open the windows search in the rdp session, which you can then send it text e.g. send("notepad")
send({enter})
Update:
A much simpler alternative:
Change the Remote Desktop Connection Settings (not in the control
code, but in the usual windows shorcut. But it seems that could be done in the AutoIt code with the keyboardhook setting keyboardhook setting ) .
Look for the Options button, in the window when launching remote desktop.
On the Local Resources Tab select Windows key combinations are applied in full-screen mode only.
Change this line in your code:
$oRDP.Fullscreen = True
Include a pause to ensure the control has been loaded
Sleep(5000)
Send ("#r")
Previous answer:
Let my suggest a workaround not very 'elegant' but should work (tested ok):
In the remote desktop make a shorcut to the Windows Virtual Keyword (On-Screen Keyboard or OSK)
Find the position of the shorcut icon
In your code send a double click at this position to start the on-screen keyboard
Then send clicks to the positions of the desired keys
Something like this:
Sleep(5000)
MouseClick("left",512,191,2) ;start virtual keyword
Sleep(1000)
MouseClick("left",553,807,1) ;click
Sleep(100)
MouseClick("left",633,740,1)
Sleep(1000)
Send("notepad")
Sleep(1000)
Send("{ENTER}")
(Aside note: For any executable with a shortcut on the remote desktop simply send double click, without the need of the virtual keyboard)

Dialog messages not handled when opening dialog from system tray entry

I have an AutoIt script in which I open a settings dialog from a system tray menu entry. When opening the dialog this way, messages via button clicks are not handled.
On the other hand, when opening the dialog directly (as indicated in the code below, which you can easily test by uncommenting this call and commenting out the call for the system tray entry), then the messages are handled successfully.
Here is my script. When calling SettingsDialog directly (without going via the systray menu), the OK and Cancel buttons work, but otherwise not.
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
;; Start program in system tray
SetupSystemTrayEntry()
;; When calling settings dialog directly, messages are handled properly
;;SettingsDialog()
Func SetupSystemTrayEntry()
Opt("TrayMenuMode", 1)
$settingsitem = TrayCreateItem("Settings")
TrayCreateItem("")
$exititem = TrayCreateItem("Exit")
TraySetState()
While 1
Local $traymsg = TrayGetMsg()
Select
Case $traymsg = 0
ContinueLoop
Case $traymsg = $settingsitem
SettingsDialog() ;; Bring up settings dialog
Case $traymsg = $exititem
Exit ;; Exit program
EndSelect
WEnd
EndFunc
Func SettingsDialog()
GUICreate("Settings", 400, 150, #DesktopWidth / 2 - 200, #DesktopHeight / 2 - 75)
$ok_button = GUICtrlCreateButton("OK", 100, 100, 80, 25, $BS_DEFPUSHBUTTON)
$cancel_button = GUICtrlCreateButton("Cancel", 200, 100, 80, 25)
GUISetState()
Do
;; These messages are never handled when the dialog is brought up from
;; the system tray menu entry above, but when calling this function
;; directly, it works
Local $settmsg = GUIGetMsg()
Select
Case $settmsg = $ok_button
ExitLoop
Case $settmsg = $cancel_button
ExitLoop
EndSelect
Until $settmsg = $GUI_EVENT_CLOSE
EndFunc
Seems all fine, except you should do something after you left the Do/Until loop.
Func SettingsDialog()
GUICreate("Settings", 400, 150, #DesktopWidth / 2 - 200, #DesktopHeight / 2 - 75)
$ok_button = GUICtrlCreateButton("OK", 100, 100, 80, 25, $BS_DEFPUSHBUTTON)
$cancel_button = GUICtrlCreateButton("Cancel", 200, 100, 80, 25)
GUISetState()
Do
;; These messages are never handled when the dialog is brought up from
;; the system tray menu entry above, but when calling this function
;; directly, it works
Local $settmsg = GUIGetMsg()
ConsoleWrite(#HOUR & ":" & #MIN & ":" & #SEC & "," & #MSEC & "msg = " & $settmsg & #CRLF)
Select
Case $settmsg = $ok_button
ExitLoop
Case $settmsg = $cancel_button
ExitLoop
EndSelect
Until $settmsg = $GUI_EVENT_CLOSE
Return GUIDelete()
Endfunc
I added 2 lines, the ConsoleWrite after calling GUIGetMessage and the Return after the loop.
When I run this script the Settings Dialog is properly closed by either clicking 'Ok' or 'Cancel'.
As per solution provided on the AutoIt forum, here is a version of the script that hides and shows the dialog on each usage. There is a big caveat (read the forum thread for details) in that on creation of the dialog, it must be explicitly hidden!
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
; Do not declare Global variables in a function <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Global $settings_window_handle, $ok_button, $cancel_button
;; Set up settings dialog
InitSettingsDialog();
;; Start program in system tray
SetupSystemTrayEntry()
Func SetupSystemTrayEntry()
Opt("TrayMenuMode", 1)
$settingsitem = TrayCreateItem("Settings")
TrayCreateItem("")
$exititem = TrayCreateItem("Exit")
TraySetState()
While 1
Switch TrayGetMsg()
Case $settingsitem
ShowSettingsDialog() ;; Bring up settings dialog
Case $exititem
Exit ;; Exit program
EndSwitch
WEnd
EndFunc ;==>SetupSystemTrayEntry
Func InitSettingsDialog()
; Create
$settings_window_handle = GUICreate("Settings", 400, 150, #DesktopWidth / 2 - 200, #DesktopHeight / 2 - 75)
$ok_button = GUICtrlCreateButton("OK", 100, 100, 80, 25, $BS_DEFPUSHBUTTON)
$cancel_button = GUICtrlCreateButton("Cancel", 200, 100, 80, 25)
GUISetState(#SW_HIDE, $settings_window_handle)
EndFunc ;==>SettingsDialog
Func ShowSettingsDialog()
GUISetState(#SW_SHOW, $settings_window_handle)
While 1
Switch GUIGetMsg()
Case $ok_button
MsgBox(0, "test", "test")
ExitLoop
Case $cancel_button
ExitLoop
EndSwitch
WEnd
GUISetState(#SW_HIDE, $settings_window_handle)
EndFunc

Resources