Jump to content

Calistoga

Active Members
  • Posts

    48
  • Joined

  • Last visited

Everything posted by Calistoga

  1. Add this at the beginning of the script Local $shops[3]; Edit: You won this time trance... but next time!
  2. Unfortunately you would have to extract the file from the exe, the FileInstall() function allows you to pack whatever you want with the exe, but before using those resources you would have to extract them to e.g. the @TempDir. It is actually possible to bundle files 100% without extracting them, that would however require a different approach. The downside of this is that you can not execute a .bat script when it's inside the exe. CMD would whine about not finding the file etc If cmd.exe was as cool as Autoit, you could imagine just loading the bat from the exe into the computer RAM, and from there just throw the memory at cmd.exe So to sum up, - Include the file in the script using FileInstall() - Compile - Run the script - Extract the file somewhere using the same FileInstall() - Do something with the file - Delete the file
  3. There is no need to use SFX archives. Look up the FileInstall() function in the help file. Using that, you can bundle all needed files inside the compiled script executable.
  4. I did not propose using a bat file because I personally despise temporary files. That is just me though, and to be pragmatic, it would solve this problem more or less. You could do something like this: (note that I have not tested this function, you might have to change something to satisfy the interpreter) #include <Process.au3> Func _CMD_RunScript() Local $s_batPath = @AppDataDir & \"adb.bat"; Where we want to extract the .bat If Not (FileInstall("adb.bat", $s_batPath, 1)) Then Return SetError(1, 0, False); Could not extract .bat _RunDOS($s_batPath); We'll let cmd.exe handle the .bat If (FileDelete($s_batPath)) Then Return SetError(0, 0, True); Everything OK Return SetError(2, 0, False); Unable to delete the .bat EndFunc
  5. I used _RunDOS() as the example here, but I see what you mean. I'm not sure if is was something like this you asked for, I'm a little slow in 'getting' things today Don't mind me using semicolons after every line, it's a habit I got from C# and now I can't stop doing it Include <Process.au3> Local $a_commands[3]; $a_commands[0] = "msg * Command 1"; $a_commands[1] = "msg * Command 2"; $a_commands[2] = "msg * Command 3"; ; This loop will iterate over every item in the array $a_commands. ; The currently evaluated item will always be $s_command. For $s_command In $a_commands _RunDOS($s_command); Next ; This loop works by incrementing $i by 1 every time the loop begins from the top and down. ; You can access the current element in the array by doing as shown below. ; E.g. $a_commands[1] will return the second element in this array. For $i = 0 To UBound($a_commands) _RunDOS($a_commands[$i]); Next I agree with you on the cmd window part. It sounds kind of ridiculous to in reality open 25 independent instances of cmd.exe just because we got tasks to do. But I'm not aware of any "nice and clean" way of doing it without using ControlSend() etc. I would love to know about one though I guess there is no really good reason for not using ControlSend() but I've personally always preferred to use API's etc. You know.
  6. Even though I do C# programming, automating GUI's in it is not my field of expertise. You might find some helpful insight here though. Eventually, if it doesn't bother you to use a DLL, you could use AutoItX which contains a lot of AutoIt methods It is included in your AutoIt install: C:\Program Files\AutoIt3\AutoItX
  7. Android is awesome indeed Are we talking HTC or something else? The _RunDOS() function will create and destroy a separate cmd.exe process for each task you request it to perform. If we look at the example I posted a little up, you could say it goes as follows: cmd.exe is launched.Command ("taskkill /f /im adb.exe /t") is processed by cmd.execmd.exe closes after the execution of the command finishes.Then the whole process repeats for the next command you use. I agree with you that this looks inefficient and maybe a little clumsy. The alternative though, is to do as you did in the first post: Create an instance of cmd.exeSend each command using ControlSend().I'm quoting the AutoIt help file: Taking this into consideration, I think i would prefer the _RunDOS() way of doing it. That is, as long as these functions are not running every minute or so if you see what I mean. It is not as efficient as we would wish, but it does the job. The example you mentioned, "cd c:\somefolder". Here you would eventually use another approach. Instead of interacting with cmd.exe, you would in this case use the AutoIt function FileChangeDir("c:\somefolder"). Just remember to change back to where you were originally if that is of importance for the execution of your program. However, even though I have been using AutoIt for some time now, there's still a lot I don't know about. I'm learning every day. So if someone else got a better idea I would love to learn about it.
  8. This code does the same as yours #include <Process.au3> _RunDOS("taskkill /f /im adb.exe /t") _RunDOS("taskkill /f /im cmd.exe /t") Android phone, eh?
  9. +H means that the attribute 'Hidden' will be applied to your file, - means that the attribute will be removed (visible again). The same logic goes for N. Note though, that if you use my functions then you do not need to apply these attributes as the file resides in a hidden directory specially designed for this kind of files. A regular user will never find it and start messing with it. Basically what the functions does, is: - Create the correct folder structure. - Create the file (config.dat which is a regular text file). - Return error values if something goes wrong. - Return and update the launch count value inside config.dat. I should have commented where i used SetError(), but when you see Return SetError(etc) used it means that the function will halt and a value will be stored inn the @error macro. This is to help you with troubleshooting what went wrong during the execution of the function. If you see SetError(3, 0, False), the first number will be stored in @error, the second in @extended and the last one will be returned directly from the function. When I'm at it, this function will reset the count to 0. @error will equal 1 if the function fails, the return value will then be False. @extended will equal 0 in all cases. Func _LaunchCount_ResetCount() Local $s_config = _LaunchCount_GetFile(); If Not (FileDelete($s_config)) Then Return SetError(1, 0, False); Return SetError(0, 0, True); EndFunc ;==>_LaunchCount_ResetCount I understand if you are confused now, so just ask if you got any questions
  10. I have created some functions for you. In _LaunchCount_GetFile() you need to replace NAME_OF_YOUR_APPLICATION_OR_GUID. I prefer using GUIDs but that may be just me. You can generate one here if you want. A GUID is unique and will ensure that no other application with the same name as yours will try to use your files. We will be using the Application Data folder of Windows. In Windows 7 this path would look like C:\Users\USERNAME\AppData\Roaming\OUR_FOLDER_WILL_BE_CREATED_HERE. The AppData folder is there for this exact purpose. MsgBox(64, "LaunchCount by Calistoga", _ "_LaunchCount_GetFile(): " & _LaunchCount_GetFile() & @CRLF & _ "_LaunchCount_GetCount(): " & _LaunchCount_GetCount() & @CRLF & _ "_LaunchCount_IncrementCount(): " & _LaunchCount_IncrementCount()); Exit; Func _LaunchCount_GetFile() Local $s_configDir = @AppDataDir & "\NAME_OF_YOUR_APPLICATION_OR_GUID"; Local $s_configFile = $s_configDir & "\config.dat"; If Not (FileExists($s_configDir)) Then If Not (DirCreate($s_configDir)) Then Return SetError(1, 0, ""); EndIf If Not (FileExists($s_configFile)) Then If Not (FileWrite($s_configFile, "")) Then Return SetError(2, 0, ""); EndIf Return SetError(0, 0, $s_configFile); EndFunc ;==>_LaunchCount_GetFile Func _LaunchCount_GetCount() Local $s_config = _LaunchCount_GetFile(); If ($s_config = "") Then Return SetError(1, 0, 0); Local $s_content = FileRead($s_config); If (@error = -1 Or @error = 1) Then Return SetError(2, 0, 0); If ($s_content = "") Then $s_content = 0; Return SetError(0, 0, $s_content); EndFunc ;==>_LaunchCount_GetCount Func _LaunchCount_IncrementCount() Local $i_count = _LaunchCount_GetCount(); If (@error <> 0) Then Return SetError(1, @error, False); Local $s_config = _LaunchCount_GetFile(); If (@error <> 0) Then Return SetError(2, @error, False); $h_config = FileOpen($s_config, 2); If ($h_config = -1) Then Return SetError(3, 0, False); If Not (FileWrite($h_config, $i_count + 1)) Then Return SetError(4, 0, False); FileClose($h_config); Return SetError(0, 0, True); EndFunc ;==>_LaunchCount_IncrementCount If you want the functions to be more flexible you could use this version of _LaunchCount_GetFile() where NAME_OF_YOUR_APPLICATION_OR_GUID has been replaced with a function argument instead. Func _LaunchCount_GetFile($s_GUID) Local $s_configDir = @AppDataDir & "\" & $s_GUID; Local $s_configFile = $s_configDir & "\config.dat"; If Not (FileExists($s_configDir)) Then If Not (DirCreate($s_configDir)) Then Return SetError(1, 0, ""); EndIf If Not (FileExists($s_configFile)) Then If Not (FileWrite($s_configFile, "")) Then Return SetError(2, 0, ""); EndIf Return SetError(0, 0, $s_configFile); EndFunc ;==>_LaunchCount_GetFile We could improve this function further by checking whether $s_GUID contains illegal NTFS characters ( / ? < > \ : * | ” ), but I'm sure you would figure that out. You don't have to use _LaunchCount_GetFile() as that is handled automatically by the two other functions. The first time you call _LaunchCount_GetCount() it will return 0. You increment the count by one using _LaunchCount_IncrementCount(). I did some quick tests and it should work
  11. No 1. You can name this variable anything you want. For $OMG = 5 to 1 Step -1 MsgBox(0, "Count down!", $OMG) Next MsgBox(0,"", "Blast Off!")The use of '$i' is just naming convention. The variable is created upon entering the loop. In other words, you create the variable. Most of the time you would want to use this value to access a certain element in an existing array. For $i = 5 to 1 Step -1 Local $s_item = $items[$i]; This will copy item number $i to the local variable $s_item. Next No 2. Dim $aArray[4]; Yes, this is the exact number of items in the array. $string = ""; This will initialize the variable as an empty string.The following array will append values to this variable ($string). I am not sure if it is required to initialize it like this, but it improves readability and certainly does not harm. ; This loop will iterate through every item in an array, and the $element ; variable will always be the current item where the loop is. You could do ; the same thing using For $i = 0 To 5 but then you would not have $element, ; but rather $aArray[$i]. For $element In $aArray ; This part will append string values to an existing string array. Let's ; say the $string value is empty (""). In the first loop iteration you add ; "LOL" and @CRLF (which is a line break), then in the next iteration you ; add "OMG". Now your string looks like: ; LOL ; OMG $string = $string & $element & @CRLF Next; This loop iteration is finished and we will go back to 'For' and start over again if there is still unprocessed items in the array. I'm not sure if I understood the last question. You want to know how you can call Windows Command Prompt commands in AutoIt? If that's the case, check out this post. You should be able to call robocopy using one of those approaches. I hope this made things a little more clear
  12. Nice, whatever functionality you may seek... There's an UDF for it
  13. In C# I would use the System.IO.FileSystemWatcher class to do this. There is an equivalent in the Windows API which might be possible to implement i AutoIt. It would require some nice API ninja moves though
  14. I don't think this is possible to accomplish easily using Au3. You would have to create an overlay for SC2, by hooking into the game etc. Just like the Steam overlay or XFire. Complicated stuff. You could play SC2 windowed? A lot of games permits this by using command line arguments like "-window".
  15. As Mat said MsgBox(64, "IP Increment", _IP_Add("192.168.2.200", 10)); Func _IP_Add($s_IP = "192.168.2.200", $i = 10) Local $a_parts = StringSplit($s_IP, ".", 0); If (IsArray($a_parts) = 0 Or $a_parts[0] <> 4) Then Return SetError(1, 0, ""); $a_parts[4] += $i; $s_IP = $a_parts[1] & "." & $a_parts[2] & "." & $a_parts[3] & "." & $a_parts[4]; Return SetError(0, 0, $s_IP); EndFunc ;==>_IP_Add
  16. You forgot the correct second argument for Run(), which is "workingdir", not show_flag. Anyways, I revised your code a little and tried to comment everything properly. Ask if you got any questions #AutoIt3Wrapper_outfile=Evony.exe; This tells the compiler to name the finished exe "Evony.exe". Local $PID = ProcessExists("iexplore.exe"); Will return the PID or 0 if the process isn't found. While ($PID <> 0); This loop will keep going until $PID equals 0. If (ProcessClose($PID) <> 1) Then ContinueLoop; If ProcessClose() returns any other value that 1, it failed to close the process. $PID = ProcessExists("iexplore.exe"); If the process was found, $PID should now contain its handle (hWnd). WEnd; Now we loop up to "While" and check whether $PID is still not 0. Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe", "", @SW_MAXIMIZE); Now we're going to run Internet Explorer. Exit; That's it.
  17. I'm not very experienced on using DllCall(), but does this work? Local $hashCode = DllCall("libbnet.dll", "str", "double_hash_password", "str", "sPassword", "long", "lClientToken", "long", "lServerToken", "str", "sBufferOut"); You need to replace sPassword, lClientToken, lServerToken and sBufferOut with the proper values of course.
  18. It's in the helpfile #include <Process.au3> _RunDOS("assoc .au3=txtfile"); or RunWait(@ComSpec & " /C " & "assoc .au3=txtfile", "", @SW_HIDE);
  19. Thank you for your assistance! I have created working code for retrieving the name of the user, whether the user is online/offline/ingame (and what game),if offline, when the user was last online, and whether the profile is private or not. Doing the same thing in C# too. When I get the code free of bugs I'll see about posting everything here
  20. I realize that regex might be the way to go, so what I need now is a pattern that returns everything between <!-- profile status bit --> ... and ... <!-- /profile status bit --> My attempt: #include <Array.au3> #include <INet.au3> Local $s_regexPattern = "^<!-- profile status bit -->$(.*?)^<!-- \/profile status bit -->$"; Local $a_regex = StringRegExp(_SteamProfile_GetPageSource("INSERT STEAM PROFILE URL HERE"), $s_regexPattern, 3, 1); _ArrayDisplay($a_regex); ; ---------------------------------------------------------------------------------------------------- Func _SteamProfile_GetPageSource($sURL_SteamProfile) Local $s_siteSource = _INetGetSource($s_steamProfile); If ($s_siteSource = "") Then Return SetError(1, 0, ""); Return SetError(0, 0, $s_siteSource); EndFunc ;==>_SteamProfile_GetPageSource ; ---------------------------------------------------------------------------------------------------- The regex pattern does not work, any hints? I'm not sure about multiline matching in au3 regex Note: A Steam Community Profile URL can be obtained from here; http://steamcommunity.com/groups/Valve (I didn't find it appropriate to post a specific profile URL).
  21. First we get the page source of the Steam Community Profile: #include <INet.au3> Func _SteamProfile_GetPageSource($sURL_SteamProfile) Local $s_siteSource = _INetGetSource($s_steamProfile); If ($s_siteSource = "") Then Return SetError(1, 0, ""); Return SetError(0, 0, $s_siteSource); EndFunc ;==>_SteamProfile_GetPageSource The function will return a large amount of text, what we need is this section: InGame <!-- profile status bit --> <div id="OnlineStatus"> <div id="inCommon"> <div id="currentlyPlayingIcon"> <div class="iconHolder_in-game"><div class="avatarIcon"><a href="http://store.steampowered.com/app/10180"><img src="http://media.steampowered.com/steamcommunity/public/images/apps/10180/ad502494f1658220f9166c7e17ac90422bf6a479.jpg" /></a></div></div> </div> <img src="http://steamcommunity.com/public/images/skin_1/status_in-game.gif" width="120" height="14" border="0" /><br /> <p id="statusInGameText"> Call of Duty: Modern Warfare 2 </p> <br clear="left" /> </div> </div> <!-- /profile status bit -->Offline <!-- profile status bit --> <div id="OnlineStatus"> <div id="inCommon"> <p id="statusOfflineText">Last Online: 2 hrs, 1 mins ago</p> </div> </div> <!-- /profile status bit -->Online <!-- profile status bit --> <div id="OnlineStatus"> <div id="inCommon"> <div id="statusOnlineText"><img src="http://steamcommunity.com/public/images/skin_1/status_online.gif" width="102" height="14" border="0" /></div><br /> </div> </div> <!-- /profile status bit --> The thing is, I have zero experience in parsing html. What I need is being able to retrieve online status (online/offline), and if status is "InGame", I need to find out what game we're talking about. If you have any clues on how I can achieve this, please let me know! And I'm not asking you to write the code for me - I'm here to learn! (though, examples is always appreciated)
  22. Wow nice! I've never seen this script before. Awesome monoceres! Nice music trancexx
  23. Looks like I'll have to do it that way I was hoping for some sort of super ninja API that could magically fix it
  24. Hello, Edit: Well, the title is kind of misleading, I figured out some of the troubles i were having the very moment i pushed the "New topic" button. ShellExecute() isn't involved in this drama. I am trying to launch SciTe like this Run($s_SciTe_Executable, "", @SW_HIDE) The problem is that @SW_HIDE doesn't seem to have any effect at all. I guess SciTe explicitly is setting itself at @SW_SHOW or something along that road. Is it possible to override this behaviour? Thanks.
  25. All right, that's what I feared I'll create a state of the art SciTe Startup Wrapper
×
×
  • Create New...