Jump to content
FMS

error in returning valeus

Recommended Posts

FMS

Hello,

I'm rather new at Autoit (picked it up again afther a couple of years) but i dont know what I'm doing wrong here.
I hope somebody can help me making this script "better readeble" and explain what I'm doing wrong here.
The thing that i want to do here is making a tool that helps me whit doing mine work.
Also want to do the "ping" command in the background whit only a msgbox if ok or not.
In the code I'm writing now I'm using Send commands but know that there is a better way for this.

At this point there is a error also whish i do not udnerstand where it is comming from.
the error i get is:

MsgBox($MB_SYSTEMMODAL, "Error", " Error no IP or name is filled in")
MsgBox(^ ERROR

Could somebody help me whit looking at this code?
 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Form1", 385, 112, 192, 124)
$iIP = GUICtrlCreateInput("", 80, 16, 209, 21)
$btn_ping = GUICtrlCreateButton("Ping", 24, 56, 89, 25)
$btn_vnc = GUICtrlCreateButton("VNC", 136, 56, 89, 25)
$btn_evr = GUICtrlCreateButton("Eventvieuwer", 248, 56, 89, 25)
GUISetState(@SW_SHOW)

Func check_input()
   If GUICtrlRead($iIP) = "" Then
        Return False
    Else
        Return True
    Endif
 EndFunc

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $btn_ping
            $check = check_input()
            If ($check = False) Then
               Run ("cmd.exe")
               WinWaitActive("C:\WINDOWS\system32\cmd.exe")
               Send ("ping " & GUICtrlRead($iIP) & "{ENTER}")
               WinClose ("C:\WINDOWS\system32\cmd.exe")
               ;if ping OK then msgbox OK else NOK
            Else
               MsgBox($MB_SYSTEMMODAL, "Error", " Error no IP or name is filled in")
            EndIf
         Case $btn_vnc
            $check = check_input()
            If ($check = False) Then
               Run ("cmd.exe")
               WinWaitActive("C:\WINDOWS\system32\cmd.exe")
               Send ("eventvwr.exe " & GUICtrlRead($iIP) & "{ENTER}")
               WinClose ("C:\WINDOWS\system32\cmd.exe")
            Else
               MsgBox($MB_SYSTEMMODAL, "Error", " Error no IP or name is filled in")
            EndIf
         Case $btn_evr
            $check = check_input()
            If ($check = False) Then
               Run ("cmd.exe")
               WinWaitActive("C:\WINDOWS\system32\cmd.exe")
               Send ("vncviewer " & GUICtrlRead($iIP) & "{ENTER}")
               WinClose ("C:\WINDOWS\system32\cmd.exe")
            Else
               MsgBox($MB_SYSTEMMODAL, "Error", " Error no IP or name is filled in")
            EndIf
    EndSwitch
 WEnd

 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
water

You need to add

#include <MsgBoxConstants.au3>

at the top of your script.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
FMS

thanks - added :)
Do you also know how to ping in the background and iff result is good a massagebox apears?

thanks in advanced


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
water

AutoIt offers a Ping function. So there is no need to run CMD.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
FMS

thanks this helps a lot...
The thing is :
the ping command is very usefull for the 1st button.
for the other buttons (VNC and eventviewer) I want to run like a batch script and I only know to do it whit "in screen"  commands like "Send" ,
Could u help me whit this? :

VNC button:

set /p ipadres=Wwhat is the IP of machine?
:LOOP
ping %ipadres% -w 1 > nul
IF ERRORLEVEL 1 GOTO :DEAD
IF ERRORLEVEL 0 GOTO :ALIVE
:DEAD
Echo Time-Out on %ipadres%...
GOTO :LOOP
:ALIVE
ECHO The machine is online and VNC wil be started
cd\
cd "C:\Program Files\Realvnc\vnc4"
vncviewer %ipadres%

cls

 

EVENTVIEWER button:

set /p ipadres=What is the IP of the machine?
net use z: /DELETE /Y
net use z: \\%ipadres%\C$ /user:username password
CLS
ECHO Event Viewer will be started...
c:\WINDOWS\system32\eventvwr.exe %ipadres%
CLS
ECHO Event Viewer wordt gestart...
ping -n 20 127.0.0.1 > nul
net use z: /DELETE /Y

 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
water

Should be quite easy:

