Sign in to follow this  
Followers 0
NiceBoy1234

Chain functions

19 posts in this topic

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?

Share this post


Link to post
Share on other sites



NiceBoy1234,

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

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


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

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

Share this post


Link to post
Share on other sites

I have several functions with different while loops.
I would like to call them seperate or together, the code above was just a sample

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
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.

1 person likes this

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

Share this post


Link to post
Share on other sites

Ty for the reply I delete that line a check it give me a minute

Share this post


Link to post
Share on other sites

Thanks that was one issue now following functions do work:
disableTaskbar()
searchForDrives()
startApplicationConstantly

just the function hiddenShortcut remains and does not work

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

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

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

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

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

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

Share this post


Link to post
Share on other sites

Hey, it was only matter of a code which works or not, even if the combo is awful indeed  :D

1 person likes this

Share this post


Link to post
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()

 


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

hiddenShortcut() function does not work anymore strange:(

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

does this have to have excatly this name ?

user32.dll

Thus the window which I create with the shortcut does have same classname as the error window

Edited by NiceBoy1234

Share this post


Link to post
Share on other sites

My While Loop looks like this now:
 

...
Local $hDLL = DllOpen("user32.dll")

While 1

    ableTaskbar()
    hiddenShortcut()
    searchForDrives()
    startApplicationConstantly()
    
WEnd

DllClose($hDLL)
...

 

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
Sign in to follow this  
Followers 0

  • Similar Content

    • Patryk
      By Patryk
      Dear Colleagues,
      I have no idea how to refer to style.display in my loop. There is a button like: 
      <input name="ctl00$bodyPlaceholder$btnFecharProcessamento" class="button" id="bodyPlaceholder_btnFecharProcessamento" style="display: none;" onclick="FecharJanelaProcessamento();return false;" type="submit" value="Fechar"> I want it to be clicked as soon as button's style change from style="display: none;" to  style= ="display: inline-block;" 
      This is what I got, but it's not working...
      Func GetButtons() $oButtons = _IEGetObjByName($oForm,"ctl00$bodyPlaceholder$btnFecharProcessamento",-1) $i = 0 While $i <> 1 For $oBtn In $oButtons If _IEFormElementGetValue($oBtn) = "Fechar" And $oBtn.document.style.display = "display: inline-block;" Then $i = 1 _IEAction($oBtn, "focus") _IEAction($oBtn, "click") ExitLoop EndIf Next WEnd EndFunc  
      I will really appreciate if you could help me with these loop!
    • mati
      By mati
      Hi,
      I wonder if
      AutoIt3Wrapper_run_debug_mode = Y can include run information about functions which are called within the main code. So far I noticed in the console that the function itself is called but no specific run information from  inside the function is provided. Is there a chance to show the entire debug log including functions in the console?
      I furthermore noticed a stop of information when a loop is entered. What could be the reason for that?
       
      Thanks for help.
    • Nareshm
      By Nareshm
      How to repeat my script when my control class does not match ?
       
      My Script : winActivate ( " PS :: Version - 2.2.0.0  - [PS Bill]")                   ControlClick ( "PS :: Version - 2.2.0.0  - [PS Bill]", "", "[NAME:btnSavebyFP]")                   ControlSend(" PS :: Version - 2.2.0.0  - [PS Bill]", "", "[NAME:btnSavebyFP]", "{enter}")                   WinActive ("Verification Number Entry ::")                   ControlClick("Next >", "","[NAME:btnNext]") ;if   >>>> Control <<<<  does not match repeat my script, ;if match exit script  

      Class:    WindowsForm734a
      Instance:    15
      ClassnameNN:    WindowsForm34a15
      Name:    BillPrint
      Advanced (Class):    [NAME:BillPrint]
      ID:    7875
      Text:    
      Position:    39, 310
      Size:    1221, 306
      ControlClick Coords:    745, 20
      Style:    0x56010000
      ExStyle:    0x00000000
      Handle:    0x00000000000C0468
    • SkysLastChance
      By SkysLastChance
      I am not sure why I am getting the this error on my second pass of the code.
      1 - $oWorkbook is not an object or not a workbook object
      Any help or advice on my code appreciated. 
      #include <Excel.au3> #include <Array.au3> #include <MsgBoxConstants.au3> Global $sExcelFile1 = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsm)") Global $sExcelFile2 = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "Excel Sheet (*.xlsx;*.xls)|All (*.*)") Global $vRow = 2 If FileExists($sExcelFile2) Then Global $oExcel2 = _Excel_Open () $oExcel2 = _Excel_BookOpen($oExcel2,$sExcelFile2) EndIF If FileExists($sExcelFile1) Then Global $oExcel1 = _Excel_Open () $oExcel1 = _Excel_BookOpen($oExcel1,$sExcelFile1,Default,Default,"2007") EndIF $oRead = _Excel_RangeRead ($oExcel2,"Untitled","A2",3) $oFind = _Excel_RangeFind ($oExcel1,$oRead,"E4:FD92",Default,$xlWhole) $Clip = _ArrayToClip($oFind,"",0,0,"",2,2) Send("{ScrollLock Off}") $hWnd = WinWait("[CLASS:XLMAIN]") ControlSend($hWnd, "", "", ("^g")) WinWait("[CLASS:bosa_sdm_XL9]") ; Go To ControlSend($hWnd, "", "", ("^v")) ControlSend($hWnd, "", "", ("{Enter}")) ControlSend($hWnD, "", "", "{Down " & $vRow & "}") Do $oTime = _Excel_RangeRead ($oExcel2,"Untitled","B2",3) If @error Then Exit MsgBox(0, "Error", "Error" & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox(0,"Test",$oTime) IF $oTime = "7:10:00 AM" Then $oCalls1 = _Excel_RangeRead ($oExcel2,Default,"C" & $vRow,3) $oCalls2 = _Excel_RangeRead ($oExcel2,Default,"D" & $vRow,3) ControlSend($hWnd, "", "", $oCalls1) ControlSend($hWnd, "", "", ("{RIGHT}")) ControlSend($hWnd, "", "", $oCalls2) $vRow = $vRow + 1 ContinueLoop Else $vRow = $vRow + 1 EndIf Until $vRow = 4 1.xlsm
      2.xlsx
    • TrashBoat
      By TrashBoat
      Is this possible:
      Executing a function from an include, but taking the function name from a gui input and then executing that function using the include:
      #include <Something.au3> ;input reads "Tree" $functionName = GuiCtrlRead($input1) $functionName(1) And the include is gonna have
      Func Tree($x) If $x = 1 Then $this = "text" MsgBox(0,$this,"whatever") EndFunc is it possible?