Jump to content

Search the Community

Showing results for tags 'Functions'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 24 results

  1. I plan to write an Au3 script to automatically install a PPT plug-in. Because the button on the installation wizard of the PPT plug-in is not a standard control, I consider writing a while loop to constantly judge the color of a specific location on the installation wizard. When the plug-in is successfully installed, a blue "Start Software" button will appear at this location, so that I can let the script close the installation wizard window. But when I used the PixelGetColor function, the script did not get the color of the button on the installation wizard. On the contrary, it went through this foreground window and got the color of my desktop background! However, Au3's window information tool can correctly return the color of this position. The following is my script code (due to different configurations, some coordinates may need to be changed when testing on other devices): ;~ Run plug-in installation package #RequireAdmin run(@ScriptDir & "\FocoSlide.exe") ;~ In each installation, the number behind this class is different, so you need to use wildcards to match the window. $tittle = "[REGEXPCLASS:HwndWrapper*]" WinWait($tittle) ;~ Change the installation path WinActivate($tittle) Send("+{TAB}") Send("+{TAB}") Send("+{END}") Send("{DELETE}") ControlSend($tittle, "", "", "C:\Program Files (x86)\OfficePlugins\Foco") ;~ Switch focus to "Install" button and enter to confirm Send("+{TAB}") Send("{ENTER}") $wh = WinGetHandle($tittle) ;~ Wait for the "Start Software" button to appear (installation is complete) ;~ Activate the window before each color acquisition to avoid potential errors. WinActivate($tittle) $s = PixelGetColor(763, 533, $wh) ConsoleWrite("color is " & Hex($s, 6) & @CR) While Hex($s) <> "0267EC" Sleep(3000) $s = PixelGetColor(763, 533, $wh) ConsoleWrite("color is " & Hex($s, 6) & @CR) WinActivate($tittle) WEnd ;~ When the blue Start Software button is detected, the installation is completed and the installation wizard is closed. MouseClick("left", 1043, 350) Exit Au3 version: 3.3.16.1 Operating system: Win11
  2. I was having problems with dates so I copied the example for _DateAdd from the docs, and THAT wouldn't compile. Am I missing a library or something?
  3. I'm using Python to call AutoIt functions, but some functions don't work. Is there a reason for this? If so, can I fix it? from win32com.client import Dispatch Auto = Dispatch("AutoItX3.Control") def autoTest(): print Auto.MsgBox('') When I run it I get this error: line 516, in __getattr__ raise AttributeError("%s.%s" % (self._username_, attr)) AttributeError: AutoItX3.Control.MsgBox It seems like it's reading 'MsgBox' as an attribute and not a function. Any thoughts?
  4. 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
  5. 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
  6. I got a question: i am trying to run different functions based upon what i select in these radio buttons.(code below) it needs to check server 1. then run function 1 or function 2 after what i selected in the checkbox. once that function is done it moves to the next one, until it has been trough all 5 iv'e tried using while loops with different while $i equals to something but then i manualy need to go in and edit the script every time. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $Server2 = GUICtrlCreateLabel("Server2", 216, 95, 41, 17) $server1 = GUICtrlCreateLabel("Server1", 216, 72, 41, 17) $server4 = GUICtrlCreateLabel("Server4", 216, 144, 41, 17) $server3 = GUICtrlCreateLabel("Server3", 216, 119, 41, 17) $server5 = GUICtrlCreateLabel("Server5", 216, 170, 41, 17) $Start = GUICtrlCreateButton("Start", 240, 248, 147, 25) $Checkbox1 = GUICtrlCreateCheckbox("function1", 288, 72, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("function2", 392, 72, 97, 17) $Checkbox3 = GUICtrlCreateCheckbox("function1", 288, 96, 97, 17) $Checkbox4 = GUICtrlCreateCheckbox("function2", 392, 96, 97, 17) $Checkbox5 = GUICtrlCreateCheckbox("function1", 288, 120, 97, 17) $Checkbox6 = GUICtrlCreateCheckbox("function2", 392, 120, 97, 17) $Checkbox7 = GUICtrlCreateCheckbox("function1", 288, 144, 97, 17) $Checkbox8 = GUICtrlCreateCheckbox("function2", 392, 144, 97, 17) $Checkbox9 = GUICtrlCreateCheckbox("function1", 288, 170, 97, 17) $Checkbox10 = GUICtrlCreateCheckbox("function2", 392, 170, 97, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
  7. Maybe I am trying this all wrong, but hope someone can help. I have a GUI and want to click a button which will start a function to get a folder location. Then I need to pass that location to a variable to use outside the function. Here is a sample of the code;It prompts to choose a file location and the message box displays the choice but that is all inside the function. I need to pass the path selected outside the function. OR need a different way of doing this, maybe my approach is wrong. $Label_Drive=GUICtrlCreateLabel("Use the select button and choose where profiles will be stored.", 15, 120, 240, 25) $BTN_Set_BKP_Path = GUICtrlCreateButton("Select Location", 250, 120, 90, 30) ;left,top,width,heigth GUICtrlSetOnEvent($BTN_Set_BKP_Path, "Location") Func Location() $BKP_Path = FileSelectFolder("Select a folder where profiles will be stored.", "c:\") MsgBox(0,"Select Path", "You set the path as " & $BKP_Path) EndFunc $Label_BKP_Path=GUICtrlCreateLabel("Current path is " & $BKP_Path & ".", 15, 150, 300, 25)
  8. As with a lot of programming, the less manual repetition done to achieve the same outcome...the better. I package programs for network deployment at the organization I work for. Sometimes these applications require verbose messaging to the user, and sometimes by special request we have to turn that off and deploy silently. The way I currently handle these 2 scenarios is this. I have a function that builds the splashwin display screen to variable size depending on message length, and displays the desired message to the end user. Then at each point throughout my script as I need to make the user aware of what is currently happening, I inject a splashwin function call with the unique message pertaining to that specific event. ie. "Installing Microsoft Office, please wait..." In effort to build a more universal script to handle any type of request submitted. I've incorporated a switch command of '/silent' If cmdlineraw detects the usage of that switch when the script is triggered it sets a variable flag, ie. $silent = "on" Then at every splashwin call I make, I'm prefixing it with an IF statement that checks for the flag, and then does NOT display the message if that flag is "on". Or does display it if its not. Has worked for me just fine. But while I grow my programming skills and look for more streamlined ways of handling areas I find myself creating repetition. I'm curious if I can relocate that flag check. Taking it out of every single splashwin call, and injecting it into the function itself. Example of how I currently display or hide the splashwin based on command line... If StringInStr($cmdlineraw, "/silent", 0) Then $SilentSwitch = "ON" EndIf If $SilentSwitch = "OFF" Then SplashWin($Uninstalling & $ProductInfo[1][0]) Some scripts have dozens of those splashwin calls littered throughout, so Is this the best approach I can take already? Or as stated earlier, can I pull the IF statement away from the splashwin call. And left the function as a whole either activate or deactivate as a result of the command line check.
  9. Edit: Just realised this was posted in the wrong forum! I guess the Mods will move it to either "AutoIt General Help and Support" or "AutoIt Technical Discussion". Do you use type checking? Or do you choose not to type check? I was trying to think of the simplest way to do a type check without typing arguments more than once and I came up with: Func displayPerson($firstName, $lastName, $age) ; -- TYPE CHECK -- Local $typeCheck = ("" _ & IsString($firstName) _ & IsString($lastName) _ & IsNumber($age) _ ) If (StringInStr($typeCheck, "0")) Then MsgBox(16, "Type Error: displayPerson()", $typeCheck) ; -- FUNCTION -- MsgBox(0, "", $firstName & " " & $lastName & " (" & $age & ")") EndFunc The only catch with this method is that it produces a very simplistic error message. Even still, the fact that you only have to type out arguments once makes it a reasonable approach, in my opinion. The same logic can also be used for making function contracts (for example: $firstName mustn't be an empty string etc...). What do you think? How do you go about such things?
  10. I am trying to allow the GUI to gather info as to when to execute a function. I am having trouble doing this. So far this is what I have. ;Timer Func timer () If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(36,"Timer","Please format your answer in 00:00:00:000") Select Case $iMsgBoxAnswer = 6 ;Yes Global $infotime = InputBox ('Time', 'What time to execute?') Do $rawtimer = ToolTip(@Hour & ':' & @Min & ':' & @Sec & ':' & _MSec()) until $rawtimer = $infotime if $rawtimer = $infotime Then msgbox (0,'Worked','Worked') Else EndIf Case $iMsgBoxAnswer = 7 ;No Exit EndSelect EndFunc Func _MSec() Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort') DllCall('kernel32.dll', 'none', 'GetSystemTime', 'ptr', DllStructGetPtr($stSystemTime)) $sMilliSeconds = StringFormat('%03d', DllStructGetData($stSystemTime, 8)) $stSystemTime = 0 Return $sMilliSeconds EndFunc I have also tried _GUIToolTip_GetText in order to read the tooltip until the time specified, but it still doesn't work. Any help would be great.
  11. im some what new to autoit and need help figuring out best way to make a simple clicker for few idle games i play(taptitdue, sakura clicker, elndless frontier etc.) ive played around with autoit recorder to make simple copy mouse clicks. but now i want to make a script that allows me to select multiple functions before starting the script for game ex: click section A or click section A + B to run At set intervals if that makes sense . i dont need scripts made by other just info on what things i should use to make it my self. need to be able to select between games and be able to select multiple functions to run inconjuntion or independent for each game. thank you in advance
  12. Hi guys. I am trying to make a soundboard app. Here is the code I have so far #include "Misc.au3" #RequireAdmin;needed to work in some games. #include "array.au3" Opt("WinTitleMatchMode", -2) If @OSArch = "x64" Then Global $VLC_Path = "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" Global $VLC_WorkingDir = "C:\Program Files (x86)\VideoLAN\VLC\" Else Global $VLC_Path = "C:\Program Files\VideoLAN\VLC\vlc.exe" Global $VLC_WorkingDir = "C:\Program Files\VideoLAN\VLC\" EndIf Global $sectionData = IniReadSectionNames(@ScriptDir & "\SoundBoard.ini") If @error Then IniWriteSection(@ScriptDir & "\SoundBoard.ini", "Sound1", 'File="' & @UserProfileDir & '\Music\SampleTrack.mp3"' & @CRLF & 'StartTime="12"' & @CRLF & 'EndTime="34"' & @CRLF & 'PlaybackDevice="Microsoft Soundmapper"' & @CRLF & 'Hotkey="+{numpad9}"') MsgBox(16, "SoundBoard", "SoundBoard.ini is missing. It has been created for you.") ShellExecute(@ScriptDir & "\SoundBoard.ini", "", "", "edit") InputBox("SoundBoard", "Notes:" & @CRLF & "StartTime and EndTime are in seconds. Available Hotkeys can be found at the following url:", "https://www.autoitscript.com/autoit3/docs/functions/Send.htm") Exit EndIf For $i = 1 To $sectionData[0] Local $iArray = IniReadSection(@ScriptDir & "\SoundBoard.ini", $sectionData[$i]) For $j = 1 To UBound($iArray) - 1 Local $result = Assign("SoundBoard" & $i & "_" & $j, IniRead(@ScriptDir & "\SoundBoard.ini", $sectionData[$i], $iArray[$j][0], $iArray[$j][1]), 2) If $result = 1 Then Consolewrite("Variable Assigned: SoundBoard" & $i & "_" & $j & @CRLF & "Data=" & $iArray[$j][1]&@CRLF) Else Consolewrite("Variable was not assigned: SoundBoard" & $i & "_" & $j & @CRLF & "Data=" & $iArray[$j][1]&@CRLF) EndIf Next Next For $i = 1 To $sectionData[0] Local $Hotkey = Eval("SoundBoard"&$i&"_5") ConsoleWrite("Processing Hotkey "&$Hotkey&@CRLF) ;NEED HELP HERE ; HotKeySet($Hotkey,"") Next While 1 Sleep(500);idle to prevent unnecessary work. 10 is the minimal we can set this value to. WEnd Func LoadVLC($iPlayFile, $iPlayFileStartTime, $iPlayFileEndTime, $iPlayAudioDevice = "Microsoft Soundmapper") ShellExecuteWait($VLC_Path, '--qt-start-minimized --play-and-exit --start-time="' & $iPlayFileStartTime & '" --stop-time="' & $iPlayFileEndTime & '" --aout=waveout --waveout-audio-device="' & $iPlayAudioDevice & '" "' & $iPlayFile & '"', $VLC_WorkingDir, "", @SW_HIDE) Beep(500, 200) EndFunc ;==>LoadVLC For example, I have a song called "MoonlightSonata.mp3" and I want to activate it with hotkey !{numpad9}. However, hotkeyset does not allow sending of flags so I cannot use LoadVLC as it is now. I need to create a function that stores the flags using the data from the earlier Inireads. Ik how to use the data but not how to create the function to store that data. I looked at IsFunc() second example but I do not understand. Sorry if I am not being clear on what I am trying to do. My brain is fried right now after trying various things for an hour. Any help would be appreciated. The idea is to be able to have a dedicated hotkey for each sound I want to play so I will need to have my script create a new function by itself using the data from the INI. hotkeyset("$hotkey1","MySoundBoard1") hotkeyset("$hotkey2","MySoundBoard2") func MySoundBoard1() LoadVLC("MoonlightSonata.mp3") ;the other flags are optional and will not be set for simplicity. endfunc func MySoundBoard1() LoadVLC("TheBananaSong.mp3") endfunc Honestly I don't care how it is done as long as I have a dedicated hotkey for each entry in my ini. An example of such an entry looks like [Sound1] File="C:\Users\BetaL\Music\SampleTrack1.mp3" StartTime="12" EndTime="34" PlaybackDevice="Microsoft Soundmapper" Hotkey="!{numpad8}" [Sound2] File="C:\Users\BetaL\Music\SampleTrack2.mp3" StartTime="24" EndTime="43" PlaybackDevice="Microsoft Soundmapper" Hotkey="!{numpad9}" Am I making any sense? Please let me know. Edit: Huge thanks to @Melba23 for the learning experience, his time, and help.
  13. i have the following snippet... now its working but i have it inside a function and want to be able to use $aThumb[$i] outside the function in the rest of the script, i tried return and keep getting this error "Invalid keyword at the start of this line.:" Global $iRows = UBound($a, $UBOUND_ROWS) Global $iCols = UBound($a, $UBOUND_COLUMNS) $oID = $oID + 1 $oURL = $oString.selectSingleNode("./url") $oName = $oString.selectSingleNode("./name") $oCategory = $oString.selectSingleNode("./category") $oThumb = $oString.selectSingleNode("./image") $oLanguage = $oString.selectSingleNode("./language") $aThumb = [$iRows] _ArrayAdd($aThumb, $oThumb.text) For $i = 1 To UBound($aThumb) - 1 ConsoleWrite($oID & @TAB & $aThumb[$i] & @CRLF) Next Next ConsoleWrite( "rows: " & $iRows & @CRLF) Thanks for your help
  14. So, I'm trying to make this autoit script, and there's a function and stuff, but I can't write a function, inside a function! It's just not working. Like; Func Function_A($para1) Local $thing = 1 Func Function_B() ;Stuff here EndFunc If Function_B($thing) Then ;Stuff Else ;Stuff EndIf EndFunc ; Something like that.I'm either doing it wrong, or I can't do it in autoit. Anyway, help me please!
  15. This is a repost, since the thread was deleted due to database issues. - https://www.autoitscript.com/forum/topic/173518-thread-deleted/ Hello fellow geeks I am making a small program for work, a tool with shortcuts and host monitoring. The program has several tab and I need help with the tab called "Servers/Hosts" The tab reads hostnames or ip adresses from an ini file and writes them to a listview. You can add or remove hosts, ping, connect with mstsc and delete the whole list. Now... Im checking for ip adresses on start of the program, or with a refresh button - so far so good.. It´s working. I also have a function to check if a host is online and write it to the listview, but i cant make it work (im not good enough yet) - (ALMOST SOLVED - Writing a dummyhost e.g. "test" as hostname, gets the status "Online" - im currently working on that ) This check needs to run every 10 seconds or so, among with the check for ip adresses. But again, (im not good enough yet) - (SOLVED USING AdlibRegister) I´ve tried to put the functions in a loop in different places in the script. They either "block" the script or hide it. If i can get the loop to work, there is no need for a refresh button. and i want to put the foldercheck in the VIKING tab in a similar loop, displaying a warning instead of having to click a button. (but thats a different question) I hope one of you briliant minds can help me along the way:) Thank you for your time. Tobias IT-Tools.V13.au3 Servers.ini
  16. How would I go about adding the following to every function, after calling Tidy? Is it a hard process? I would want it to fill in: Name of the functionParameters Variable Names from the function, and put them in place - adding more parameter spaces as neededFill in the created date; #FUNCTION# ==================================================================================================================== ; Name ..........: $NameOfFunction ; Description ...: ; Syntax ........: ; Parameters ....: $Param_1 ; $Param_2 ; $Param_3 ; Return values .: ; Author ........: ; Created .......: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ===============================================================================================================================; Also, was wondering, how hard it would be to create another tool, as I seem to always want to see the values being sent to a function, maybe a HotKey (script) that can put a MessageBox box/ConsoleWrite at the top off all the functions (or at least the one high lighted? With the name of the function as title, and each parameter/variable in the header, put its name and value on separate lines. EDIT Or the syntax of a UDF - do not remember where that is, but will see if I can find it. EDIT 2 Found this, I assume it should be added, so when I find it, I guess I will https://www.autoitscript.com/wiki/Best_coding_practices
  17. Hey there, e.g. I have a gui with one button. If i click the button it should turn transparency on and if i click it again it should turn transaprenc off, but how do i do that? or another example: If i click the button first time it should msgbox: "1" and for the second time it should say: "2", and if i click a third time it should say again 1. I do not have any answer, so can you please make an example script? Thanks in advance, and sorry for my bad english, i am german
  18. Hello, First off I feel really stupid because I cannot grasp how to create the function that I want to make. Looking at the examples in the help file just confuse me more. I am trying to simply build a function that will either A: Encrypt a string and return the value or B: Decrypt a string and return the value. I have encryption and decryption working fine I just want to create a function to do the work because I will be doing a lot of encrypting and decrypting in my script. I am working on a TCP register/login/logoff script if anyone is wondering. Thanks!
  19. Hi everyone Learned a lot about programming languages and how they work the last days In my previous post I had a question about RPN calculators and how they evaluate unary symbols, now i have a question about the Shunting Yard algorithm The script I'll post here has 2 bugs in it, the firs one is a nasty small bug that i can't trace.. The last "push(pop(stack),queue)" call always pushes a "0" to the stack and I don't know why. edit: [gray text solved by JohnOne] The second problem: I don't know if I did this right but I wanted to modify this algorithm to work with functions as well. here is the pseudo-code explanation that i followed: http://en.wikipedia.org/wiki/Shunting-yard_algorithm did I do this right? Because at the moment the algorithm allows wrong usage of "(" and ")" example: function((10,20,)30) is allowed but it is clearly not the right way to call a function.. #INCLUDE <ARRAY.AU3> FUNC MSG($WHAT) IF ISARRAY($WHAT) THEN MSGBOX(0,"ARRAY",_ARRAYTOSTRING($WHAT)) ELSE MSGBOX(64,"MESSAGE",$WHAT) ENDIF ENDFUNC FUNC PUSH($ITEM, BYREF $STACK) LOCAL $UBOUND = UBOUND($STACK) IF $UBOUND > 0 THEN REDIM $STACK[$UBOUND + 1] $STACK[$UBOUND] = $ITEM ELSE DIM $STACK[] = [$ITEM] ENDIF ENDFUNC FUNC PEEK($STACK) LOCAL $UBOUND = UBOUND($STACK) IF $UBOUND > 0 THEN RETURN $STACK[$UBOUND - 1] ENDIF ENDFUNC FUNC POP(BYREF $STACK) LOCAL $UBOUND = UBOUND($STACK) LOCAL $RETURN IF $UBOUND > 0 THEN $RETURN = $STACK[$UBOUND - 1] REDIM $STACK[$UBOUND - 1] ENDIF ENDFUNC FUNC STACKISEMPTY($STACK) IF UBOUND($STACK) > 0 THEN RETURN FALSE ELSE RETURN TRUE ENDIF ENDFUNC FUNC ASSOCIATIVITY($OPERATOR) IF $OPERATOR = "^" THEN RETURN "RIGHT" ELSE RETURN "LEFT" ENDIF ENDFUNC FUNC PRECEDENCE($OPERATOR) SWITCH $OPERATOR CASE "^" RETURN 3 CASE "*","/" RETURN 2 CASE ELSE RETURN 1 ENDSWITCH ENDFUNC FUNC ISOPERATOR($OPERATOR) RETURN STRINGINSTR("+-*/^",$OPERATOR) <> 0 ENDFUNC ;################################################################################################### FUNC SHUNTINGYARD($INPUT) Local $queue[0] Local $stack[0] Local $token, $operator_a, $operator_b For $token = 0 To UBound($input) - 1 Switch $input[$token] Case "(" push($input[$token], $stack) Case ")" While Not(peek($stack) = "(") push(pop($stack), $queue) If stackisempty($stack) Then msg("Can't find a matching ""("".") WEnd POP($stack) Case "," While Not(peek($stack) = "(") push(pop($stack), $queue) If stackisempty($stack) Then msg("Can't find a matching function ""("".") WEnd Case "+","-","*","/","^" $operator_a = $input[$token] While isoperator(peek($stack)) $operator_b = peek($stack) if (associativity($operator_b) = "LEFT" and precedence($operator_a) = precedence($operator_b)) or (precedence($operator_a) < precedence($operator_b)) then push(pop($stack), $queue) Else ExitLoop EndIf WEnd push($operator_a, $stack) Case "function" push("function", $stack) Case Else push($input[$token], $queue) EndSwitch Next for $itemcount = 0 to ubound($stack) - 1 if peek($stack) = "(" then msg("can't find a matching "")"".") push(pop($stack), $queue) next Return $queue ENDFUNC ;################################################################################################### GLOBAL $input = ["function","(","1",",","2",")"] msg($input) $shuntingYard = shuntingyard($input) msg($shuntingYard) ;################################################################################################### any help would be appreciated! TheAutomator
  20. Hello, I've been pondering this for a little bit and I sense there's something wrong, obviously. The error is reading it's being called by only 1 arg however there are two listed. Func getFiles($location, $file) GUICtrlSetData($Progress, $file) GUICtrlSetBkColor($Progress, 0xC67171) InetGet($URL & $location & $file, $mcd & $location & $file, 0, 0) GUICtrlSetBkColor($Progress, 0xFFFBF0) EndFunc Is being called by this: For $i = 1 To UBound($download) - 1 getFiles($dir[2], $download[$i]) ;<== line 188 Next Error returned: ERROR: getFiles() called by a previous line with 1 arg(s). Min = 2. First previous line calling this Func is 188. Func getFiles($location, $file) This cycles through each one using the 'getFiles' function using two args. My thoughts: improper function syntax
  21. Hi guys found this on a blog today and i was just wondering how this works as ive tried the example but i cant get it to work for myself ? Here is the blog entry http://www.sadeghi85.info/articles/using-php-functions-inside-autoit/#more-189 If anyone has any ideas or pointer id appreciate it.
  22. Is it possible to run or call two separate functions simultaneously? If it is then any sample? THANKS.
  23. Below is my script. Can you please tell me why I keep getting exit code 0, and the script stops? I'm expecting it to just idle in the background and await my hotkey pressing. Global $Paused HotKeySet("F7", "Cycle2") HotKeySet("F8", "Cycle1") HotKeySet("F9", "Cycle3") Func Cycle3() $Paused = NOT $Paused MouseClick("left", 920, 755, 1, 25) ;taskbar MouseClick("left", 776, 598, 1, 25) ;region MouseClick("left", 575, 565, 1, 25) ;pgdown MouseClickDrag("left", 325, 310, 500, 575, 25) Exit 0 EndFunc Func Cycle2() $Paused = NOT $Paused MouseClick("left", 920, 755, 1, 25) ;taskbar MouseClick("left", 776, 598, 1, 25) ;region MouseClick("left", 575, 565, 1, 25) ;pgdown MouseClick("left", 575, 310, 2, 25) ;up MouseClickDrag("left", 325, 310, 500, 575, 25) Global $Paused EndFunc Func Cycle1() $Paused = NOT $Paused MouseClick("left", 920, 755, 1, 25) ;taskbar MouseClick("left", 776, 598, 1, 25) ;region MouseClickDrag("left", 325, 310, 500, 575, 25) Local $i = 0 Do Sleep(2000) ;2-second sleep Cycle2() $i = $i + 1 Until $i = 7 Global $Paused EndFunc
  24. File + Process Imports/Exports Information UDFs Forwarder String Support, C++ Name Undecorating Added!! (Extreme case of string forwarding from wsock32.dll example in this post) This UDF gets Function Imports and Exports for any Windows PE file (.DLL, .EXE), both 32-bit and 64-bit (unlike most programs out there), and from either a 32-bit or 64-bit Process. I created this due to my frustration with other programs either working only *some* of the time, or having a common inability to read PE32+ (x64) file format tables properly. There's just two functions in the main UDF - _FileGetWinPEImports or _FileGetWinPEExports. The bundled TestImportExportsList program lets you explore files on your system. *Newly included are: _ProcessGetWinPEImports, _ProcessGetWinPEExports and TestProcessImportExportsList program (requires my Process Functions UDF). NOTE: *Compressed* executable files will only give the Import information for the 'decompressor'. The only way to get the compressed executable's Import information is to decompress the executable. Anyway, enjoy my hard work. Either read on for more information about some of the features, or see below for the License agreement and Download link. Information on 'Virtual Offset of Thunk': These address offsets you see are offsets from the base of the .DLL or .EXE file (uncompressed only!), where the actual function location of an 'Import' gets placed. All calls to these functions load addresses from these Thunk locations in order to correctly place a call to the right DLL function. (This is totally different than the old Import fixup location lists of earlier pre-NT systems). Technically, you could overwrite these Thunks with addresses to your own functions, but this is a dangerous thing to do. Its a neat tool to have though. Forwarder functions? An explanation: The whole 'DLLNAME.Functionname' string might be confusing to you, but here's an explanation of why an address can not and should not be returned. To better understand all this, grab a copy of DLL Export Viewer, (which doesn't report Relative/Function addresses correctly for Forwarded functions) and then follow along: *update: as of v1.50, DLL Export Viewer now reports forwarder string info (I was the one that reported the bug heh) Okay, open up DLL Export Viewer and look at (for this example) KERNEL32.DLL - lets pick 'HeapFree', a known Forwarded function. DLL Export Viewer reports the following (on XP SP3):Relative Address: 0x0000910c, 'Loaded' address: 0x7c80910c. *Neither* is the case, though - 0x0000910c is in fact just the virtual address of the forwarder string! Now, with my Exports function, you'll find that 'HeapFree' is reported (correctly) as a Forwarder string. What you'll see then is 'NTDLL.RtlFreeHeap'. What does that mean? It means that: HeapFree is not a part of KERNEL32.DLL (and hasn't been for a while),When that function is called or the address retrieved via 'GetProcAddress', the function 'RtlFreeHeap' in NTDLL.DLL is the function that's actually called (or returned as an address). Hopefully the 'DLLNAME.FunctionName' structure of a Forwarder string is starting to make sense now?The address you get when you do 'GetProcAddress' does *not* correspond to what you see in DLL Export Viewer - in fact, 'HeapFree's reported address lies entirely OUTSIDE of kernel32.dll's memory space - pointing instead inside of NTDLL.DLL, at (guess what?): RtlFreeHeap.So, on XP SP3, looking up 'HeapFree' with GetProcAddress, you get: 0x7C90FF2D. Doesn't match what was reported with DLL Export Viewer AT ALL. However - go back, and now look at NTDLL.DLL with DLL Export Viewer, and at function 'RtlFreeHeap' (following the logic of the Forwarder Function string). What is reported for RtlFreeHeap? Relative Address: 0x0000ff2d, 'Loaded' address: 0x7c90ff2d. See now how it lines up with what was reported via GetProcAddress for 'HeapFree' in KERNEL32.DLL? So, there you have it in a nutshell - Forwarder functions are functions 'rerouted' to another DLL. The DLL's that are being rerouted to are either: A.) Pre-loaded by the system (Important DLL's like NTDLL.DLL, KERNEL32.DLL, USER32.DLL, GDI32.DLL, etc - are all permanently loaded)B.) Loaded upon a program's execution if the function is in its 'Imports' list, orC.) Loaded upon a call to GetProcAddress. To see how this works clearly, list the modules that are loaded (my Process Functions UDF GUI can do this for you), then call GetProcAddress for 'GetServiceW' from WSOCK32.DLL, and then re-list the modules again. You'll see a new module loaded up - MSWSOCK.DLL (the location of the forwarder function). Wa-la, forwarder is set up.Ascend4nt's AutoIT Code License agreement:While I provide this source code freely, if you do use the code in your projects, all I ask is that: If you provide source, keep the header as I have put it, OR, if you expand it, then at least acknowledge me as the original author, and any other authors I creditIf the program is released, acknowledge me in your credits (it doesn't have to state which functions came from me, though again if the source is provided - see #1)The source on it's own (as opposed to part of a project) can not be posted unless a link to the page(s) where the code were retrieved from is provided and a message stating that the latest updates will be available on the page(s) linked to.Pieces of the code can however be discussed on the threads where Ascend4nt has posted the code without worrying about further linking. Download the ZIPs from my Site UPDATES:
×
×
  • Create New...