Friends,
I am really desperate and I hope you can help me. I coded my first GUI script to send free SMS.
Description: When $Button1 is pressed the main function starts. It takes about 2 minutes to complete because it loads few web pages and insert some data as logon credentials, recipient number and text message itself.
1. When the button is pressed the GUI is "frozen" until main function is completed. Is it possible to return the control to GUI and press the same button or other buttons to e.g. change global variable?
2. Is it possible to stop running function? I found many examples but all are related to very fast calculations. There is no calculation in my function it simply loads the web pages and retrieve/insert some data so I don't know if there is a place for any FOR or While loop.
I tried to achieve this two goals with both "On Event" and "Case Switch" solution so my code is really dirty now. I am going to provide working concept.
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <Array.au3>
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Meteor SMS Agent v0.2", 304, 329, 246, 160)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$file = GUICtrlCreateMenu("&File")
$menu_exit = GUICtrlCreateMenuItem("Exit", $file)
GUICtrlSetOnEvent(-1, "_Quit")
$help = GUICtrlCreateMenu("Help")
$menu_about = GUICtrlCreateMenuItem("About", $help)
GUICtrlSetOnEvent(-1, "about")
$hListBox = GUICtrlCreateList("", 192, 96, 89, 118, $LBS_STANDARD)
$Button1 = GUICtrlCreateButton("Send SMS", 48, 224, 83, 33, $WS_GROUP)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
;GUICtrlSetOnEvent(-1, "_StartStopButton")
GUICtrlSetOnEvent(-1, "smssend")
$Input1 = GUICtrlCreateInput("085", 16, 32, 89, 24, $ES_NUMBER)
GUICtrlSetLimit(-1, 10)
$Edit1 = GUICtrlCreateEdit("", 16, 96, 145, 121, BitOR($LBS_STANDARD, $WS_VSCROLL) )
GUICtrlSetLimit(-1, 160)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("Your phone number", 16, 8, 121, 20)
$Label2 = GUICtrlCreateLabel("Message (160 chars)", 16, 72, 129, 20)
$Label3 = GUICtrlCreateLabel("Contact List", 192, 72, 72, 20)
$Input2 = GUICtrlCreateInput("", 192, 32, 57, 24, BitOR($ES_PASSWORD, $ES_NUMBER))
GUICtrlSetLimit(-1, 7)
$Label4 = GUICtrlCreateLabel("PIN (MyMeteor)", 192, 8, 97, 20)
$Progress1 = GUICtrlCreateProgress(50, 264, 77, 10)
$Input3 = GUICtrlCreateInput("300 / 300", 216, 232, 57, 24,$ES_READONLY)
$Label5 = GUICtrlCreateLabel("Free SMS", 216, 256, 64, 20)
;$help = GUICtrlCreateMenu("Help")
;$menu_about = GUICtrlCreateMenuItem("About", $help)
$StatusBar = _GUICtrlStatusBar_Create($Form1, -1, "Ready")
GUISetState(@SW_SHOW)
While 1
sleep(100)
WEnd
Func smssend()
;THIS IS THE MAIN FUNCTION - it takes about 2 minutes to complete, It loads different web pages
EndFunc
Func _quit()
exit
EndFunc
Func about()
MsgBox(8192 + 262144 + 64, "Information about...", "I am desperate :)")
EndFunc