Jump to content

Help: Need to pass parameters to running script


Guest soulin
 Share

Recommended Posts

Any ideas how to do it? I need to run script and pass some parameters to it.

Idea is to create GUI, where are some entries... When the entries are finished, I would like to grey them.

Any help appreciated.

Martin

Link to comment
Share on other sites

Not sure what you mean. Are the 'parameters' you want to pass just something you can type in a box or select from a list? In that case you should just be able to use standard GUI controls. Or do you want to pass filenames to a running script? In that case, create your GUI with the extended style $WS_EX_ACCEPTFILES, and you can drag-and-drop them from Windows Explorer.

Link to comment
Share on other sites

hi im doing something alike u can take this code i tink i got it very clean :">

also can someone help me with my code when i press save the iniwrite allways returns 6 into the saved file :whistle:

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.0
; Language:    English
; Platform:    Win9x / NT
; Author:        -NONE- <?@?.com>
;
; Script Function:
;   R.Y.L. Path of the Emperor, XP Trainer
;
; ----------------------------------------------------------------------------


; ----------------------------------------------------------------------------
; Set up our defaults
; ----------------------------------------------------------------------------

;AutoItSetOption("MustDeclareVars", 1)
;AutoItSetOption("MouseCoordMode", 0)
;AutoItSetOption("PixelCoordMode", 0)
;AutoItSetOption("RunErrorsFatal", 0)
;AutoItSetOption("TrayIconDebug", 1)
;AutoItSetOption("WinTitleMatchMode", 4)
Opt("GuiOnEventMode", 1)
;Opt("GUICoordMode",2)
; ----------------------------------------------------------------------------
; includes and variables
; ----------------------------------------------------------------------------

#include <GUIConstants.au3>
;general variables
$cfgfile = @ScriptDir & "\trainer_cfg.ini"
$screen = @DesktopWidth

;attack variables
$att_1 = IniRead($cfgfile, "attack", "$rot_speed", "0")
$att_2 = IniRead($cfgfile, "attack", "$att_time", "0")
$att_3 = IniRead($cfgfile, "attack", "$pick_time", "0")
$att_4 = IniRead($cfgfile, "attack", "$pick_amount", "0")
$att_5 = IniRead($cfgfile, "attack", "$walk_time", "0")
$att_6 = IniRead($cfgfile, "attack", "$walk_switch", "0")
;heal variables
$heal_1 = IniRead($cfgfile, "heal", "$heal_75", "0")
$heal_2 = IniRead($cfgfile, "heal", "$heal_50", "0")
$heal_3 = IniRead($cfgfile, "heal", "$heal_25", "0")
;options variables
$opt_1 = IniRead($cfgfile, "option", "$title", "Risk Your Life")
$opt_2 = IniRead($cfgfile, "option", "$total_time", "60")

; ----------------------------------------------------------------------------
; Interface Start
; ----------------------------------------------------------------------------

GUICreate ( "Trainer", 154, 400, $screen - 159, -1); Create the app GUI(title,with,height,left,top)
GUISetBkColor (0x000000)    ; BG color 
GUISetFont(9, 300)        ;Font
GUISetState (@SW_SHOW)    ; will display an empty dialog box
GuiSetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

$tab = GUICtrlCreateTab (2,2, 150,397); Create the tab controller
; Tab 1/3 attack -------------------------------------------------------
$tab0=GUICtrlCreateTabitem ("Auto"); Tab Label = "Auto"
GUICtrlSetState(-1,$GUI_SHOW)   ; will display this tab first
; 1st attack cfg controller
GUICtrlCreateLabel ("Rotation Speed:", 5,32,105,20); label text, left, top,with,height
$ctrl_1 = GUICtrlCreateInput ($att_1, 115, 30, 30, 20)
GUICtrlSetLimit(-1,2,0)   ; change id max/min value
GUICtrlSetData($ctrl_1,$att_1)   ; set data on load from ini file

GUICtrlCreateButton ("Save", 20, 370, 50, 20)
GUICtrlSetOnEvent ( -1, "Save" )
GUICtrlCreateButton ("on", 85, 370, 50, 20)

; Tab 2/3 heal ---------------------------------------------------------
$tab1=GUICtrlCreateTabitem ( "Heal")

; Tab 3/3 options ------------------------------------------------------
$tab2=GUICtrlCreateTabitem ("Config")
GUICtrlCreateEdit ($opt_1, 5,30,130,20); label text, left, top,with,height
; example slider


; End Tab control --------------------------------------------------------------
GUICtrlCreateTabitem ("")   ; end tabitem definition


; ----------------------------------------------------------------------------
; Script
; ----------------------------------------------------------------------------

While 1
 Sleep (10); loop doing nothing
Wend

; ----------------------------------------------------------------------------
; Functions
; ----------------------------------------------------------------------------
Func Save() 
   IniWrite($cfgfile, "attack", "$rot_speed", $ctrl_1)
EndFunc

