Search the Community

Showing results for tags 'functions'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Chat
    • 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

Categories

  • Forum
  • AutoIt

Calendars

  • Community Calendar

Found 17 results

  1. 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?
  2. 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.
  3. 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
  4. 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.
  5. 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
  6. 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!
  7. 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
  8. 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
  9. 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
  10. 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!
  11. 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
  12. 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?
  13. 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
  14. 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.
  15. Is it possible to run or call two separate functions simultaneously? If it is then any sample? THANKS.
  16. 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
  17. 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: