Jump to content

Chain functions


Recommended Posts

I got these function but somehow only the first one gets called.

 

test01()
test02()
test03()
test04()
test05()

Func test01()

    While 1
        ConsoleWrite("01")
    WEnd
    
EndFunc

Func test02()

    While 1
        ConsoleWrite("02")
    WEnd
    
EndFunc

Func test03()

    While 1
        ConsoleWrite("03")
    WEnd
    
EndFunc

Func test04()

    While 1
        ConsoleWrite("04")
    WEnd
    
EndFunc

Is there a way to accomplish this this way?

Link to comment
Share on other sites

  • Moderators

NiceBoy1234,

Of course only the first is called - how do you expect to escape the While...WEnd loop within it?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Also, what are you trying to accomplish, what is your end game?

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • Moderators

NiceBoy1234,

If you want the chained functions to repeat indefinitely then you could do something like this:

While 
    test01()
    test02()
    test03()
    test04()
WEnd



Func test01()
    ConsoleWrite("01")
EndFunc



Func test02()
    ConsoleWrite("02")
EndFunc



Func test03()
    ConsoleWrite("03")
EndFunc



Func test04()
    ConsoleWrite("04")
EndFunc

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hmm that sample worked, I think I have probably something wrong in my code could you have a look please=)

 

#include <AutoItConstants.au3>
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <FileConstants.au3>

Local $sPath = "C:\Program Files (x86)\xxx\xxx.exe";
Local $bFpExists = False;
Local $aDrives   = DriveGetDrive($DT_REMOVABLE) ; usbs
Local $sUsername = "xxx"
Local $sPassword = "xxx"
Local $sLockdown = "C:\Users\xxx\Desktop\xxx.exe"

While 1

   disableTaskbar()
   hiddenShortcut()
   
   searchForDrives()
   startApplicationConstantly()

WEnd

Func startApplicationConstantly()

   
  Local $bxxfExe = RunWait("C:\Users\xxx\xxx\xxx\xxx.exe")

  If WinExists("[CLASS:#32770]") Then
     ProcessWaitClose("C:\Users\xxx\xxx\xxx\xxx.exe")
  EndIf
 
EndFunc

Func searchForDrives()

  If @error Then
     ConsoleWrite("error.")
  Else
     For $i = 1 To $aDrives[0]
        ConsoleWrite(StringUpper($aDrives[$i]) & "Drive " & $i & "/" & $aDrives[0] & @CRLF)
        ConsoleWrite($aDrives[$i])
        If($aDrives[$i] == "f:") Then
           DirCopy("F:\xxx\xxx", "C:\Users\xxx\Desktop\CC", $FC_OVERWRITE)
           Sleep(10000)
        Else
           ConsoleWrite("couldnt find f drive")
        EndIf
     Next
  EndIf

EndFunc

Func hiddenShortcut()

  If _IsPressed("43") And _IsPressed("59") And _IsPressed("58") Then
     While _IsPressed("43") And _IsPressed("59") And _IsPressed("58")
        Sleep(250)
     WEnd
     Local $sAnswer = InputBox("Password", "Password to unlock", "put pw", "", 0, 0, 0, 0)
     If($sAnswer == $sPassword) Then
        ShellExecute($sLockdown)
        ableTaskbar()
     Else
        ConsoleWrite("wrong pw" & @CRLF)
     EndIf
     If ProcessExists("Lockdown.exe") Then
        ConsoleWrite("xxx.exe exist" & @CRLF)
     Else
        ConsoleWrite("xxx.exe does not exist" & @CRLF)
     EndIf
  EndIf
  Sleep(250)

EndFunc

Func disableTaskbar()

   Opt('WINTITLEMATCHMODE', 4)
   ControlHide('classname=Shell_TrayWnd', '', '')

EndFunc

Func ableTaskbar()

   Opt('WINTITLEMATCHMODE', 4)
   ControlShow('classname=Shell_TrayWnd', '', '')

EndFunc

I used for privacy issues the letter X a few times

Edited by NiceBoy1234
Link to comment
Share on other sites

Your WinExists might get stuck because there might be a dozen windows using that class open, then the code will wait until you close the program and not do anything else as long as it is still running.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

That is a really weird key combination to have held down all at once - c + x + y

Open Notepad, and attempt to do that combo, and you will find that only one key repeats, so the combo will never may not work.

If you are going to repeat _IsPressed you should be using the DllOpen method as per the Example anyway.

https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm

However, your key combo will never may not work and so your code in that function will may never happen.

 

Edited by Santa
I may have learnt something

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Hmmm sorry Santa  :)
However I agree with DllOpen

#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")
$n = 0
 While 1
 If _IsPressed("43", $hDLL) And _IsPressed("59", $hDLL) And _IsPressed("58", $hDLL) Then
     While _IsPressed("43", $hDLL) And _IsPressed("59", $hDLL) And _IsPressed("58", $hDLL)
        Sleep(10)
    WEnd
    $n += 1
        Tooltip("test " &  $n, 0, 0)
        ConsoleWrite("test " &  $n & @CRLF)
 EndIf
 Wend
DllClose($hDLL)

 

Edited by mikell
Link to comment
Share on other sites

Well if that works, then I have learnt something new. :D

Other than the Notepad method, I had no AutoIt facility to try the combo, so I went for what seemed obvious ... no doubt a mistake. Still seems like an awful combo to me anyway ... I'd throw in a CTRL and or SHIFT and just use one letter ... if that.

Edited by Santa

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Just to make it clear, you can't do this with native AutoIt functions, because that's what "chaining" functions means.

Function Example1()
    Return "First"
EndFunc

Function Example2()
    Return "Second"
EndFunc

Example1().Example2()

 

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Dll seemed to solved the problem, it works now thanks.
I got one more little question, since I deleted the WinExists Method, what would be a better way to close the windows error window like "program does not work wait or close".
I tried to check with WinExists if that windows appears to close it immediately.

Edited by NiceBoy1234
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

×
×
  • Create New...