Jump to content

Simple Button Clicking in Graphical Script


creamers
 Share

Recommended Posts

I used Koda to make the gui build 252

 

I am having an absolute time trying to get my buttons to work. 

 

The first sample that does work is an ip script I found online 

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=x86 Public Ip Finder.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <INet.au3>
#include <GuiButton.au3>
#include <GuiToolBar.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
 
$yourip = _GetIP()
$localip = @IPAddress1
GUICreate("Ip Finder", 369, 126, 192, 124)
$button1 = GUICtrlCreateButton("Get Public Ip", 208, 72, 75, 25)
$button2 = GUICtrlCreateButton("Get Local Ip", 208, 30, 75, 25)
$Input1 = GUICtrlCreateInput("The Ip Will Go here", 32, 72, 137, 21)
$Label1 = GUICtrlCreateLabel("Your Ip", 32, 48, 38, 17)
GUISetState(@SW_SHOW)
 
While 1
$msg=GUIGetMsg()
if $msg=-3 Then Exit
if $msg=$button1 then button1()
if $msg=$button2 then button2()
WEnd
 
func button1()
GUICtrlSetData($Input1,$yourip)
EndFunc
 
func button2()
GUICtrlSetData($Input1,$localip)
EndFunc
the second sample of code is going to be an automated backup solution. Essentialy I need the buttons to execute a script in take command (third party cmd replacement). I can work out the working directories latter. I also will need the drive letter to be able to have input and set that as a variable that windows cmd will be able to access later on even it if needed to be a stored to a log file per say. Another thing I am trying to do in the script is have "Log File" run a program run("tail.exe -f log.txt", "/includes"). I tried bring the code from the first sample and I could not get the code to work in the second script.

FileInstall("C:\Users\Wesley\Dropbox\Photos\Desktops\home_is_where_the_hard_disk_is_by_beaucoupzero-d175fpx.jpg", "./images/harddisk.jpg")
FileInstall("C:\Users\Wesley\Dropbox\Photos\Desktops\tumblr_l61uqi7tQl1qckrsl.jpg", "./images/exploding.jpg")

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
#include <GuiButton.au3>
#include <GuiToolBar.au3>


#Region ### START Koda GUI section ### Form=c:\users\wesley\desktop\backup script\koda\main interface.kxf
$Form1_1 = GUICreate("Backup Script", 598, 421, 192, 124)
$Pic1 = GUICtrlCreatePic("./images/harddisk.jpg", 0, 0, 612, 468)
$Label1 = GUICtrlCreateLabel("Computer Works Automated Backup", 0, 0, 391, 33)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$viewerlogs = GUICtrlCreateButton("Log File", 520, 0, 75, 25)
$Script = GUICtrlCreateProgress(376, 296, 150, 17)
$ownership = GUICtrlCreateButton("Step 1: Ownership", 8, 136, 115, 25)
$permissions = GUICtrlCreateButton("Step 2: Permissions", 8, 168, 115, 25)
$symlinks = GUICtrlCreateButton("Step 3: Symlinks", 8, 200, 115, 25)
$backupmove = GUICtrlCreateButton("Step 4: Backup Move", 8, 232, 115, 25)
$backupcopy = GUICtrlCreateButton("Step 4: Backup Copy", 8, 264, 115, 25)
$Customer = GUICtrlCreateInput("Customer", 224, 216, 129, 21)
$Technician = GUICtrlCreateInput("Technician", 224, 240, 70, 21)
$Driveletter = GUICtrlCreateInput("DriveLetter", 224, 264, 60, 21)
Dim $Form1_1_AccelTable[3][2] = [["^p", $permissions],["^!s", $symlinks],["^b", $backupmove]]
GUISetAccelerators($Form1_1_AccelTable)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
$msg=GUIGetMsg()
if $msg=-3 Then Exit
if $msg=$button1 then button1()
if $msg=$button2 then button2()
WEnd

Func viewerlog()
    GUICtrlSetData(Run ("tail.exe", "/includes"))
EndFunc
Thank you for your time. Edited by creamers
Link to comment
Share on other sites

Use

$Pic1 = GUICtrlCreatePic("./images/harddisk.jpg", 0, 0, 612, 468)
GUICtrlSetState(-1, $GUI_DISABLE)
to enable buttons on GUI.

If tail.exe is from here '?do=embed' frameborder='0' data-embedContent>> then you can use the -s <file name> parameter to write the output to a file and read it afterwards to your program or you can use run() function using $STDOUT_CHILD (see in help file) to catch the output from cmd.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

That worked! thank you, I am just using my way for now for some reason that version of tail halts the process while tailwin32 just reads the log file and isnt interupting.

2 questions would there be a way to do almost an iframe and send it over to another form to display tail?

Also what would be the correct way of extracting input from the user data fields and creating a folder based on the user data. I want to create a folder on uncshare$Customer %date% $Technican.

Thank you very much.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...