$sIP = InputBox("Prompt", "What is the IP of the machine?")
If Ping($sIP) > 0 Then
    Run("C:\Program Files\Realvnc\vnc4\vncviewer.exe " & $sIP)
Else
    MsgBox($MB_ICONERROR, "Error", $sIP & " is dead. @error = " & @error)
EndIf

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
FMS

who knows,....
this will make mine code a lot simpler and shorter!
Many thanks :)


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
water

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

  • Similar Content

    • xtcislove
      By xtcislove
      Hello,
      as a start in Autoit i tried something i was missing since im using Autoit. 

      I build a custom MessageBox which has a large amount of custom options and which scales its size on the parameters you set. 

      Aviable Settings:
      -Title
      -Unlimited Buttons
      -Text Color (Buttons, Text)

      -Background Color (Msgbox, Buttons, Label) 

      -Button Timeout
      -Autoclose Timeout
      -Icon (Default, No Icon, Custom)

      -Label/ Button Style. 
      -Transparency

      I tried to keep this as close as i could to a Msgbox i was used too on my batch times.

      After i was ready i realised, @Melba23 probably build a way better msgbox which would have suit my needs enterly, anyway thanks to @Melba23 because i use his Stringsize UDF. 

       
       
      local $Message = _sMsgBox("Test", 6, "Continue?") if @extended <> -1 Then MsgBox(0, @extended, $Message&" Button pressed")  
      ScalingMessageBox.au3
    • SkysLastChance
      By SkysLastChance
      I am having a hard time understanding why this is not working. I was hoping some one could help explain it to me. 
      $tags = $oIE.document.GetElementsByTagName("input") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "fTs-p3298-l0 wplEditControl" Then $target = $tag ExitLoop EndIF Next MsgBox(0,"",$target) If $target = "fTs-p3298-l0 wplEditControl" THEN MsgBox(0,"","itworked") I have tried 
       MsgBox(0,"",$target.Attribute)  MsgBox(0,"",$target.Value)  MsgBox(0,"",$target.InnerText) I would expect to see this in the msgbox
      fTs-p3298-l0 wplEditControl  
    • b9k
      By b9k
      Hi, I am stuck on a GUI problem and would like your help to solve it.
      I am trying to automate the SoundWire Server app to match my current system volume level while it is minimized to the notification area (so no clicking or stealing focus),
      I can already get the handle and alter the tracker position by sending a WM_SETPOS message, but somehow the actual volume is not changed: I think I need to do something else to trigger the event handler for the value change and propagate it correctly.
      This is the control summary from Au3 info:
      >>>> Window <<<< Title: SoundWire Server Class: #32770 Position: 441, 218 Size: 566, 429 Style: 0x94CA00C4 ExStyle: 0x00050101 Handle: 0x0000000000510E12 >>>> Control <<<< Class: msctls_trackbar32 Instance: 4 ClassnameNN: msctls_trackbar324 Name: Advanced (Class): [CLASS:msctls_trackbar32; INSTANCE:4] ID: 6002 Text: Position: 51, 222 Size: 47, 126 ControlClick Coords: 1, 101 Style: 0x5001000A ExStyle: 0x00000000 Handle: 0x00000000001234C8 >>>> Mouse <<<< Position: 496, 567 Cursor ID: 2 Color: 0xF0F0F0 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< Default multimedia device Tray on Start Static Server Address: 192.168.1.8 Status: Connected to B9K~OP3 Audio Output Audio Input Level Record to File Input Select: 44.1 kHz Minimize to Master Volume Mute >>>> Hidden Text <<<< Slider2 Mute OK Cancel Label Balance Slider1 Volume Front L/R Fr C/LFE Side L/R Back L/R
      I am attaching the program in question so you don't have to install it (i don't know if it is portable enough, tough): 

      SoundWire Server_files.zip

      Thanks in advance and I hope I didn't post in the wrong section
    • lenclstr746
      By lenclstr746
      HELLO GUYS
      I'm a work on a background see and click bot project 
      I can complete it if your help me
      (using imagesearch , gdi+ and  fastfind)
    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      With this script you can print Unicode text in the CMD screen
      the script is  easy to use
      just you  write the text that contains Unicode in the first input
      and the script automatically reflect the code in the second input
       you can copy the text to the clipboard
      or you can try printing the text in the CMD window
      I apologize to everyone for colors and shape if not appropriate
      I'm a blind man and I do not see
      Thank you for your understanding
      Greetings to all of youCmdUtM.au3
×