Jump to content
Emmhor1

Choose between Functions within GUI

Recommended Posts

Hi All,


MAIN QUESTION:
Is it possible to Call specific function within a GUI


So I have a script with multiple functions although I don't want to use every function every time.
My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.

I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
This script is on my work laptops and cannot access it right now.

 

Who can help me with this?

GUIcreate

Func1 
Func2
Func3

Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
Then a button which executes/calls the selected functions

Share this post


Link to post
Share on other sites

This is a quick modyfication for GUICreate() first Example from HelpFile :

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idOK
                _ButtonOK_Pressed()
        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func _ButtonOK_Pressed()
    MsgBox($MB_ICONINFORMATION, 'Info', 'Button OK Pressed')
EndFunc   ;==>_ButtonOK_Pressed

I this what you are looking for ?

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API Forum Rules *
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

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 SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.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 * Good coding practices in AutoIt * 

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) * IE in TaskScheduler

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

11

Signature last update: 2018-10-31

Share this post


Link to post
Share on other sites
23 minutes ago, mLipok said:

 

Hi mLipok,

Thanks for you reply although I managed to find my script I mentioned above.

I modified it a bit:

This is my original script

#requireadmin
#include <GUIConstantsEx.au3>
#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\AutoIt_Main_v10_48x48_256.ico)

$state = "UNCHECKED"
;CHECK BOXES
$gui=GUICreate("VidaXL App Installer", 500, 340)
;Standard Applications
$app1 = GUICtrlCreateCheckbox("7 Zip", 20, 30, 120, 20)
$app2 = GUICtrlCreateCheckbox("Google Chrome", 20, 50, 120, 20)



$standardSoftware = GUICtrlCreateLabel("Standard Software", 20, 10, 120, 20)
GUICtrlSetColor($StandardSoftware, 0x93117E)
GUICtrlSetFont($StandardSoftware,10,Default,Default,"Comic Sans MS")



$select=GUICtrlCreateButton("Select All", 20, 235, 100, 20)
$deselect=GUICtrlCreateButton("Deselect All", 20, 255, 100, 20)

$select2=GUICtrlCreateButton("Select All", 200, 235, 100, 20)
$deselect2=GUICtrlCreateButton("Deselect All", 200, 255, 100, 20)

$select3=GUICtrlCreateButton("Select All", 380, 235, 100, 20)
$deselect3=GUICtrlCreateButton("Deselect All", 380, 255, 100, 20)

$button=GUICtrlCreateButton("Start Installation", 150, 290, 200, 20)
$cancelbutton=GUICtrlCreateButton("Cancel", 150, 310, 200, 20)
$msg=GUISetState()

While 1

   Switch GUIGetMsg()
   Case $select
       GUICtrlSetState($app1, $GUI_CHECKED)
       GUICtrlSetState($app2, $GUI_CHECKED)
     
   Case $deselect
       GUICtrlSetState($app1, $GUI_UNCHECKED)
       GUICtrlSetState($app2, $GUI_UNCHECKED)


       Case $button
        If BitAnd(GUICtrlRead($app1),$GUI_CHECKED) = $GUI_CHECKED Then
           RunWait("\\sl051-file-01\IT Workstation\Software\Standard\7Zip.exe")
        EndIf
        If BitAnd(GUICtrlRead($app2),$GUI_CHECKED) = $GUI_CHECKED Then
           RunWait("\\sl051-file-01\IT Workstation\Software\Standard\Chrome.exe")
        EndIf
      


    Case $GUI_EVENT_CLOSE
       MsgBox(0, 'Thank you for using!', 'Made by Emmanuel Horvat')
        Exit
     Case $cancelbutton
        MsgBox(0, 'Thank you for using!', 'Made by Emmanuel Horvat')
        Exit
    EndSwitch
 WEnd

This works. As you see I get a GUI with 2 checkboxes. If I select app1 it only installs app1 if I select app1 and app2 it installs both and if I silect app2 it only installs app2

But like you see it uses runwait to run the EXE. In the new situation I have not created multiple exe's but more functions within the script

This is what I use now:

$app1 = GUICtrlCreateCheckbox("Char1", 20, 30, 120, 20)
$app2 = GUICtrlCreateCheckbox("Char2", 20, 50, 120, 20)
$select=GUICtrlCreateButton("Select All", 20, 235, 100, 20)
$deselect=GUICtrlCreateButton("Deselect All", 20, 255, 100, 20)

$button=GUICtrlCreateButton("Start Installation", 150, 290, 200, 20)
$cancelbutton=GUICtrlCreateButton("Cancel", 150, 310, 200, 20)
$msg=GUISetState()


While 1

   Switch GUIGetMsg()
   Case $select
       GUICtrlSetState($app1, $GUI_CHECKED)
       GUICtrlSetState($app2, $GUI_CHECKED)

   Case $deselect
       GUICtrlSetState($app1, $GUI_UNCHECKED)
       GUICtrlSetState($app2, $GUI_UNCHECKED)


   Case $button
        If BitAnd(GUICtrlRead($app1),$GUI_CHECKED) = $GUI_CHECKED Then
           Call("Char1")
        EndIf
        If BitAnd(GUICtrlRead($app2),$GUI_CHECKED) = $GUI_CHECKED Then
           Call("Char2")
        EndIf


    Case $GUI_EVENT_CLOSE
       MsgBox(0, 'Thank you for using!', 'Made by Emmanuel Horvat')
        Exit
     Case $cancelbutton
        MsgBox(0, 'Thank you for using!', 'Made by Emmanuel Horvat')
        Exit
    EndSwitch
 WEnd

Func Char1()
 WHAT THE FUNCTION DOESN BUT IT"S NOT IMPORTANT FOR NOW
EndFunc

Func Char2()

As you see it is the exact same but instead of runwait I use Call to select the function to run.

If I select Char1 it runs char1 function without issues

If I select char2 it runs char2 function without issues

If I select both it only runs char1

 

How do I make it to run the selected functions correctly.So if I select char1 and char2 that it runs both not only the first one.

Share this post


Link to post
Share on other sites

You do not need to use Call() just change this:
 

If BitAnd(GUICtrlRead($app1),$GUI_CHECKED) = $GUI_CHECKED Then
           Call("Char1")
        EndIf
        If BitAnd(GUICtrlRead($app2),$GUI_CHECKED) = $GUI_CHECKED Then
           Call("Char2")
        EndIf

to:

If BitAnd(GUICtrlRead($app1),$GUI_CHECKED) = $GUI_CHECKED Then
           Char1()
        EndIf
        If BitAnd(GUICtrlRead($app2),$GUI_CHECKED) = $GUI_CHECKED Then
           Char2()
        EndIf

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API Forum Rules *
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

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 SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.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 * Good coding practices in AutoIt * 

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) * IE in TaskScheduler

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

11

Signature last update: 2018-10-31

Share this post


Link to post
Share on other sites

Just using this simple example, both execute for me.

#include <GUIConstantsEx.au3>
#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\AutoIt_Main_v10_48x48_256.ico)


;CHECK BOXES
$gui=GUICreate("VidaXL App Installer", 500, 340)
$app1 = GUICtrlCreateCheckbox("Char1", 20, 30, 120, 20)
$app2 = GUICtrlCreateCheckbox("Char2", 20, 50, 120, 20)
$select=GUICtrlCreateButton("Select All", 20, 235, 100, 20)
$deselect=GUICtrlCreateButton("Deselect All", 20, 255, 100, 20)

$button=GUICtrlCreateButton("Start Installation", 150, 290, 200, 20)
$cancelbutton=GUICtrlCreateButton("Cancel", 150, 310, 200, 20)
$msg=GUISetState()


While 1

   Switch GUIGetMsg()
   Case $select
       GUICtrlSetState($app1, $GUI_CHECKED)
       GUICtrlSetState($app2, $GUI_CHECKED)

   Case $deselect
       GUICtrlSetState($app1, $GUI_UNCHECKED)
       GUICtrlSetState($app2, $GUI_UNCHECKED)


   Case $button
        If BitAnd(GUICtrlRead($app1),$GUI_CHECKED) = $GUI_CHECKED Then
           Char1()
        EndIf
        If BitAnd(GUICtrlRead($app2),$GUI_CHECKED) = $GUI_CHECKED Then
           Char2()
        EndIf


    Case $GUI_EVENT_CLOSE
       MsgBox(0, 'Thank you for using!', 'Made by Emmanuel Horvat')
        Exit
     Case $cancelbutton
        MsgBox(0, 'Thank you for using!', 'Made by Emmanuel Horvat')
        Exit
    EndSwitch
 WEnd

