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 beginning - communication 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 * SciTE - Lexer for console pane

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

Signature last update: 2019-10-01

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 beginning - communication 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 * SciTE - Lexer for console pane

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

Signature last update: 2019-10-01

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 Dan_555
      Hi, here are few functions for the ListBox.
      I have searched the forum, but most of the functions are for listview, so i took one example code from melba23 (clear selection) and
      wrote few more functions. (Because my current project needs them).
       
      These functions work only on a Multi-selection ListBox .
      The functions do: Clear Selection, Delete Selected items, Invert Selection, Move selected items up and down.
       The example code has 2 Listboxes. The selected items on the left ListBox can be moved up and down. The right Listbox has buttons for the other functions.
      #include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> Global $hForm1 = GUICreate("Listbox test", 349, 287) $LB_1 = GUICtrlCreateList("", 6, 40, 157, 244, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $WS_HSCROLL, $WS_VSCROLL, $LBS_DISABLENOSCROLL)) $LB_2 = GUICtrlCreateList("", 179, 40, 157, 244, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL , $WS_HSCROLL, $WS_VSCROLL, $LBS_DISABLENOSCROLL)) $BL_1 = GUICtrlCreateButton("Up", 20, 3, 35, 18) $BL_2 = GUICtrlCreateButton("Down", 60, 3, 35, 18) $BR_1 = GUICtrlCreateButton("Up", 200, 3, 35, 18) $BR_2 = GUICtrlCreateButton("Down", 240, 3, 35, 18) $BR_3 = GUICtrlCreateButton("Reverse Sel", 272, 22, 68, 17) $BR_4 = GUICtrlCreateButton("Clear Sel", 217, 22, 52, 17) $BR_5 = GUICtrlCreateButton("Delete", 175, 22, 40, 17) $BR_6 = GUICtrlCreateButton("Populate", 290, 3, 50, 18) GUISetState(@SW_SHOW) For $x = 0 To 50 If $x <= 10 Then GUICtrlSetData($LB_1, $x & " test", 0) GUICtrlSetData($LB_2, $x & " Test", 0) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BL_1 $a = Listbox_ItemMoveUD($LB_1, -1) If $a > -1 Then WinSetTitle($hForm1, "", "Moved items: " & $a) Case $BL_2 $a = Listbox_ItemMoveUD($LB_1, 1) If $a > -1 Then WinSetTitle($hForm1, "", "Moved items: " & $a) Case $BR_1 Listbox_ItemMoveUD($LB_2, -1) Case $BR_2 Listbox_ItemMoveUD($LB_2, 1) Case $BR_3 Listbox_ReverseSelection($LB_2) Case $BR_4 Listbox_ClearSelection($LB_2) Case $BR_5 Listbox_DeleteSelectedItems($LB_2) Case $br_6 ;Populate GUICtrlSetData($LB_2, "") ; Clears the listbox For $x = 0 To 50 GUICtrlSetData($LB_2, $x & " Test", 0) Next EndSwitch WEnd ;note $hLB_ID - is the Listbox id Func Listbox_DeleteSelectedItems($hLB_ID) local $aSel = _GUICtrlListBox_GetSelItems($hLB_ID) Local $i For $i = $aSel[0] To 1 Step -1 _GUICtrlListBox_DeleteString($hLB_ID, $aSel[$i]) Next EndFunc ;==>Listbox_DeleteSelectedItems Func Listbox_ClearSelection($hLB_ID) Local $aSel = _GUICtrlListBox_GetSelItems($hLB_ID) ;Code from Melba23 - Autoit Forum For $i = 1 To $aSel[0] _GUICtrlListBox_SetSel($hLB_ID, $aSel[$i], False) Next EndFunc ;==>Listbox_ClearSelection Func Listbox_ReverseSelection($hLB_ID) Local $i Local $aCou = _GUICtrlListBox_GetCount($hLB_ID) Local $cSel = _GUICtrlListBox_GetCaretIndex($hLB_ID) ;Save the caret For $i = 0 To $aCou _GUICtrlListBox_SetSel($hLB_ID, $i, Not (_GUICtrlListBox_GetSel($hLB_ID, $i))) Next _GUICtrlListBox_SetCaretIndex($hLB_ID, $cSel) ;Restore the caret EndFunc ;==>Listbox_ReverseSelection Func Listbox_ItemMoveUD($hLB_ID, $iDir = -1) ;Listbox_ItemMoveUD - Up/Down - Works only on multiple selection listbox ($LBS_MULTIPLESEL) ;$iDir: -1 up, 1 down ;Return values -1 nothing to do, 0 nothing moved, >0 performed moves Local $iCur, $iNxt, $aCou, $aSel, $i, $m = 0 ;Current, next, Count, Selection, loop , movecount $aSel = _GUICtrlListBox_GetSelItems($hLB_ID) ;Put selected items in an array $aCou = _GUICtrlListBox_GetCount($hLB_ID) ;Get total item count of the listbox WinSetTitle ($hForm1,"",$aSel[0]) Select Case $iDir = -1 ;Move Up For $i = 1 To $aSel[0] If $aSel[$i] > 0 Then $iNxt = _GUICtrlListBox_GetText($hLB_ID, $aSel[$i] - 1) ;Save the selection index - 1 text _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i] - 1, _GUICtrlListBox_GetText($hLB_ID, $aSel[$i])) ;Replace the index-1 text with the index text _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i], $iNxt) ;Replace the selection with the saved var $m = $m + 1 EndIf Next For $i = 1 To $aSel[0] ;Restore the selections after moving If $aSel[$i] > 0 Then _GUICtrlListBox_SetSel($hLB_ID, $aSel[$i] - 1, 1) EndIf Next Return $m Case $iDir = 1 ;Move Down If $aSel[0] > 0 Then For $i = $aSel[0] To 1 Step -1 If $aSel[$i] < $aCou - 1 Then $iNxt = _GUICtrlListBox_GetText($hLB_ID, $aSel[$i] + 1) _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i] + 1, _GUICtrlListBox_GetText($hLB_ID, $aSel[$i])) _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i], $iNxt) $m = $m + 1 EndIf Next EndIf For $i = $aSel[0] To 1 Step -1 ;Restore the selections after moving If $aSel[$i] < $aCou - 1 Then _GUICtrlListBox_SetSel($hLB_ID, $aSel[$i] + 1, 1) EndIf Next Return $m EndSelect Return -1 EndFunc ;==>Listbox_ItemMoveUD  
    • By GNGNUT
      Hi guys
      what i am trying to do is have My Gui LIve update Out of focus, so i can have this on a 2nd monitor streaming live updates while i continue to work on other screen, 
      i have been googling and looking at other threads about focus and stuff , but they do not seem to match what I'm after, 

      to be clear - i am not wanting to put focus on the GUI for it to auto update values, 
       
      if you have any positive feed back on the script while you read - i would be more then happy to accept - as im still building my Knowledge of this coding, 
      and stream line is always better Garbage code writing, 
       
      Kind regards 
      Gngnut
       
      #include <MemoryConstants.au3> #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $currentTime,$currentTimeValue,$v,$Label_Time,$Form1 Global $Label_C2_1,$Label_C2_2,$Label_C2_3,$Label_C2_4,$Label_C2_5,$Label_C2_6,$Label_C2_7 Global $Label_C3_1,$Label_C3_2,$Label_C3_3,$Label_C3_4,$Label_C3_5,$Label_C3_6,$Label_C3_7 ;~ Default Hight for boxs $Hight = 40 $lenght = 180 ;; As per nines comments moved out side of the While loop, AdlibRegister(UpdateTime,250) AdlibRegister(updateValues,500) AdlibRegister(Warning,250) hotkeyset ("{ESC}",Terminate) ;; <<< Used to Quit the programe $aMemStats = MemGetStats() MyGui() ;; running the GUI #Region ### START Koda GUI section ### Form= func MyGui() $ServerName=@ComputerName ; ### Change to your location of image $Image = "C:\Users\gngnut\OneDrive\Pictures\Computer.jpg" ; Creating the form With the Labels $Form1 = GUICreate("My System Status", 800, 750, 225, 173,BitOR($WS_SYSMENU,$WS_MAXIMIZEBOX,$WS_MINIMIZEBOX));$WS_POPUP)) $Pic1 = GUICtrlCreatePic($Image, 0, 0, 800, 750) ;;; #### Column 1 $Label_C1_1 = GUICtrlCreateLabel("Total load currently on RAM:", 71, 192, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_2 = GUICtrlCreateLabel("Total physical RAM:", 71, 248, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_3 = GUICtrlCreateLabel("Available physical RAM:", 71, 304, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_4 = GUICtrlCreateLabel("Total Page Size:", 71, 360, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_5 = GUICtrlCreateLabel("Available Page Size:", 71, 416, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_6 = GUICtrlCreateLabel("Total virtual Size:", 71, 472, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_7 = GUICtrlCreateLabel("Available virtual RAM:", 71, 528, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") ;;; #### Column 2 $Label_C2_1 = GUICtrlCreateLabel($aMemStats[$MEM_LOAD] & " %", 311, 192, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) $colour=0xFEF200 GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_2 = GUICtrlCreateLabel($aMemStats[$MEM_TOTALPHYSRAM] & ' Kb' , 311, 248, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_3 = GUICtrlCreateLabel($aMemStats[$MEM_AVAILPHYSRAM] & ' Kb', 311, 304, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_4 = GUICtrlCreateLabel($aMemStats[$MEM_TOTALPAGEFILE] & ' Kb', 311, 360, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_5 = GUICtrlCreateLabel($aMemStats[$MEM_AVAILPAGEFILE] & ' Kb', 311, 416, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_6 = GUICtrlCreateLabel($aMemStats[$MEM_TOTALVIRTUAL] & ' Kb' , 311, 472, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_7 = GUICtrlCreateLabel($aMemStats[$MEM_AVAILVIRTUAL] & ' Kb', 311, 528, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") ;;; #### Column 3 $Label_C3_2 = GUICtrlCreateLabel(Round($aMemStats[$MEM_TOTALPHYSRAM]/1024/1024, 2) & ' Gb', 551, 248, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C3_3 = GUICtrlCreateLabel(Round($aMemStats[$MEM_AVAILPHYSRAM]/1024/1024, 2) & ' Gb', 551, 304, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C3_4 = GUICtrlCreateLabel(Round($aMemStats[$MEM_TOTALPAGEFILE]/1024/1024, 2) & ' Gb', 551, 360, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C3_5 = GUICtrlCreateLabel(Round($aMemStats[$MEM_AVAILPAGEFILE]/1024/1024, 2) & ' Gb', 551, 416, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C3_6 = GUICtrlCreateLabel(Round($aMemStats[$MEM_TOTALVIRTUAL]/1024/1024, 2) & ' Gb', 551, 472, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C3_7 = GUICtrlCreateLabel(Round($aMemStats[$MEM_AVAILVIRTUAL]/1024/1024, 2) & ' Gb', 551, 528, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_Server = GUICtrlCreateLabel($ServerName, 551, 600, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_Time = GUICtrlCreateLabel($currentTime , 71, 600, 180, $Hight, bitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") GUISetState(@SW_SHOWNORMAL) #EndRegion ### END Koda GUI section ### EndFunc While 1 Sleep(1000) ; sets a delay of 1 sec per 1000 WEnd ;; close down the Application func Terminate() exit EndFunc ;; Updating Time func UpdateTime() $currentTime = @HOUR&":"& @MIN &":"& @SEC ControlSetText($Form1,"",$Label_Time, $currentTime) EndFunc ;; currently changing the CPU % lable Func Warning() if $aMemStats[$MEM_LOAD] <=40 Then ; Green GUICtrlSetbkColor($Label_C2_1,0x2BFC0B) ElseIf $aMemStats[$MEM_LOAD] >40 and $aMemStats[$MEM_LOAD] <= 80 Then GUICtrlSetbkColor($Label_C2_1,0xFDBE01) Elseif $aMemStats[$MEM_LOAD] > 80 Then GUICtrlSetBkColor($Label_C2_1, 0xEE0C0C) EndIf EndFunc ;; Updating The Lable values of column 2 Only if the values change func updateValues() $aMemStats = MemGetStats() if GUICtrlRead($Label_C2_1) <> $aMemStats[$MEM_LOAD] Then ControlSetText($Form1,"",$Label_C2_1,$aMemStats[$MEM_LOAD]) endif If GUICtrlRead($Label_C2_2) <> $aMemStats[$MEM_TOTALPHYSRAM] & ' Kb' then ControlSetText($Form1,"",$Label_C2_2,$aMemStats[$MEM_TOTALPHYSRAM] & ' Kb') endif If GUICtrlRead($Label_C2_3) <> $aMemStats[$MEM_AVAILPHYSRAM] & ' Kb' then ControlSetText($Form1,"",$Label_C2_3,$aMemStats[$MEM_AVAILPHYSRAM] & ' Kb') endif If GUICtrlRead($Label_C2_4) <> $aMemStats[$MEM_TOTALPAGEFILE] & ' Kb' then ControlSetText($Form1,"",$Label_C2_4,$aMemStats[$MEM_TOTALPAGEFILE] & ' Kb') endif If GUICtrlRead($Label_C2_5) <> $aMemStats[$MEM_AVAILPAGEFILE] & ' Kb' then ControlSetText($Form1,"",$Label_C2_5,$aMemStats[$MEM_AVAILPAGEFILE] & ' Kb') endif If GUICtrlRead($Label_C2_6) <> $aMemStats[$MEM_TOTALVIRTUAL] & ' Kb' then ControlSetText($Form1,"",$Label_C2_6,$aMemStats[$MEM_TOTALVIRTUAL] & ' Kb') endif If GUICtrlRead($Label_C2_7) <> $aMemStats[$MEM_AVAILVIRTUAL] & ' Kb' then ControlSetText($Form1,"",$Label_C2_7,$aMemStats[$MEM_AVAILVIRTUAL] & ' Kb') endif EndFunc  
    • By Colduction
      Hi guys!, recently i needed to measure two functions and detect fastest one then i decided to write and share this tiny script for compare, measure and detect fastest functions easily.

      It's such as snippets, i hope you find it useful :)❤
       
      #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include-once ; #FUNCTION# ==================================================================================================================== ; Name...........: _FuncSpeedComparator ; Description ...: Compares and measures speed of two functions and shows fastest one. ; Syntax.........: _FuncSpeedComparator($s1stFunc, $s2ndFunc [,$iCallNum, $iResultType]) ; Parameters ....: $s1stFunc - First function that should be compared and measured ; $s2ndFunc - Second function that should be compared and measured ; $iCallNum - [Optional] Number of times function should be called ; Default value is 100 ; $iResultType - [Optional] Type of output must be one of the following numbers: ; 1 ; Results will written in AutoIt Console Output ; 2 ; Results will be as a Message Box ; 3 ; Results will written in AutoIt Console Output and then shows as a Message Box ; Default value is 1 ; Return values .: Success - Returns string ; Failure - Returns False or empty string ; Author ........: Colduction (Ho3ein) ; Modified.......: ; Remarks .......: Function names should be written as string (inside of two Double Quotation or Quotation) to be executed and be measured ; Example .......; _FuncSpeedComparator('ConsoleWrite("10101010101")', 'ConsoleWrite("Hello World!")', 500, 3) ; =============================================================================================================================== Func _FuncSpeedComparator($s1stFunc = "", $s2ndFunc = "", $iCallNum = 100, $iResultType = 1) If Not StringRegExp($s1stFunc, "^[a-zA-Z0-9_]+\x28(.*?)\x29$") Or Not StringRegExp($s2ndFunc, "^[a-zA-Z0-9_]+\x28(.*?)\x29$") Or Not StringRegExp($iCallNum, "^\p{Nd}*$") Or Not StringRegExp($iResultType, "^\p{Nd}*$") Then ; Human mistake preventative stage. Return False Else ; Measure stage. ;; First function measurement. Local $hTimer_1stFunc = TimerInit() For $i = 1 To $iCallNum Execute($s1stFunc) Next Local $iDiff_1stFunc = TimerDiff($hTimer_1stFunc) ;; Second function measurement. Local $hTimer_2ndFunc = TimerInit() For $i = 1 To $iCallNum Execute($s2ndFunc) Next Local $iDiff_2ndFunc = TimerDiff($hTimer_2ndFunc) ; Fastest function detector stage. Local $sFastestFunc = "" If $iDiff_1stFunc = $iDiff_2ndFunc Then $sFastestFunc = "Both of them" ElseIf $iDiff_1stFunc < $iDiff_2ndFunc Then $sFastestFunc = StringRegExpReplace($s1stFunc, "(\x28).*", "") Else $sFastestFunc = StringRegExpReplace($s2ndFunc, "(\x28).*", "") EndIf ; Results stage. Local $sResultText = @CRLF & '#Fastest Function: "' & $sFastestFunc & '"' & @CRLF & @CRLF & '1) "' & StringRegExpReplace($s1stFunc, "(\x28).*", "") & '" time elapsed: (' & $iDiff_1stFunc & ") ms" & @CRLF & '2) "' & StringRegExpReplace($s2ndFunc, "(\x28).*", "") & '" time elapsed: ' & "(" & $iDiff_2ndFunc & ") ms" & @CRLF If $iResultType = 1 Or Not StringRegExp($iResultType, '^[1|2|3]{1}$') Then ; Output as ConsoleWrite. ConsoleWrite($sResultText) ElseIf $iResultType = 2 Then ; Output as MsgBox. MsgBox(64, "Result: " & $sFastestFunc, $sResultText) ElseIf $iResultType = 3 Then ; Output as both ConsoleWrite & MsgBox. ConsoleWrite($sResultText) MsgBox(64, "Result: " & $sFastestFunc, $sResultText) EndIf EndIf EndFunc ;==>_FuncSpeedComparator  
      _FuncSpeedComparator.au3
    • By PeterVerbeek
      This topic give you access to an AutoIt functions library I maintain which is called PAL, Peter's AutoIt Library. The latest version 1.20 contains 197 functions divided into these topics:
      window, desktop and monitor mouse and GUI GUI controls including graphical buttons (jpg, png) logics and mathematics include constants string, xml string and file string dialogues and progress bars data lists: lists, stacks, shift registers and key maps (a.ka. dictionaries) miscellaneous: logging/debugging, process and system info Change log and files section  on the PAL website (SourceForge).
      A lot of these functions were created in the development of Peace, Peter's Equalizer APO Configuration Extension, which is a user interface for the system-wide audio driver called Equalizer APO.
    • By jantograaf
      Hi all,
      I've been looking around the forum and testing different ways of getting a 'drop zone' to work in my script, but I can't seem to get any response from the event listener. Code compiles perfectly. Chaning the control from a label to an input- or edit-field doesn't change its behaviour, still no response when a file is dropped on there...
      It might just be that I am overlooking a simple detail, so I'm hoping for an extra pair of eyes here or there who can spot why this isn't working as it should. 
      I have another 3500+ lines script where I have basically the same bit of code, and it seems to work in there without problems.
      So, here it goes:
      Global $DD_GUI = GUICreate("DicomDrop",200,200,-1,-1,BitOR($WS_SYSMENU,$WS_POPUP),$WS_EX_ACCEPTFILES) GUISetBkColor(0x030303,$DD_GUI) $DD_GUI_DRAGLABEL = GUICtrlCreateLabel("",0,0,32,32,-1, $GUI_WS_EX_PARENTDRAG) $DD_GUI_DRAGIMAGE = GUICtrlCreateIcon(@ScriptFullPath,201,0,0,32,32) $DD_GUI_TITLELABEL = GUICtrlCreateLabel("DicomDrop",50,10,100,20,$SS_CENTER) GUICtrlSetFont($DD_GUI_TITLELABEL,8,$FW_SEMIBOLD,$GUI_FONTNORMAL,"Verdana") GUICtrlSetColor($DD_GUI_TITLELABEL,0xFFFFFF) $DD_GUI_CLOSE = GUICtrlCreateButton("X",174,4,24,24,$BS_FLAT) GUICtrlSetBkColor($DD_GUI_CLOSE,0x030303) GUICtrlSetColor($DD_GUI_CLOSE,0xFFFFFF) Global $DD_GUI_DROPZONE = GUICtrlCreateLabel("",10,42,180,148) GUICtrlSetState(-1,8) GUICtrlSetBkColor($DD_GUI_DROPZONE,0x181818) GUISetState(@SW_SHOW,$DD_GUI) Local $DD_MSG = 0 While 1 $DD_MSG = GUIGetMsg() Select Case $DD_MSG = $GUI_EVENT_CLOSE ConsoleWrite(@CRLF & "Debug -- Closed by GUI_EVENT_CLOSE") DD_EXIT() Case $DD_MSG = $GUI_EVENT_DROPPED If @GUI_DropId = $DD_GUI_DROPZONE Then Local $DroppedFile = @GUI_DragFile GUIDelete() ConsoleWrite(@CRLF & "Debug -- Dropped file : " & $DroppedFile) EndIf Case $DD_MSG = $DD_GUI_CLOSE ConsoleWrite(@CRLF & "Debug -- Closed by DD_GUI_CLOSEIMAGE") DD_EXIT() EndSelect WEnd Func DD_EXIT() GUIDelete($DD_GUI) Exit EndFunc If anyone has any idea whatsoever, please let me know 🙂
      Thanks in advance and kind regards,
      Jan
×
×
  • Create New...