Func SpecialEvents()
   
    Select
        Case @GUI_CTRLID = $GUI_EVENT_CLOSE
           ;MsgBox(0, "Exit?", "Are you sure?")
            Exit
            
        Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
            MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
            
        Case @GUI_CTRLID = $GUI_EVENT_RESTORE
            MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
            
    EndSelect
    
EndFunc

trainer_cfg.ini

[Attack]
$rot_speed=6
$att_time=0
$pick_time=0
$pick_amount=0
$walk_time=0
$walk_switch=0

[Heal]
$heal_75=0
$heal_50=0
$heal_25=0

[Option]
$title=abc
$total_time=29

any help apreciated :dance:

note=im kinda noobish on program language i did this from the help files =)

Link to comment
Share on other sites

Idea is to create GUI, where are some entries... When the entries are finished, I would like to grey them.

<{POST_SNAPBACK}>

i use GUICtrlSetState( control ID, $GUI_DIABLE)

here is an example

#include <GuiConstants.au3>
Dim $stop = 0, $go = 0, $time, $t, $move

GuiCreate("The  W A I T E R ", 365, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$input1 = GuiCtrlCreateInput("wait time", 130, 85, 55, 22)
GUICtrlSetState( -1, $GUI_FOCUS)
$label1 = GuiCtrlCreateLabel("Please type in a  *wait*  time for the function ( in seconds)", 20, 150, 340, 80)
$startbutton = GuiCtrlCreateButton("Start", 130, 115, 96, 23)
GUICtrlSetState( -1, $GUI_DEFBUTTON)
$stopbutton = GuiCtrlCreateButton("Stop", 249, 115, 96, 23)
$progress = GUICtrlCreateProgress( 20, 116, 96, 20)
GUISetState()

;Set on event-- does not use GUIGetMessage()
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode 

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlSetOnEvent($startbutton, "startit")
GUICtrlSetOnEvent($stopbutton, "stopit")


While 1
    
    If $go = 1 Then
        GUICtrlSetState( $input1, $GUI_DISABLE)
        $t = $t +1
        $move = $move + 10
        
        GUICtrlSetData($progress, $move)
        If $t = 11 then 
            $go = 0
            $t = 0
            $move = 0
            GUICtrlSetData($progress, 0)
            GUICtrlSetState( $input1, $GUI_ENABLE)
            GUICtrlSetData($label1, " The wait is over")
        EndIf
        
        Sleep($time)
        
    EndIf

    If $stop = 1 Then
        MsgBox(0, "Cancelled", "Wait was cancelled...", 2)
        GUICtrlSetData($progress, 0)
        GUICtrlSetState( $input1, $GUI_ENABLE)
        $stop = 0
        $go = 0
        $t = 0
        $move = 0
    EndIf
    
    If $t <> 0 Then
        GUICtrlSetData($label1, " The Program is still running,  " & $move & "%" )
    Else
        Sleep(300)
        GUICtrlSetData($label1, "Please type in a  *wait*  time for the function ( in seconds)")
    EndIf

;Sleep(5)
WEnd

Func stopit()
   $stop = 1
EndFunc

Func startit()
    $go = 1
    $inputread = GUICtrlRead($input1)
    $time = $inputread * 90
Endfunc

Func CLOSEClicked()
  MsgBox(0, "Close Program", "You clicked CLOSE!" & @CRLF & "Now Exiting...  The W A I T E R", 3)
  Exit
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

this could help

Func Save()
    $ctrl_1 = GUICtrlRead($ctrl_1)
   IniWrite($cfgfile, "attack", "$rot_speed", $ctrl_1)
EndFunc

just replace this in your script

8)

<{POST_SNAPBACK}>

thx that pointed me out to GUIRead() that worked it up =)
Link to comment
Share on other sites

Hi guys!

I had hard day yesterday, so sorry that my question was so stupid.

I am working on SDS - free management software like SMS, USD, Alitris (more info on my blog, martinzugec.blogdrive.com).

I need to create frontend on client workstations, that will show the progress. The client installation will report when they are finished.

Idea is that you will launch frontend program, in will load a list of entries from ini file.

It will show this entries together with progress bar. When the installation of application will finish, applications will somehow notify frontend that they finished successfuly, the colour next to entries will change to green and progress bar will progress :whistle: If they will just close without notify, frontend will change colour to red.

Now the problem is how to notify running application that it should change the state of entries?

Any ideas greatly appreciated, if there is anyone interested in developing this, I will include him in readme.txt.

Martin

Link to comment
Share on other sites

Sounds like you want something like kTool? The source was released for that project.

Unless you want somethimg that uses FileFind(First\Next)File. No INI needed. This is what I use to install AutoIt install scripts from a software folder, one after the other. Let me know, and I will share the script. Picture here. ;)

Link to comment
Share on other sites

Hello MHz! (p.s.: I am Martin Zugec from MSFN:))

Looks like exactly what I am looking for. Thanks for info, I will let you know about progress...

Link to comment
Share on other sites

Looks like I found my favourite ;)

SDS is running to first public beta, the last thing I need to solve is client agent...

It looks like I will modify kTool to my needs and use it.

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...