Func Char1()
    msgbox(0,"","char1")
EndFunc

Func Char2()
    msgbox(0,"","char2")
EndFunc

Perhaps there is something else in your full script causing issue?


Share this post


Link to post
Share on other sites

I found out yesterday I had no Case $button

I added it and now it seems to work but only for 1/2 functions again they don't run together

Share this post


Link to post
Share on other sites

If you want to scale:

;#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Icon_Add=Resources\AddRemApp.ico
#AutoIt3Wrapper_Icon=Resources\AddRemApp.ico
#AutoIt3Wrapper_Run_Tidy=n
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <WinAPI.au3>
#include <GuiEdit.au3>
#include <GuiButton.au3>
#include <Constants.au3>
#include <GuiStatusBar.au3>
#include <GUIConstants.au3>
#include <GuiImageList.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("TrayMenuMode", 1)
Opt("TrayIconHide", 1)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 0)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 1)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)

FileInstall("AutoIt Checkboxes Installation.au3", @ScriptDir & '\AutoIt Checkboxes Installation.au3', 1)

TraySetIcon("IMG\install2.ico")

Local $STR1 = StringInStr(@ScriptDir, '\', 2, 2)
Local $STR2 = StringLeft(@ScriptDir, $STR1)

$hGUI = GUICreate("AutoIt Install Menu", 740, 250, 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
$hlabel = GUICtrlCreateLabel("Select a Program to install", 30, 10, 126, 17)
$hButton1 = GUICtrlCreateButton("Start", 30, 200, 50)
$hButton2 = GUICtrlCreateButton("Select All", 80, 200, 80)
$hButton3 = GUICtrlCreateButton("UnSelect All", 160, 200, 80)

$totray = TrayCreateItem("Tray")
TrayItemSetOnEvent($totray, "ToTray")

$restore = TrayCreateItem("Restore")
TrayItemSetOnEvent($restore, "Restore")

$exititem = TrayCreateItem("Close")
TrayItemSetOnEvent($exititem, "Quit")

GUISetState()

Global $aRadio[32]
Global $aApps[32][3]
$aApps[0][0] = "W10Tools"
$aApps[0][1] = "W10Tools.exe"
$aApps[0][2] = "IMG\Pc.ico"
$aApps[1][0] = "SMP"
$aApps[1][1] = "AutoIt SMP.exe"
$aApps[1][2] = "IMG\SMP.ico"
$aApps[2][0] = "LAN"
$aApps[2][1] = "AutoIt LAN.exe"
$aApps[2][2] = "IMG\realtek.ico"
$aApps[3][0] = "Obsidian"
$aApps[3][1] = 'Obsidian\Obsidian.bat'
$aApps[3][2] = "Obsidian\normal.ico"
$aApps[4][0] = "Java"
$aApps[4][1] = "AutoIt Java.exe"
$aApps[4][2] = "IMG\java.ico"
$aApps[5][0] = "DX9c"
$aApps[5][1] = "AutoIt DX9c.exe"
$aApps[5][2] = "IMG\dx9c.ico"
$aApps[6][0] = "Create Synchronicity 6.0"
$aApps[6][1] = "Create Synchronicity 6.0.exe"
$aApps[6][2] = "IMG\sync.ico"
$aApps[7][0] = "Firefox"
$aApps[7][1] = "AutoIt FFox.exe"
$aApps[7][2] = "IMG\fox.ico"
$aApps[8][0] = "Group Policy Tool"
$aApps[8][1] = "GroupPolicy W10 X64\GPO Tool.exe"
$aApps[8][2] = "IMG\gpls.ico"
$aApps[9][0] = "Notepad ++"
$aApps[9][1] = "Notepad ++ 7.5.2 SFX.exe"
$aApps[9][2] = "IMG\notepad.ico"
$aApps[10][0] = "PowerCfgW10"
$aApps[10][1] = "PowerCfgW10.exe"
$aApps[10][2] = "IMG\power.ico"
$aApps[11][0] = "FlashPlayer"
$aApps[11][1] = "AutoIt FlashPlayer.exe"
$aApps[11][2] = "IMG\flashplayer.ico"
$aApps[12][0] = "WinRar"
$aApps[12][1] = "AutoIt WinRar.exe"
$aApps[12][2] = "IMG\winrar.ico"
$aApps[13][0] = "Foxit Reader"
$aApps[13][1] = "FoxitReaderPortable.exe"
$aApps[13][2] = "IMG\foxit.ico"
$aApps[14][0] = "Realtek R*"
$aApps[14][1] = "AutoIt RLTK x64.exe"
$aApps[14][2] = "IMG\realtek.ico"
$aApps[15][0] = "AutoIt + SciTE"
$aApps[15][1] = "AutoIt AutoIt + SciTe Silent.exe"
$aApps[15][2] = "IMG\autoit.ico"
$aApps[16][0] = "PhysX"
$aApps[16][1] = "AutoIt PhysX.exe"
$aApps[16][2] = "IMG\physx.ico"
$aApps[17][0] = "FM2 Chipset"
$aApps[17][1] = "F2A85M-LE\FM2_Chipset\Setup.exe"
$aApps[17][2] = "IMG\amd.ico"
$aApps[18][0] = "Logitech SetPoint"
$aApps[18][1] = "AutoIt Logitech SetPoint.exe"
$aApps[18][2] = "IMG\logitech.ico"
$aApps[19][0] = "Logitech GS"
$aApps[19][1] = "AutoIt LGS.exe"
$aApps[19][2] = "IMG\lgs.ico"
$aApps[20][0] = "Synaptics 17.0.19C"
$aApps[20][1] = "AutoIt Synaptics 17.0.19C.exe"
$aApps[20][2] = "IMG\synaptics.ico"
$aApps[21][0] = "Fraps"
$aApps[21][1] = "AutoIt Fraps.exe"
$aApps[21][2] = "IMG\fraps.ico"
$aApps[22][0] = "Reserved"
$aApps[22][1] = ""
$aApps[22][2] = "IMG\Blank.ico"
$aApps[23][0] = "Reserved"
$aApps[23][1] = ""
$aApps[23][2] = "IMG\Blank.ico"
$aApps[24][0] = "Reserved"
$aApps[24][1] = ""
$aApps[24][2] = "IMG\Blank.ico"
$aApps[25][0] = "Reserved"
$aApps[25][1] = ""
$aApps[25][2] = "IMG\Blank.ico"
$aApps[26][0] = "Reserved"
$aApps[26][1] = ""
$aApps[26][2] = "IMG\Blank.ico"
$aApps[27][0] = "Reserved"
$aApps[27][1] = ""
$aApps[27][2] = "IMG\Blank.ico"
$aApps[28][0] = "Reserved"
$aApps[28][1] = ""
$aApps[28][2] = "IMG\Blank.ico"
$aApps[29][0] = "Reserved"
$aApps[29][1] = ""
$aApps[29][2] = "IMG\Blank.ico"
$aApps[30][0] = "Reserved"
$aApps[30][1] = ""
$aApps[30][2] = "IMG\Blank.ico"
$aApps[31][0] = "Reserved"
$aApps[31][1] = ""
$aApps[31][2] = "IMG\Blank.ico"

For $i = 0 To 3
    For $j = 0 To 7
        $sName = ($aApps[($i * 8) + $j][0])
        GUICtrlCreateIcon($aApps[($i * 8) + $j][2], -2, 30 + ($i * 160), 30 + ($j * 20), 17, 17)
        $aRadio[($i * 8) + $j] = GUICtrlCreateCheckbox($sName, 50 + ($i * 160), 30 + ($j * 20), 138, 20)
    Next
Next

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton1
            For $i = 0 To 29
                If BitAND(GUICtrlRead($aRadio[$i]), $GUI_CHECKED) = $GUI_CHECKED Then
                    If Not FileExists($aApps[$i][1]) Then
                        MsgBox(262160, "File not found!", $aApps[$i][1], 0)
                    Else
                        ConsoleWrite("Running: " & $aApps[$i][0] & @CRLF)
                        ShellExecuteWait($aApps[$i][1])
                        TrayTip('Installer', "Running: " & $aApps[$i][0], 3)
                    EndIf
                EndIf
            Next
            ;================================================
        Case $hButton2 ;All
            For $i = 0 To 21
                GUICtrlSetState($aRadio[$i], $GUI_CHECKED)
            Next
            ;================================================
        Case $hButton3 ;None
            For $i = 0 To 31
                GUICtrlSetState($aRadio[$i], $GUI_UNCHECKED)
            Next
    EndSwitch
WEnd

Func ToTray()
    TrayItemSetState($totray, $TRAY_UNCHECKED)
    GUISetState(@SW_HIDE)
EndFunc   ;==>ToTray

Func Restore()
    TrayItemSetState($restore, $TRAY_UNCHECKED)
    GUISetState(@SW_SHOW)
EndFunc   ;==>Restore

Func Quit()
    Exit
EndFunc   ;==>Quit

 


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

I managed to get it to work these are the changes

 

First

Func Char1()
 While 1
      Local $hWnd = WinWait($Class, "", 10)
      Local $iState = WinGetState($hWnd)

   If BitAND($Title, $WIN_STATE_EXISTS) Then
        WinActivate($Title)
    Else
        Exit
    EndIf

    Sleep(2000)

      Send("{q down}")
      Send("{q up}")

    Sleep(2000)
 WEnd
EndFunc

If I use this setup in both Functions only 1 is being executed

But if I change it to this it works:
 

Func Char1()
   WinActivate($Title)

    Sleep(5000)
    Send("{q down}")
      Send("{q up}")
EndFunc

 

The next problem is the functions itself. The functions contain a While this means it won't execute the second function because the first function is still in it's loop

 

Func Char1()

   While 1
      WinActivate($Title)
      Sleep(5000)
      Send("{q down}")
      Send("{q up}")
   WEnd 
EndFunc

Func Char2()
   While 1
      WinActivate($Title)
      Sleep(5000)
      Send("{a down}")
      Send("{a up}")
   WEnd
EndFunc

Is it possible to run the 2 functions at the same time?

 

EDIT: Managed to get it to work by not calling the function but by running a external script
The thing with this is I will have to create a lot of scripts imagine having 20 charactet this means 20 scripts atleast

If BitAnd(GUICtrlRead($Character1),$GUI_CHECKED) = $GUI_CHECKED Then
         $PID = Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\test.au3' & '"')

      EndIf
      If BitAnd(GUICtrlRead($Character2),$GUI_CHECKED) = $GUI_CHECKED Then
         $PID = Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\test1.au3' & '"')

 

Edited by Emmhor1

Share this post


Link to post
Share on other sites

Run 2 functions at the same time would be multithreading so no.

But you could have it all in the main loop, set the conditions and it would run sequentially. And there's adlib.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
2 hours ago, careca said:

Run 2 functions at the same time would be multithreading so no.

But you could have it all in the main loop, set the conditions and it would run sequentially. And there's adlib.

Could you set this up for me and then i Will expanderen it with my needs

Share this post


Link to post
Share on other sites

I'll help you, and that's <> than doing it FOR you, besides it's easy enough so you can at least try.

A condition is for example:

If $varX = 1 Then

So if you put conditions, inside the main loop, and under these conditions, code to execute, this means you select what you want to get executed, just need to change the variables value. You can have for example checkboxes corresponding to what sections you want executed, the checkbox can be read, also in the main loop, and depending on checked or not, set the variable to 1 or 0. That simple.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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

    • By CarlD
      As my first stab at GUI scripting, I'm trying to write a simple graphical interface for Grep for Windows. I have a basic GUI, but I'm stuck on one point and nothing I've tried so far works. The sticking point is that while the Tab key works to move focus from one input control to the next, clicking the mouse on any but the first input does nothing. This seems like a basic feature of GUI functionality that should work out of the box (like Tab), but clearly I'm missing something. I tried (among many other things) Melba23's technique in the post below, but this doesn't do what I'm after -- getting the left click to set the insertion point for user input. Would greatly appreciate a pointer or two. 😉
      Here's my code so far:
      ; Grep for Windows -- GUI [CLD] #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("WinTitleMatchMode", -2) #cs FileInstall("X:\nix\search1.ico", @TempDir & "\search1.ico") FileInstall("X:\nix\grep.exe", @TempDir & "\grep.exe") FileInstall("X:\nix\sed.exe", @TempDir & "\sed.exe") FileInstall("X:\nix\libiconv2.dll", @TempDir & "\libiconv2.dll") FileInstall("X:\nix\libintl3.dll", @TempDir & "\libintl3.dll") FileInstall("X:\nix\pcre3.dll", @TempDir & "\pcre3.dll") FileInstall("X:\nix\regex2.dll", @TempDir & "\regex2.dll") #ce ; $sDefFs = @ScriptDir & "\.txt" $sOut = "" $iX = 20 $iY = 20 $hgGGrep = GUICreate("Grep for Windows: Simple TeXT search", 600, 600) GUISetState(@SW_SHOW, $hgGGrep) ; Obtain value of control: GUICtrlRead() ; left, top, width, height ; $iX, $iY, $iX + n, $iY + m ; $hgIco = GUICtrlCreateIcon(@ScriptDir & "\search1.ico", $iX, $iY, 10) $hgGL0 = GUICtrlCreateLabel("Enter a string or regular expression" & @CRLF & "(space between words means ""OR"")", $iX + 50, $iY, 250, 30) $hgSch = GUICtrlCreateInput("", $iX + 50, $iY + 40, 325, 20, $GUI_SS_DEFAULT_INPUT, -1) $hgXyZ = GUICtrlCreateCheckbox("cAsE-sEnSiTiVe", $iX + 50, $iY + 65, -1, -1) $hgExe = GUICtrlCreateButton("Search", 400, $iY + 40, -1, -1) $hgFL1 = GUICtrlCreateLabel("Filespec", $iX + 50, $iY + 100, 250, 20) $hgFs1 = GUICtrlCreateInput("d:\path\*.txt", $iX + 110, $iY + 100, 250, 20, $GUI_SS_DEFAULT_INPUT, -1) $hgFL2 = GUICtrlCreateLabel("Filespec", $iX + 50, $iY + 120, 250, 20) $hgFs2 = GUICtrlCreateInput("", $iX + 110, $iY + 120, 250, 20, $GUI_SS_DEFAULT_INPUT, -1) $hgFL3 = GUICtrlCreateLabel("Filespec", $iX + 50, $iY + 140, 250, 20) $hgFs3 = GUICtrlCreateInput("", $iX + 110, $iY + 140, 250, 20, $GUI_SS_DEFAULT_INPUT,-1) $hgOut = GUICtrlCreateEdit($sOut, 25, 190, 550, 400, $ES_LEFT, -1) GUICtrlSetState($hgSch, $GUI_FOCUS) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ; #cs _WinAPI_SetFocus(ControlGetHandle("Grep for Windows", "", $hgSch)) _WinAPI_SetFocus(ControlGetHandle("Grep for Windows", "", $hgFs1)) _WinAPI_SetFocus(ControlGetHandle("Grep for Windows", "", $hgFs2)) _WinAPI_SetFocus(ControlGetHandle("Grep for Windows", "", $hgFs3)) #ce Thanks in advance.
    • By Elizabeth
      Buttons on GUI to perform different tasks. SETUP is a task that involves displaying another GUI, doing calculations, writing lines to 2 external files, displaying information on GUI labels.  The info from the displayed GUI (quantity made and job completed YES or NO) must be included on the written lines. I cannot get the script to run synchronously (waterfall execution 1st one ends before 2nd one starts.) That means lines written to the files do not contain the required data.  I have read through FORUM and thought by inserting a boolean value and changing TRUE FALSE that I could solve this issue. I would have to set/reset the boolean before every function call to make it work. I've tried using Sleep but that just slows everything down and makes main GUI look unresponsive
      Is there a trick or tip someone can provide that forces synchronous execution?
      I am using OPT GUIOnEventMode
      Thank you for any insight into this issue.
    • By TheDcoder
      Hello everyone,
      I encountered this strange issue while working on a freelance project, I cannot give you the webpage/website on which this is happening because it is an internal site which is inaccessible externally. I am attempting to create a GUI with an IE control embedded in it, but when I navigate to the desired address, it shows a blank white page.
      The webpage does load if I use a different browser or normal (non-embedded) IE instance.
      I managed to get my hands on the source of the blank page:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="res://ieframe.dll/ErrorPageTemplate.css" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Navigationen blev annulleret</title> <script src="res://ieframe.dll/errorPageStrings.js" language="javascript" type="text/javascript"> </script> <script src="res://ieframe.dll/httpErrorPagesScripts.js" language="javascript" type="text/javascript"> </script> </head> <body onLoad="javascript:navCancelInit(); "> <table width="730" cellpadding="0" cellspacing="0" border="0"> <!-- Error title --> <tr> <td id="infoIconAlign" width="60" align="left" valign="top" rowspan="2"> <img src="res://ieframe.dll/info_48.png" id="infoIcon" alt="Oplysningsikon"> </td> <td id="mainTitleAlign" valign="middle" align="left" width="*"> <h1 id="mainTitle">Navigationen til websiden blev annulleret</h1> </td> </tr> <tr> <!-- This row is for HTTP status code, as well as the divider--> <td id="errorCodeAlign" class="errorCodeAndDivider" align="right">&nbsp; <div class="divider"></div> </td> </tr> <!-- Error Body --> <!-- What you can do --> <tr> <td> &nbsp; </td> <td id="whatToTryAlign" valign="top" align="left"> <h2 id="whatToTry">Prøv at:</h2> </td> </tr> <!-- refresh page --> <tr> <td > &nbsp; </td> <td id="refreshPageAlign" align="left" valign="middle"> <h4> <table> <tr> <td valign="top"> <img src="res://ieframe.dll/bullet.png" border="0" alt="" class="actionIcon"> </td> <td valign="top"> <span id="navCancelContainer"></span><noscript id="refreshPage">Opdatere siden.</noscript> </td> </tr> </table> </h4> </td> </tr> </table> </body> </html> The ieframe.dll resources are a point of interest. I am not sure how the server is able to detect the embedded instance of IE ...
      Any suggestions? Here is a basic outline of the script:
      #include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Main() While True Sleep(1000) WEnd Func Main() ; Create GUI $hGUI = GUICreate("", $GUI_WIDTH, $GUI_HEIGHT, $iLeft, $iTop, $WS_POPUP) $oIE = _IECreateEmbedded() ;$oIE = _IECreate() ; This works, but it is not embedded in the GUI GUICtrlCreateObj($oIE, 0, 0, $GUI_WIDTH, $GUI_HEIGHT) GUISetState() ; Navigate to the URL and authenticate _IENavigate($oIE, $URL) EndFunc Thank you for the advice in advance!
    • By jpomalley
      Hi all,
      Does anyone know if there is a way to disable the Windows "fade effect" that occurs when a window appears or disappears?
      It is possible for a user to disable visual effects in windows in general through the system properties > performance settings, but I am interested just in fixing it for a particular window that pops up in my app.
      I would like it to appear and disappear instantaneously, snapping in and out, out of nowhere, rather than the short (maybe 300 ms?) fade in/fade out effect that windows has.
      Thanks for any tips
      JP
    • By fastman
      I am struggling with activating the 2nd GUI.  References of https://www.autoitscript.com/wiki/Managing_Multiple_GUIs did not help.
      Gui2 and controls are created, but the buttons are not active.  I have tried to remove extra code.
      Thanks for any help.
      ; ; cabinet maker process to automate MasterCam ; ATP nesting process ; #include <AutoItConstants.au3> #include <Array.au3> ;#include <file.au3> ;#include <FileConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <WinAPIFiles.au3> #include <WindowsConstants.au3> ;#include <XML.au3>; If XML library is updated, note that this script requires that save file will overwrite an existing file Opt("GUIOnEventMode", 1) ; 1 = OnEvent mode Opt("WinWaitDelay", 500) ; milliseconds Opt("TrayIconDebug", 1) Opt("WinSearchChildren", 1) Global $hMainGUI Global $hMainGUI2 Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible = Default, $sStringIncludes = Default, $sClass = Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = True If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass) > 0 Then For $i = UBound($aClassList) - 1 To 0 Step -1 If $aClassList[$i] <> $sClass Then _ArrayDelete($aClassList, $i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ;ConsoleWrite("ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ;ConsoleWrite("ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next ;MsgBox($MB_SYSTEMMODAL, "title", "check console for control list") EndFunc ;==>GetAllWindowsControls ; ======= Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible = Default, $sStringIncludes = Default, $sClass = Default) ========= Func setNestingOverlay() $ovrWidth = 400 $ovrHeight = 60 $ovrLeft = -1 ;$mcamWindow[0] + $nestControlRelative[0] $ovrTop = -1;$mcamWindow[1] + $nestControlRelative[1]+ 10 $hMainGUI = GUICreate("covering mastercam buttons", $ovrWidth, $ovrHeight, $ovrLeft, $ovrTop, -1, $WS_EX_TOPMOST) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseButton2") Local $iOKButton1 = GUICtrlCreateButton("Continue to gui2", 20, 20, 80) GUICtrlSetOnEvent($iOKButton1, "NestResultButtonOverlay") GUISetState(@SW_SHOW, $hMainGUI) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) ;loop to monitor button click While 1 Sleep(50) ; Sleep to reduce CPU usage WEnd ConsoleWrite(" exit loop setNestingOverlay") EndFunc ;==>setNestingOverlay ;=== 2nd gui ======= 2nd gui ======= 2nd gui ======= 2nd gui ======= 2nd gui ======= 2nd gui ==== func NestResultButtonOverlay() $ovrWidth = -1;$mcamWindow[2] - 10 $ovrHeight = 70 ;40 $ovrLeft = -1 ;$mcamWindow[0] + 5 ;+ $nestControlRelative[0] $ovrTop = -1 ;$mcamWindow[1] + $nestControlRelative[1]+ 10 $hMainGUI2 = GUICreate("gui2-- covering nest result buttons", $ovrWidth, $ovrHeight, $ovrLeft, $ovrTop, -1, $WS_EX_TOPMOST) ;width, height, left, top ;GUISetState(@SW_DISABLE + @SW_MINIMIZE, $hMainGUI) ;GUISwitch($hMainGUI2) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseButton2") local $iBackNestingButton = GUICtrlCreateButton("Back to Nesting", 20, 10, 120) GUICtrlSetOnEvent($iBackNestingButton, "backtoNesting") Local $iOKButton2 = GUICtrlCreateButton("Continue for g-Code", 160, 10, 120) GUICtrlSetOnEvent(-1, "generateGCode") ;GUICtrlSetOnEvent($iOKButton2, "generateGCode") Local $iDoneButton2 = GUICtrlCreateButton("Oops go back to vortex", 300, 10, 120) GUICtrlSetOnEvent($iDoneButton2, "CloseButton2") GUISetState(@SW_SHOW, $hMainGUI2) GUISetState(@SW_DISABLE + @SW_MINIMIZE, $hMainGUI) GUISwitch($hMainGUI2) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) While 1 Sleep(50) ; Sleep to reduce CPU usage WEnd ConsoleWrite(" exit loop NestResultButtonOverlay") EndFunc ;==>setNestingOverlay func backtoNesting() msgbox($MB_SYSTEMMODAL, "gui2","backtoNesting") EndFunc Func CloseButton2() msgbox($MB_SYSTEMMODAL, "gui2","CloseButton2") Exit EndFunc func generateGCode() msgbox($MB_SYSTEMMODAL, "gui2","generateGCode") EndFunc ; =========== main =========== main =========== main =========== main =========== main =========== main setNestingOverlay()  
×
×
  • Create New...