Jump to content
Sign in to follow this  
mohan93

GUI Button to open VBS script

Recommended Posts

mohan93

Hello Guys,

I have not worked with creating Button in autoit. Though this is common one, please help me with this.

Am trying to create an GUI, only with 10 button and the GUI title name on top.

On clicking each button, VBS will be opened from a repository in a notepad. (e.g: Delete Folder, Stop Service etc some 15 to 20 scripts)

How to acheive this.

Please assist.

Share this post


Link to post
Share on other sites
mikell

You want the buttons to run the vbs or to open them for editing ?

Share this post


Link to post
Share on other sites
mohan93

You want the buttons to run the vbs or to open them for editing ?

I want buttons to open VBS in read mode only (not even for editing) - Because the idea is: all the scipt templates will be in one repository, for users to access the code which they want they can click on respective button, and view only the code. (sorry till now i have not worked with GUIs and Buttons) 

Cheers,

Share this post


Link to post
Share on other sites
mikell

Pick the code for gui/buttons in the helpfile samples, and use this in the script main loop

While 1
   $msg = GUIGetMsg()
   Switch $msg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $btn_vbs1
        Run('notepad.exe ".\folder\vbs1.vbs" ')  ; here use the full or relative path of the vbs file
   EndSwitch
WEnd
Edited by mikell
  • Like 1

Share this post


Link to post
Share on other sites
mohan93

 

Pick the code for gui/buttons in the helpfile samples, and use this in the script main loop

While 1
   $msg = GUIGetMsg()
   Switch $msg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $btn_vbs1
        Run('notepad.exe ".\folder\vbs1.vbs" ')  ; here use the full or relative path of the vbs file
   EndSwitch
WEnd

Thanks for your post.

I use the below script to try open the VBS file in Notepad.

#include <GUIConstantsEx.au3>

GUICreate("Script Template", 180, 600)

$Install = GUICtrlCreateButton("Install.vbs", 15, 50, 150)

GUISetState(@SW_SHOW)

While 1

  $msg = GUIGetMsg()

  Select

    Case $msg = $Install

      Run('notepad.exe "C:tempInstall.vbs" ')

I have new requirement now, instead of opening the VBS file directly in notepad.. i want to read the contents of the file and display it in Listview or watever which will be easy.

am reading the file using _FileReadToArray but not able to write it to a listview..  tried using _GUICtrlListView_AddItem but am spoiling the scipt somewhere.

#include <file.au3>

Dim $aRecords

If Not _FileReadToArray("C:tempSample.txt",$aRecords) Then

   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)

   Exit

EndIf

 

Please assist how do i show this content in a Listview

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  

×