Sign in to follow this  
Followers 0
suckinsyn

SMS Lite - send sms from your desktop (currently only in Poland)

3 posts in this topic

Hey there, folks. I have expanded my previous sms script (link here) to the point that it can be used by anyone without a problem. 

Currently, as said in topic, it's working only with Polish numbers - I do not have enough knowledge about foreign country services that allow to send free text msgs, so if anyone could provide me some info, I would be glad. 

Picture of GUI:

aE3I9nb.png

Dane = sms details, such as Numer odbiorcy, which is target number starting with siec (first three numbers as they are representing the provider) and ending with last six numbers. You can use only numbers there. Nadawca and Tresc are the sender name and the text itself. Sender name is max 12 afaik (cba to check source) and text is max 60 letters long.

By pressing 'Zatwierdz' script checks if number is valid. If it is, button to send sms is enabled, if not, it's disabled. You can chose to send 1 sms or to send x amount of them, theres 2 buttons.

Timer on right side is not yet done. Any ideas to help me out doing it would be cool, although I've though of using variable to declare how much script would have to wait, something like this:

Sleep($some_variable_from_checkbox)

If I can't make it like that, any ideas, as said, would be nice.

Here's the code of the app:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=C:\Users\qwe\Desktop\(32 bit)SMS Lite 1.2.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("SMS lite 1.2", 275, 460, 263, 315)
$Group1 = GUICtrlCreateGroup(" Error log ", 8, 232, 257, 41)
$error_label = GUICtrlCreateLabel("Wybrana siec: X", 25, 250, 119, 17)
$error_label2 = GUICtrlCreateLabel("Poprawny numer: X", 135, 250, 119, 17)
GUICtrlSetFont($error_label, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor($error_label, 0xce0000)
GUICtrlSetFont($error_label2, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor($error_label2, 0xce0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Dane", 8, 8, 257, 217)
$Input1 = GUICtrlCreateInput("", 76, 48, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
GUICtrlSetLimit($Input1, 6)
$OK = GUICtrlCreateButton("Zatwierdz", 32, 200, 83, 17)
$Label8 = GUICtrlCreateLabel("Numer odbiorcy", 32, 30, 90, 17)
$Label10 = GUICtrlCreateLabel("Nadawca:", 40, 70, 53, 17)
$Input2 = GUICtrlCreateInput("", 24, 88, 100, 21)
GUICtrlSetLimit($Input2, 15)
$Label11 = GUICtrlCreateLabel("Tresc:", 48, 110, 34, 17)
$Input3 = GUICtrlCreateInput("Wpisz tutaj tresc SMS. Maksymalnie mozesz uzyc 60 znakow.", 24, 128, 97, 68, $ES_MULTILINE)
GUICtrlSetLimit($Input3, 60)
$Combo1 = GUICtrlCreateCombo("siec", 24, 48, 49, 25)
$Pic1 = GUICtrlCreatePic("C:\Users\qwe\Desktop\SKULL ICON.gif", 136, 32, 115, 167)
$Label9 = GUICtrlCreateLabel("## BY BRODATY ##", 141, 200, 107, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup(" Wysylanie SMS ", 8, 280, 257, 169)
$Label4 = GUICtrlCreateLabel("Dzienny limit SMS'ow wynosi 30.", 54, 392, 157, 17)
$Label5 = GUICtrlCreateLabel("Chcesz wiecej? Daj znac, dogadamy sie.", 32, 408, 197, 17)
$Group3 = GUICtrlCreateGroup("", 24, 377, 225, 7)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label6 = GUICtrlCreateLabel("suckinsyn@gmail.com", 72, 424, 109, 17)
$Checkbox1 = GUICtrlCreateCheckbox("wyslij za 10 minut", 136, 312, 105, 17)
$Checkbox2 = GUICtrlCreateCheckbox("wyslij za 30 minut", 136, 328, 105, 17)
$Checkbox3 = GUICtrlCreateCheckbox("wyznacz sam czas", 136, 344, 113, 17)
$Group5 = GUICtrlCreateGroup(" Timer (dodatek) ", 125, 292, 130, 78)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Wyslij 1 SMS", 24, 304, 91, 25)
$Button2 = GUICtrlCreateButton("1 do 30 SMS'ow", 24, 348, 91, 25)
$Label1 = GUICtrlCreateLabel("lub sam wybierz ilosc", 18, 331, 102, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;---------------------------------------------------------;---------------------------------------------------------;---------------------------------------------------------;-------------------------------------------------

GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetState($Button2, $GUI_DISABLE)

GUICtrlSetState($Checkbox1, $GUI_DISABLE)
GUICtrlSetState($Checkbox2, $GUI_DISABLE)
GUICtrlSetState($Checkbox3, $GUI_DISABLE)

Dane()

Func Dane()

    GUICtrlSetData($Combo1, "500|501|502|503|504|505|506|507|508|509|510|511|512|513|514|515|516|517|518|519|530|531|532|533|534|535|536|537|538|539|600|601|602|603|604|605|606|607|608|609|660|661|662|663|664|665|666|667|668|669|690|691|692|693|694|695|696|697|698|699|721|722|723|724|725|726|727|728|729|730|731|732|733|739|780|781|782|783|784|785|786|787|788|789|790|791|792|793|794|795|796|797|798|799|880|881|882|883|884|885|886|887|888|889", "0")
        Local $sComboRead = ""

While 1
    $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit

            Case $OK
                $sNR_1 = GUICtrlRead($Combo1)
                $sNR_2 = GUICtrlRead($Input1)

if $sNR_1 = "siec" then
    GUICtrlSetData($error_label,"Wybrana siec: X")
    GUICtrlSetFont($error_label, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor($error_label, 0xce0000)
            Else
    GUICtrlSetData($error_label,"Wybrana siec: V")
    GUICtrlSetFont($error_label, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor($error_label, 0x4bcc00)
            EndIf

if stringlen(GUICtrlRead($Input1))<6 Then
    GUICtrlSetData($error_label2,"Poprawny numer: X")
    GUICtrlSetFont($error_label2, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor($error_label2, 0xce0000)
            Else
    GUICtrlSetData($error_label2,"Poprawny numer: V")
    GUICtrlSetFont($error_label2, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor($error_label2, 0x4bcc00)
            EndIf

$tes1 = GUICtrlRead($error_label)
if $tes1 = "Wybrana siec: V" Then
                    $zgoda1 = 1
                Else
                    $zgoda1 = 0
EndIf

$tes2 = GUICtrlRead($error_label2)
if $tes2 = "Poprawny numer: V" Then
                    $zgoda2 = 1
                Else
                    $zgoda2 = 0
EndIf

If $zgoda1 = 1 AND $zgoda2 = 1 Then
GUICtrlSetState($Button1, $GUI_ENABLE)
GUICtrlSetState($Button2, $GUI_ENABLE)
        Else
GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetState($Button2, $GUI_DISABLE)
        EndIf


            Case $Button1 ; wysyłanie jednego SMS

                        $numer_1 = GUICtrlRead($Combo1)
                        $numer_2 = GUICtrlRead($Input1)
                        $nadawca = GUICtrlRead($Input2)
                        $tresc = GUICtrlRead($Input3)

                                Global $oIE = _IECreate("sms.priv.pl", 0, 0)
                                $oSelect = _IEGetObjByName($oIE, "siec")                            ;select first thing to change
                                _IEFormElementOptionSelect($oSelect, $numer_1, 1, "byText")          ;set the data
                                $oObj = _IEGetObjByName($oIE,"number2")                             ;select second thing to change
                                _IEPropertySet($oObj,"innertext", $numer_2)                           ;set the data
                                $oObj = _IEGetObjByName($oIE,"tresc")                               ;select third thing to change
                                _IEPropertySet($oObj,"innertext", $tresc)                           ;set the data
                                $oObj = _IEGetObjByName($oIE,"od")                                  ;select fourth thing to change
                                _IEPropertySet($oObj,"innertext", $nadawca)                         ;set the data
                                $oForm = _IEGetObjByName($oIE, "bramka")                            ;find the send button
                                $oObj = _IEFormSubmit($oForm)                                       ;send sms
                                Sleep(2000)
                                _IEQuit($oIE)


            Case $Button2 ; wysyłanie wielu SMS

                        $numer_1 = GUICtrlRead($Combo1)
                        $numer_2 = GUICtrlRead($Input1)
                        $nadawca = GUICtrlRead($Input2)
                        $tresc = GUICtrlRead($Input3)

                    Global $oIE = _IECreate("sms.priv.pl", 0, 0)
                        $number = inputbox("Ilosc SMS","Wpisz liczbe od 1 do 30. Pamietaj, dziennie z Twojego IP moze byc wyslane tylko 30 sms. Aby zniesc ten limit skontaktuj sie ze mna przez maila.","",50,100)
                            For $I = 1 to  $number ;repeat $number of times

                                $oSelect = _IEGetObjByName($oIE, "siec")                            ;select first thing to change
                                _IEFormElementOptionSelect($oSelect, $numer_1, 1, "byText")          ;set the data
                                $oObj = _IEGetObjByName($oIE,"number2")                             ;select second thing to change
                                _IEPropertySet($oObj,"innertext", $numer_2)                           ;set the data
                                $oObj = _IEGetObjByName($oIE,"tresc")                               ;select third thing to change
                                _IEPropertySet($oObj,"innertext", $tresc)                           ;set the data
                                $oObj = _IEGetObjByName($oIE,"od")                                  ;select fourth thing to change
                                _IEPropertySet($oObj,"innertext", $nadawca)                         ;set the data
                                $oForm = _IEGetObjByName($oIE, "bramka")                            ;find the send button
                                $oObj = _IEFormSubmit($oForm)                                       ;send sms
                                Sleep(2000)
                            Next
                _IEQuit($oIE)
        EndSwitch
    WEnd
EndFunc



;---------------------------------------------------------;---------------------------------------------------------;---------------------------------------------------------;-------------------------------------------------
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

I am almost sure that there is better way to do some things I've done, but I can't describe how happy I am that this actually works.

I also have few ideas how to make the GUI better by using TABS, are they good option? I couldn't find how to make menu with switchable forms. :(

Share this post


Link to post
Share on other sites



Hi countryman.

Nice script.
It works well.

I personally use the REST API available from this supplier:  http://www.smsapi.pl/

But this is commercial REST API solution.

and btw.

please use TIDY before post.

 

Cheers

mLipok


Wondering who uses AutoIT and what it can be used for ?


ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-05-23
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF * GitHub API UDF - modest begining *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

After a while I am playing with the script again.

To-do:

- menu (or tabs) to switch between various functions

- contact list (add, delete, et cetera - stored in txt file)

- nuke all button (kill any left ie instances based on $pid (this may be hard))

- expand the script so that it may be used in other countries too

I would be glad if someone could tell me which sites are used in other countries to send free sms to people :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • zetaimmersion
      By zetaimmersion
      I have 2 items (a field box and a bypass checkbox). every time the box is checked i need the field to become writable. unchecked is read only displaying some text.
      this is as far as i got as I am stuck at making it read/write toggle
      #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) Global $hCombo = GUICtrlCreateInput("", 10, 10, 200, 20, BitOR($ES_AUTOHSCROLL,$ES_READONLY)) GUICtrlSetBkColor($hCombo,0xe7e5e5) Global $cbox = GUICtrlCreateCheckbox ("", 40,50,10,20) GUICtrlSetState($cbox, $GUI_Unchecked) GUISetState() Global $sCurrCombo = "" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cbox If GUICtrlRead($cbox) <> $sCurrCombo Then $sCurrCombo = GUICtrlRead($cbox) GUICtrlSetStyle ($hCombo, $SS_LEFTNOWORDWRAP) GUICtrlSetBkColor($hCombo,0xFFFFFF) MsgBox(0, "Choice", "PLease enter the text") EndIf EndSwitch WEnd  
    • dascondor
      By dascondor
      So I having issues with this GUI/Listview. My main GUI works like it needs to but the ListView GUIs don't. The exit buttons do not work on them and om have a hard time getting them to work. And I'm trying to make the  listview GUI resizeable. But I'm not sure how to fix either of these issues any thoughts.
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <ScreenCapture.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <ListviewConstants.au3> #include 'MultiPing.au3' Opt("GUIOnEventMode", 1) #Region ;Declares ; Reads text file for the base list of IP's Global $aBase_IPlist = _FileReadToArray_mod(".\IP_List.txt") Global $replace2 = "Second" Global $replace3 = "Thrid" ;Global $userdata1 = GUICtrlRead($data1) ;Global $userdata2 = GUICtrlRead($data2) Global $savefolder = "C:\Users\" Global $paths = "\Desktop\PingChecks" Global $1stpaths = "\~~~Store" Global $2ndpaths = "~~~" Global $results = FileExists($savefolder & @UserName & $paths) ;Global $foldercheck = FileExists($savefolder & @UserName & $paths & $1stpaths & $userdata1 & $userdata2 & $2ndpaths) ;Global $savefile = "C:\Users\" & @UserName & "\Desktop\PingChecks\~~~Store" & $userdata1 & $userdata2 & "~~~\" #EndRegion ;Declares #Region ### START Koda GUI section ### Form= $IPMonkey = GUICreate("IP Monkey", 573, 254, -1, -1) GUISetIcon("C:\Users\Dlex\Pictures\monkeyicon.ico", -1) GUISetFont(16, 800, 0, "Arial") GUISetBkColor(0xFFFFFF) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") $data1 = GUICtrlCreateInput("1", 184, 120, 89, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) GUICtrlSetColor(-1, 0x000000) $data2 = GUICtrlCreateInput("23", 280, 120, 89, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) GUICtrlSetColor(-1, 0x000000) $GOButton = GUICtrlCreateButton("GO", 80, 192, 75, 25) GUICtrlSetFont(-1, 10, 800, 0, "Arial") GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlSetTip(-1, "Runs A Live Continuous Ping" & @CRLF & _ "Until Told Other Wise") GUICtrlSetOnEvent(-1, "GOButtonClick") $quickscan = GUICtrlCreateButton("Quick Scan", 224, 192, 107, 25) GUICtrlSetFont(-1, 12, 800, 0, "Arial") GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFF00) GUICtrlSetOnEvent(-1, "quickscanClick") GUICtrlSetTip(-1, "Quickly Scans, Then Saves" & @CRLF & _ "Results In Your 'PingChecks' " & @CRLF & _ "Folder Under Your Store Number Folder") Global $exitbutton = GUICtrlCreateButton("Exit", 416, 192, 75, 25) GUICtrlSetFont(-1, 12, 800, 0, "Arial") GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetTip(-1, "What Do You Think This Button Does?") GUICtrlSetOnEvent(-1, "exitbuttonClick") $titlebar = GUICtrlCreateLabel("IP Monkey", 16, 120, 107, 28) GUICtrlSetColor(-1, 0x000000) $Pic1 = GUICtrlCreatePic("C:\Users\Dlex\Pictures\monkeyicon-0.jpg", 16, 16, 100, 100) GUICtrlSetOnEvent(-1, "Pic1Click") $infobutton = GUICtrlCreateButton("?", 536, 8, 27, 25) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFF8000) GUICtrlSetTip(-1, "Unsure what to do?" & @CRLF & _ "This will get give you " & @CRLF & _ "the help for IP Monkey") GUICtrlSetOnEvent(-1, "infobuttonClick") $Whatstorelabel = GUICtrlCreateLabel("What Store?", 208, 56, 130, 28) GUICtrlSetColor(-1, 0x000000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ;ping gui ; ------ pinger GUI ------------------- Global $StopPing = 0 Local $Win_X = 1200, $Win_Y = 880 ; dimension of window Global $PingGui = GUICreate("IP Monkey", $Win_X, $Win_Y, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") Global $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40) GUICtrlSetFont(-1, 8) $button1 = GUICtrlCreateLabel("Hit Exit To Quit", 10, $Win_Y - 25, $Win_X - 20, 20, -1,$ES_CENTER) GUICtrlSetFont(-1, 10, 800) GUICtrlSetTip(-1, "exit") GUICtrlSetOnEvent(-1, 'SpecialEvents') GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP) GUISetState(@SW_HIDE) ; hidden at startup ; --------- end of pinger gui ------------- #EndRegion ;ping gui ; Generate colored square images $hImage = _GUIImageList_Create(30, 30) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green _GUICtrlListView_SetImageList($listview, $hImage, 0) While 1 Sleep(100) WEnd Func exitbuttonClick() MsgBox(0,'0','0') Exit EndFunc ;==>exitbuttonClick Func GOButtonClick() $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) ; pass the wanted new octet replace_And_Go($userdata1, $userdata2) ; generate a list of new IP and Go EndFunc ;==>GOButtonClick Func infobuttonClick() EndFunc ;==>infobuttonClick Func Pic1Click() EndFunc ;==>Pic1Click Func quickscanClick() $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) replace_And_Go2($userdata1, $userdata2) EndFunc ;==>quickscanClick Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE _button1() Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE Case @GUI_CtrlId = $GUI_EVENT_RESTORE Case @GUI_CtrlId = $GUI_EVENT_MAXIMIZE EndSelect EndFunc ;==>SpecialEvents #Region ; Main_GO/Replace_and_GO #cs ############################## second script ############################################# ; this is to ping continuously a list of IP addresses, get and display ping result "live" ; it simulates the dos "ping -t" command but performed simultaneously on many IP ; presenting the results in a ListView highlighting not responding devices with a red box #ce Func replace_And_Go($s_2, $s_3) ; Create a new array wit a new list of IP according to passed second and third octet Local $aNew_IPlist = $aBase_IPlist For $i = 0 To UBound($aNew_IPlist) - 1 $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3) Next GUISetState(@SW_HIDE, $IPMonkey) GUISetState(@SW_SHOW, $PingGui) ; pass the new list to the pinger Main_GO($aNew_IPlist) GUISetState(@SW_HIDE, $PingGui) GUISetState(@SW_SHOW, $IPMonkey) EndFunc ;==>replace_And_Go Func Main_GO($IPlist) HotKeySet("{esc}", "exitbuttonClick") $StopPing = 0 ; $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's ; ; the above command, it loads in the $IPlist array the values contained in the file IP_List.txt ; values in the file should be separated by a semicolon, something like in the following example: ; ; hostname1;192.168.0.1 ; hostname2;192.168.0.5 ; hostnameX;10.59.7.200 ; etc.... ; ; if values in the file are not separated by a semicolon, but another char is used, for example a comma, ; then just pass it as second parameter of the function: $IPlist = _FileReadToArray_mod(".\IP_List.txt", ",") ; _GUICtrlListView_BeginUpdate($listview) _GUICtrlListView_DeleteAllItems($listview) _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView _GUICtrlListView_EndUpdate($listview) While Not $StopPing ; 1 ; continuously ping addresses of the previously loaded file (IP_List.txt) Sleep(10) ; ; $IPlist is the array loaded with all the IP to be pinged (a 2d array in this case) ; | ; | 1 means the IP are in the second column of the $IPlist array (first colun is nr. 0) ; | | ; | | +--> 0 means return back an array loaded with results from all pinged addresses (responding and not responding) ; | | | if you use 1 then only responding addresses are loaded in the returned array [default] ; | | | if you use 2 then only NOT responding addresses are loaded in the returned array ; | | | In this case we do not need an array to be returned, we only need to perform all pings and pass results ; | | | directly (on the fly) to the "_refresh" callback function that will refresh the listview ; | | | ; | | | 0 means NO lookup name resolution must be performed ; | | | | ; | | | | +--> this is the callback function to be called for each pinged address each time the ping has finished ; | | | | | (see the MultiPing.au3 file for info on all passed params) ; | | | | | 6 parameters are passed to this function, but only 2 are used by the called function in this case: ; | | | | | [4] roundtrip of the responding ping or -1 if IP is down ; | | | | | [5] Index (position) of this IP within the caller's passed array ; | | | | | ; v v v v v _nPing($IPlist, 1, 0, 0, "_refresh") WEnd EndFunc ;==>Main_GO #EndRegion ; Main_GO/Replace_and_GO #Region ; QuickScan/Replace_and_GO2 Func replace_And_Go2($s_2, $s_3) ; Create a new array wit a new list of IP according to passed second and third octet Local $aNew_IPlist = $aBase_IPlist For $i = 0 To UBound($aNew_IPlist) - 1 $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3) Next GUISetState(@SW_HIDE, $IPMonkey) GUISetState(@SW_SHOW, $PingGui) ; pass the new list to the pinger QuickRun($aNew_IPlist) GUISetState(@SW_HIDE, $PingGui) GUISetState(@SW_SHOW, $IPMonkey) EndFunc ;==>replace_And_Go2 Func QuickRun($IPlist) $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) HotKeySet("{esc}", "_button1") Local $Win_X = 1200, $Win_Y = 880 ; dimension of window $PingGui = GUICreate("IP Monkey" & "~~~" & @UserName & "~~~" & "Store" & $userdata1 & $userdata2 & "~~~" & @MON & "." & @MDAY & "." & @YEAR & "~~~" & @HOUR & "." & @MIN, $Win_X, $Win_Y, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui) $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40) GUICtrlSetFont(-1, 8) GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP) ; Generate colored square images $hImage = _GUIImageList_Create(30, 30) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green _GUICtrlListView_SetImageList($listview, $hImage, 0) $button1 = GUICtrlCreateButton("Exit", 10, $Win_Y - 25, $Win_X - 20, 20) GUICtrlSetTip(-1, "End of program") GUICtrlSetOnEvent(-1, "exitbuttonClick") GUISetState(@SW_SHOW) ;~ $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's _GUICtrlListView_BeginUpdate($listview) _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView _GUICtrlListView_EndUpdate($listview) ;While 1 ; perform Pings and update ListView by the "_refresh" callback function $aFinalResult = _nPing($IPlist, 1, 0, 0, "_refresh") ;~ _ArrayDisplay($aFinalResult) ;DirCheck() EndFunc ;==>QuickRun #EndRegion ; QuickScan/Replace_and_GO2 #Region ; Misc Funcs (network) Func _refresh($Params) ; this receive ping results and displays them in the ListView _GUICtrlListView_SetItemImage($listview, $Params[5], 0) ; set colour to Yellow Sleep(50) ; a little wait If $Params[4] = -1 Then ; Device not responding to ping _GUICtrlListView_SetItemImage($listview, $Params[5], 1) ; set colour to RED _GUICtrlListView_EnsureVisible($listview, $Params[5]) ; Position view to this item Else ; Device responds to ping _GUICtrlListView_SetItemImage($listview, $Params[5], 2) ; set colour to GREEN EndIf EndFunc ;==>_refresh Func _button1() ; Button 1 clicked ;~ $StopPing = 1 Exit EndFunc ;==>_button1 #EndRegion ; Misc Funcs (network)  
      MultiPing.au3
      IP_List.txt
    • jannikrendl
      By jannikrendl
      Hey,
      I'd like to create a gui wich records the total runtime of the script. 
      It should tell the hours,minutes and seconds (like this: Running since 00:00:00)
      This is what I have right now:
      Local $iTimer, $hGUI, $cLabel $iTimer = TimerInit() $hGUI = GUICreate("") $cLabel = GUICtrlCreateLabel("",300,380,100,20) GUISetState() AdlibRegister("_UpdateLabel",1000) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit EndSwitch Wend Func _UpdateLabel() $iTimerDiff = TimerDiff($iTimer) GUICtrlSetData($cLabel,"Running Since " & Round($iTimerDiff/1000,0) & " sec.") EndFunc Thanks in advance
    • dascondor
      By dascondor
      I  need to has Opt(GUISetOnEvent,-1) available in my script, but since I'm using koda designer it uses GUIgetmessage is there any work around for this. I'm pretty new to this stuff so any help is great appreciated.
      Any Thoughts?
       
    • dascondor
      By dascondor
      Hello I've been working on an IP Scanner Program with help from other people on the forum. Anyway I've hit a wall with why the GUI won't close on Exit button once pass the main screen, please if anyone could help that would be great.
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\..\..\Downloads\monkeyicon.ico #AutoIt3Wrapper_Outfile=IP Monkey.exe #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <ScreenCapture.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <ListviewConstants.au3> #include 'MultiPing.au3' ; <-- take this from the following link: ; http://www.autoitscript.com/forum/topic/156395-versatile-multi-ping #Region ;ping gui Opt("GUIOnEventMode", 1) ; ------ pinger GUI ------------------- Global $StopPing = 0 Local $Win_X = 1200, $Win_Y = 880 ; dimension of window Global $PingGui = GUICreate("IP Monkey", $Win_X, $Win_Y, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui) Global $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40) GUICtrlSetFont(-1, 8) ;~ $button1 = GUICtrlCreateLabel("Hit Exit To Quit", 10, $Win_Y - 25, $Win_X - 20, 20, -1, $ES_CENTER) ;~ GUICtrlSetFont(-1, 1, 800) ;~ GUICtrlSetTip(-1, "save") ;~ GUICtrlSetOnEvent(-1, 'QuickRun') GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP) GUISetState(@SW_HIDE) ; hidden at startup ; --------- end of pinger gui ------------- #EndRegion ;ping gui ; Generate colored square images $hImage = _GUIImageList_Create(30, 30) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green _GUICtrlListView_SetImageList($listview, $hImage, 0) #Region ### START Koda GUI section ### Form= $IPpong = GUICreate("IP Monkey", 572, 253, -1, -1) GUISetBkColor(0xFFFFFF) Global $data1 = GUICtrlCreateInput("1", 184, 104, 81, 37, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) Global $data2 = GUICtrlCreateInput("23", 280, 104, 73, 37, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) Global $gobutton = GUICtrlCreateButton("GO", 80, 192, 75, 25) GUICtrlSetTip(-1, "Runs A Live Continuous Ping" & @CRLF & _ "Until Told Other Wise") GUICtrlSetBkColor(-1, 0x00FF00) Global $quickbutton = GUICtrlCreateButton("Quick Run", 240, 192, 75, 25) GUICtrlSetTip(-1, "Quickly Scans, Then Saves" & @CRLF & _ "Results In Your 'PingChecks' " & @CRLF & _ "Folder Under Your Store Number Folder") GUICtrlSetBkColor(-1, 0xFFFF00) $title = GUICtrlCreateLabel("IP Monkey", 16, 128, 116, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) $infobutton = GUICtrlCreateButton("?", 536, 16, 27, 25) GUICtrlSetTip(-1, "Unsure what to do?" & @CRLF & _ "This will get give you " & @CRLF & _ "the help for IP Monkey") GUICtrlSetBkColor(-1, 0xFF8000) ;$superbutton = GUICtrlCreateButton("", 0, 0, 19, 17) ;GUICtrlSetBkColor(-1, 0xFFFFFF) ;GUICtrlSetState(-1, $GUI_HIDE) $Label1 = GUICtrlCreateLabel("What Store?", 200, 40, 145, 33) GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) Global $exitbutton = GUICtrlCreateButton("Exit", 400, 192, 75, 25) GUICtrlSetTip(-1, "What Do You Think This Button Does?") GUICtrlSetBkColor(-1, 0xFF0000) $Icon = GUICtrlCreatePic("C:\Users\" & @UserName & "\Desktop\monkeyicon-0.jpg", 16, 16, 100, 100) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ;Declares ; Reads text file for the base list of IP's Global $aBase_IPlist = _FileReadToArray_mod(".\IP_List.txt") Global $replace2 = "Second" Global $replace3 = "Thrid" Global $userdata1 = GUICtrlRead($data1) Global $userdata2 = GUICtrlRead($data2) Global $savefolder = "C:\Users\" Global $paths = "\Desktop\PingChecks" Global $1stpaths = "\~~~Store" Global $2ndpaths = "~~~" Global $results = FileExists($savefolder & @UserName & $paths) Global $foldercheck = FileExists($savefolder & @UserName & $paths & $1stpaths & $userdata1 & $userdata2 & $2ndpaths) Global $savefile = "C:\Users\" & @UserName & "\Desktop\PingChecks\~~~Store" & $userdata1 & $userdata2 & "~~~\" #EndRegion ;Declares #Region ; Foldercreation/ScreenCap/HelpFile Func DirCheck() Global $savefolder = "C:\Users\" Global $paths = "\Desktop\PingChecks" $results = FileExists($savefolder & @UserName & $paths) Global $helptext = "C:\Users\" & @UserName & "\Desktop\PingChecks\README.txt" If $results = 0 Then DirCreate($savefolder & @UserName & $paths) FileWrite($helptext, " .. IMMMI .. " & @CRLF & _ " .~MMMMMMMMMMMMM~. ") Createdforstore() ElseIf $results = 1 Then Createdforstore() EndIf EndFunc ;==>DirCheck Func Createdforstore() Local $pathslocal = "\Desktop\PingChecks\" If $foldercheck = 0 Then DirCreate($savefolder & @UserName & $pathslocal & $1stpaths & $userdata1 & $userdata2 & $2ndpaths) Screencap() ElseIf $foldercheck = 1 Then Screencap() EndIf EndFunc ;==>Createdforstore Func Screencap() $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) Local $savesfile = "C:\Users\" & @UserName & "\Desktop\PingChecks\~~~Store" & $userdata1 & $userdata2 & "~~~\" Global $point = "," Global $time = "." Global $id = "Store" Global $tid = "~" ;~ Global $pathslocal = "\Desktop\PingChecks\" _ScreenCapture_CaptureWnd($savesfile & @UserName & $tid & $id & $userdata1 & $userdata2 & $tid & @MON & $time & @MDAY & $time & @YEAR & $tid & @HOUR & $time & @MIN & $tid & ".jpg", $PingGui) MsgBox(0, "Completed", " Your Ping Scan Is In Your PingChecks Folder, " & @CRLF & _ "On Your Desktop.") Exit EndFunc ;==>Screencap ;helpfile Func Helpfile() $readmecheck = FileExists("README.txt") If $readmecheck = 1 Then ShellExecute("README.txt") ElseIf $readmecheck = 0 Then Run("Notepad.exe") WinWait("Untitled - Notepad") ControlSetText("Untitled - Notepad", '', 'Edit1', " .. IMMMI .. " & @CRLF & _ " .~MMMMMMMMMMMMM~. ") EndIf EndFunc ;==>Helpfile #EndRegion ; Foldercreation/ScreenCap/HelpFile #Region ; Main_GO/Replace_and_GO #cs ############################## second script ############################################# ; this is to ping continuously a list of IP addresses, get and display ping result "live" ; it simulates the dos "ping -t" command but performed simultaneously on many IP ; presenting the results in a ListView highlighting not responding devices with a red box #ce Func replace_And_Go($s_2, $s_3) ; Create a new array wit a new list of IP according to passed second and third octet Local $aNew_IPlist = $aBase_IPlist For $i = 0 To UBound($aNew_IPlist) - 1 $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3) Next GUISetState(@SW_HIDE, $IPpong) GUISetState(@SW_SHOW, $PingGui) ; pass the new list to the pinger Main_GO($aNew_IPlist) GUISetState(@SW_HIDE, $PingGui) GUISetState(@SW_SHOW, $IPpong) EndFunc ;==>replace_And_Go Func Main_GO($IPlist) HotKeySet("{esc}", "_button1") ; $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's ; ; the above command, it loads in the $IPlist array the values contained in the file IP_List.txt ; values in the file should be separated by a semicolon, something like in the following example: ; ; hostname1;192.168.0.1 ; hostname2;192.168.0.5 ; hostnameX;10.59.7.200 ; etc.... ; ; if values in the file are not separated by a semicolon, but another char is used, for example a comma, ; then just pass it as second parameter of the function: $IPlist = _FileReadToArray_mod(".\IP_List.txt", ",") ; _GUICtrlListView_BeginUpdate($listview) _GUICtrlListView_DeleteAllItems($listview) _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView _GUICtrlListView_EndUpdate($listview) While Not $StopPing ; 1 ; continuously ping addresses of the previously loaded file (IP_List.txt) Sleep(10) ; ; $IPlist is the array loaded with all the IP to be pinged (a 2d array in this case) ; | ; | 1 means the IP are in the second column of the $IPlist array (first colun is nr. 0) ; | | ; | | +--> 0 means return back an array loaded with results from all pinged addresses (responding and not responding) ; | | | if you use 1 then only responding addresses are loaded in the returned array [default] ; | | | if you use 2 then only NOT responding addresses are loaded in the returned array ; | | | In this case we do not need an array to be returned, we only need to perform all pings and pass results ; | | | directly (on the fly) to the "_refresh" callback function that will refresh the listview ; | | | ; | | | 0 means NO lookup name resolution must be performed ; | | | | ; | | | | +--> this is the callback function to be called for each pinged address each time the ping has finished ; | | | | | (see the MultiPing.au3 file for info on all passed params) ; | | | | | 6 parameters are passed to this function, but only 2 are used by the called function in this case: ; | | | | | [4] roundtrip of the responding ping or -1 if IP is down ; | | | | | [5] Index (position) of this IP within the caller's passed array ; | | | | | ; v v v v v _nPing($IPlist, 1, 0, 0, "_refresh") WEnd HotKeySet("{esc}", _button1) $StopPing = 0 EndFunc ;==>Main_GO #EndRegion ; Main_GO/Replace_and_GO #Region ; QuickScan/Replace_and_GO2 Func replace_And_Go2($s_2, $s_3) ; Create a new array wit a new list of IP according to passed second and third octet Local $aNew_IPlist = $aBase_IPlist For $i = 0 To UBound($aNew_IPlist) - 1 $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3) Next GUISetState(@SW_HIDE, $IPpong) GUISetState(@SW_SHOW, $PingGui) ; pass the new list to the pinger QuickRun($aNew_IPlist) GUISetState(@SW_HIDE, $PingGui) GUISetState(@SW_SHOW, $IPpong) EndFunc ;==>replace_And_Go2 Func QuickRun($IPlist) $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) HotKeySet("{esc}", "_button1") Local $Win_X = 1200, $Win_Y = 880 ; dimension of window $PingGui = GUICreate("IP Monkey" & "~~~" & @UserName & "~~~" & "Store" & $userdata1 & $userdata2 & "~~~" & @MON & "." & @MDAY & "." & @YEAR & "~~~" & @HOUR & "." & @MIN, $Win_X, $Win_Y, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui) $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40) GUICtrlSetFont(-1, 8) GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP) ; Generate colored square images $hImage = _GUIImageList_Create(30, 30) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green _GUICtrlListView_SetImageList($listview, $hImage, 0) $button1 = GUICtrlCreateButton("Exit", 10, $Win_Y - 25, $Win_X - 20, 20) GUICtrlSetTip(-1, "End of program") GUICtrlSetOnEvent(-1, "_button1") GUISetState(@SW_SHOW) ;~ $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's _GUICtrlListView_BeginUpdate($listview) _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView _GUICtrlListView_EndUpdate($listview) ;While 1 ; perform Pings and update ListView by the "_refresh" callback function $aFinalResult = _nPing($IPlist, 1, 0, 0, "_refresh") ;~ _ArrayDisplay($aFinalResult) DirCheck() EndFunc ;==>QuickRun #EndRegion ; QuickScan/Replace_and_GO2 #Region ; Misc Funcs (network) Func _refresh($Params) ; this receive ping results and displays them in the ListView _GUICtrlListView_SetItemImage($listview, $Params[5], 0) ; set colour to Yellow Sleep(50) ; a little wait If $Params[4] = -1 Then ; Device not responding to ping _GUICtrlListView_SetItemImage($listview, $Params[5], 1) ; set colour to RED _GUICtrlListView_EnsureVisible($listview, $Params[5]) ; Position view to this item Else ; Device responds to ping _GUICtrlListView_SetItemImage($listview, $Params[5], 2) ; set colour to GREEN EndIf EndFunc ;==>_refresh Func _button1() ; Button 1 clicked $StopPing = 1 Exit EndFunc ;==>_button1 #EndRegion ; Misc Funcs (network) While (1) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $gobutton $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) ; pass the wanted new octet replace_And_Go($userdata1, $userdata2) ; generate a list of new IP and Go Case $infobutton Helpfile() ;Case $superbutton ;Run("notepad.exe") Case $quickbutton $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) replace_And_Go2($userdata1, $userdata2) Case $exitbutton Exit EndSwitch WEnd