Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/02/2016 in all areas

  1. You will always have to wait for upload to finish before continuing in AutoIt. The language isn't capable for parallel executions. What I can do is add new function to WinHttp.au3 that could be used to set callback function that would be called during upload process periodically, in which you could control/update progress bar or whatever. Yea, I think I'll do that.
    3 points
  2. trancexx

    API Upload XML WinHttp

    Ok, done. The example would be: #include "WinHTTP.au3" $sAddress = "https://posttestserver.com/post.php?dir=WinHttp" ; the address of the target (https or http, makes no difference - handled automatically) ; Select some file $sFileToUpload = FileOpenDialog("Select file to upload...", "", "All Files (*)") If Not $sFileToUpload Then Exit 5 ; check if the file is selected and exit if not $sForm = _ '<form action="' & $sAddress & '" method="post" enctype="multipart/form-data">' & _ ' <input type="file" name="upload"/>' & _ '</form>' ; Initialize and get session handle $hOpen = _WinHttpOpen() $hConnect = $sForm ; will pass form as string so this is for coding correctness because $hConnect goes in byref ; Creates progress bar window ProgressOn("UPLOADING", $sFileToUpload, "0%") ; Register callback function _WinHttpSimpleFormFill_SetCallback(UploadCallback) ; Fill form $sHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _ Default, _ "name:upload", $sFileToUpload) ; Collect error number $iErr = @error ; Unregister callback function _WinHttpSimpleFormFill_SetCallback(0) ; Kill progress bar window ProgressOff() ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If $iErr Then MsgBox(4096, "Error", "Error number = " & $iErr) Else ConsoleWrite($sHTML & @CRLF) MsgBox(4096, "Success", $sHTML) EndIf ; Callback function. For example, update progress control Func UploadCallback($iPrecent) If $iPrecent = 100 Then ProgressSet(100, "Done", "Complete") Sleep(800) ; give some time for the progress bar to fill-in completely Else ProgressSet($iPrecent, $iPrecent & "%") EndIf EndFuncAnd the latest (working version of) WinHttp.au3 is at https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3 Try it, maybe I leave it in.
    2 points
  3. Hello Again! I previously stumbled upon a topic asking for maps datatype's instructions... I too wasn't sure what a map is until I tried it... So I am making this topic to help other newbies (and some oldbies) better understand the Maps datatype of AutoIt! Lets start! A Note for Readers The maps datatype is still in development and is currently in Alpha Stage (More Risky than Beta) and its unstable, so AutoIt can crash indefinably while using Maps! I can't guarantee if this will be implemented in stable versions, this is a fairly new thing to AutoIt coders & in my honest opinion I don't see any use for it Maps are the best datatype in AutoIt, Very Useful ... Not hurting anyone though . Also the maps datatype is DISABLED IN STABLE VERSIONS, So you need to install the latest beta version of AutoIt to make maps work . If you find any bugs while using a map, please report it in the Official Bug Tracker Introduction To Maps Maps are just like arrays, instead they use "keys" to access elements inside them... A key can be either a string or an integer (Other datatypes work too but they are converted to a integer [Equivalent to Int($vKey)] before assignment [Source]). Although Integers don't represent the order of elements in a map unlike in an array... Declaring Maps Its similar to declaring an Array: ; This is the only way to declare a map ; You must have a declarative keyword like Dim/Global/Local before the declaration unless the map is assigned a value from a functions return Local $mMap[] ; Don't insert any numbers or strings it! Simple, Isn't it? Using Maps Using maps is similar to arrays (again!): Local $mMap[] ; Lets declare our map first! ; Adding data to maps is easy... ; This is our key ; | ; v $mMap["Key"] = "Value" ; <--- And our value! ; A key is Case-Sensitive meaning "Key" is not same as "key"! $mMap["key"] = "value" ; Not the same as $mMap["Key"]! ; There are 2 different ways to access an element in a map $mMap["Key"] ; 1st Method $mMap.Key ; 2nd Method Enumerating Maps Its quite easy to enumerate through arrays but what about maps? how can I enumerate through them!? #include <MsgBoxConstants.au3> ; Lets create our map first Local $mMap[] ; Lets add some information to the map, feel free to modify & add new elements $mMap["Name"] = "Damon Harris" $mMap["Alias"] = "TheDcoder" $mMap["Gender"] = "Male" $mMap["Age"] = 14 $mMap["Location"] = "India" $aMapKeys = MapKeys($mMap) ; MapKeys function returns all the keys in the format of an array Local $sProfile = "Profile of " & $mMap["Name"] & ':' & @CRLF ; We will use this string later For $vKey In $aMapKeys ; We use this to get the keys in a map :) $sProfile &= @CRLF & $vKey & ': ' & $mMap[$vKey] ; Add some details to the profile string using our map! Next MsgBox($MB_ICONINFORMATION + $MB_OK, "Profile", $sProfile) ; Finally display the profile :) It is easy as always Multi-Dimensional Maps Now now... I know that you are a little confused that how can an multi-dimensional maps exist... Although I am not 100% sure if its called that but lets continue: #include <MsgBoxConstants.au3> ; Multi-Dimensional maps are just maps in a map Local $mMapOfMapsvilla[] ; This map will store an other map Local $mParkMap[] ; This Park map will be inserted in the Mapsvilla's map :P $mMapOfMapsvilla["Map Item 1"] = "Town Hall" $mMapOfMapsvilla["Map Item 2"] = "Police Station" $mMapOfMapsvilla["Map Item 3"] = "Shopping Mall" $mMapOfMapsvilla["Map Item 4"] = "Residential Area" $mMapOfMapsvilla["Map Item 5"] = "Park" $mParkMap["Map Item 1"] = "Cottan Candy Stand" $mParkMap["Map Item 2"] = "Public Toilet" $mParkMap["Map Item 3"] = "Woods" $mMapOfMapsvilla.Park = $mParkMap MsgBox($MB_OK, "Map Location", $mMapOfMapsvilla["Map Item 1"]) ; Will display Town Hall MsgBox($MB_OK, "Map Location", $mMapOfMapsvilla.Park["Map Item 1"]) ; Will display Cottan Candy Stand I am sure its easy for you to understand now Frequently Asked Questions (FAQs) & Their answers Q #1. Help! My code does not respond to anything (or) I get an "Variable subscript badly formatted" error on the line of declaration... A. DONT USE F5 or Go, Instead use Alt + F5 or Tools -> Beta Run in SciTE (Make sure that you have Beta installed) Q #2. Why are you using "m" in-front of every map variable? A. Best coding Practices: Names of Variables Q #3. What are "Elements" which you mention frequently??? A. This is a newbie question (I have no intention of insulting you ), so I guess you are new to programming. "Elements" are data slots inside a Map (or an Array), you can imagine elements as individual variable which are stored in a Map. You can access them using "keys", Please refer to "Introduction to Maps" section at the starting of this post Q #4. Are Maps faster than Arrays? A. You need to understand that Maps have different purpose than Arrays. Maps are designed to store data dynamically (like storing information for certain controlIDs of GUI) and Arrays are designed to store data in a order (for instance, Storing every character of a string in an element for easy access). If you still want to know then if Maps are faster, then the answer is maybe... Maps are *supposed* (I am not sure ) to be faster in addition of elements (while Arrays are painfully slow while adding or removing elements). Here (Post #24) is a benchmark (Thanks kealper! ) More FAQs coming soon! Feel free to ask a question in the mean while
    1 point
  4. Lately, in this forum, there were many questions and problems referring to the use of ie.au3 UDF using the latest version of AutoIt v3.3.14.x. I would like to present the correct usage of the UDF. I hope that it will help many users to prevent problems. #include <ie.au3> #include <MsgBoxConstants.au3> ; STEP 1 ; YOU MUST SET ANY COM ERROR HANDLER IN ONE OF THE FOLLOWING WAY ; STEP 1: CASE 1 ; you should set COM Error Handler Function for ie.au3 UDF _IEErrorHandlerRegister(_User_ErrFunc) ; STEP 1: CASE 2 ; eventually if you not want to recieve additional information ; you can use just the same function without parameter ; _IEErrorHandlerRegister() ; STEP 1: CASE 3 ; or use your own global COM Error Handler ;~ Global $oCOMErrorHandler = ObjEvent("AutoIt.Error", _User_ErrFunc) ; STEP 2 ; if you do not wish to get in Console Output Pane information like the following: ; --> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType ; You can uncomment this following line: ; _IEErrorNotify(False) _Example() Func _Example() ; First lets create some IE Object Local $oIE = _IECreate('google.com') ; you should always check for @error in any function (even you own made) If @error Then MsgBox($MB_ICONERROR, '_IECreate', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; Set @error when you return from function with Failure Return SetError(1,0,0) Endif ; here we try to get reference to LuckyStrike button Local $oLuckyStrike = _IEGetObjByName($oIE, 'btnI') ; you should always check for @error in any function (even you own made) If @error Then MsgBox($MB_ICONERROR, '_IEGetObjByName', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; Set @error when you return from function with Failure Return SetError(2,0,0) Endif ; here we try to click LuckyStrike button with previously achieved Object which is a reference to HTML DOM OBJECT in IE Instance _IEAction($oLuckyStrike, 'click') ; you should wait when page is loading _IELoadWait($oIE) ; some user interaction If MsgBox($MB_YESNO, 'Question', 'Do you want to back ?') = $IDYES Then _IEAction($oIE, 'back') EndIf EndFunc ;==>_Example ; User's COM error function. ; After SetUp with ObjEvent("AutoIt.Error", ....) will be called if COM error occurs Func _User_ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptFullPath & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_User_ErrFunc Regards, mLipok
    1 point
  5. suppose your program has a service-like functionality, i.e. launch at Windows startup, constantly running in the background, no GUI (e.g. TCP server). you could write it as a service (with this marvelous UDF), or you could install it as a scheduled task. Windows Task Scheduler has an API, and is also manageable by WMI. but if you are not a seasoned developer, the simplest way is to call schtasks.exe to create the task (as well as validate and run it). unfortunately, schtasks.exe does not directly support all options and settings of a task. tasks created by schtasks.exe have some undesirable settings enabled by default, such as "Start the task only if the computer is on AC power", "Stop if the computer switches to battery power", and the most annoying is of course, "Stop the task if it runs longer than 3 days". to overcome this, we write an XML file with the desired options configured, and call schtasks.exe to create the task by that XML file. this topic uses two files: 1) the tasked script itself, which - in this example - is used only to log the used and free space of the system drive: #RequireAdmin #AutoIt3Wrapper_Res_Fileversion=0.0.0.0 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=Y #NoTrayIcon Global $sDrive = StringLeft(@WindowsDir, 3) Global $sFile = $sDrive & 'Au3task_VolLog.csv' Global $sLastMinute = '' Global $nDriveSpaceTotal=0 Global $nDriveSpaceFree=0 While True If Not FileExists($sFile) Then FileWriteLine($sFile, 'Time,Used Space [MB],Free Space [MB]') If @SEC = '00' And @MIN <> $sLastMinute Then $nDriveSpaceTotal=Round(DriveSpaceTotal($sDrive)) $nDriveSpaceFree=Round(DriveSpaceFree($sDrive)) FileWriteLine($sFile, @YEAR & '/' & @MON & '/' & @MDAY & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & ',' & $nDriveSpaceTotal - $nDriveSpaceFree & ',' & $nDriveSpaceFree) $sLastMinute = @MIN EndIf Sleep(100) WEnd compile this script and name it au3@task.exe to run the example setup script hereunder. note the wrapper directives!. 2) the setup script (which you can run without compiling). this installs the compiled task above to the root of the system drive, and configures a task to run it at startup as the local SYSTEM account: (EDIT: updated setup script with a subfolder for the task is in post #2 hereunder) #RequireAdmin #AutoIt3Wrapper_Res_Fileversion=0.0.0.0 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=y #NoTrayIcon #include <MsgBoxConstants.au3> Global $sTitle = 'au3@task Setup' Global $sDrive = StringLeft(@WindowsDir, 3) Global $sTaskName = 'au3@task' If AlreadyInstalled() Then If MsgBox($MB_ICONQUESTION + $MB_YESNO, $sTitle, 'Uninstall? ') = $IDYES Then If Uninstall() Then MsgBox($MB_ICONINFORMATION, $sTitle, 'Uninstallation completed successfully. ') Else MsgBox($MB_ICONERROR, $sTitle, 'Uninstallation error. ') EndIf Else MsgBox($MB_ICONINFORMATION, $sTitle, 'Uninstallation aborted. ') EndIf Else If MsgBox($MB_ICONQUESTION + $MB_YESNO, $sTitle, 'Install? ') = $IDYES Then If Install() Then If MsgBox($MB_ICONQUESTION + $MB_YESNO, $sTitle, 'Installation completed successfully. Run task now? ') = $IDYES Then If RunWait('schtasks.exe /Run /TN ' & $sTaskName, '', @SW_HIDE) = 0 Then MsgBox($MB_ICONINFORMATION, $sTitle, 'Task is running. ') Else MsgBox($MB_ICONERROR, $sTitle, 'Error running the task. ') EndIf Else MsgBox($MB_ICONINFORMATION, $sTitle, 'Done. ') EndIf Else MsgBox($MB_ICONERROR, $sTitle, 'Installation error. ') EndIf Else MsgBox($MB_ICONINFORMATION, $sTitle, 'Installation aborted. ') EndIf EndIf Func AlreadyInstalled() If Not FileExists($sDrive & 'au3@task.exe') Then Return False If RunWait('schtasks.exe /Query /TN ' & $sTaskName, '', @SW_HIDE) <> 0 Then Return False Return True EndFunc ;==>AlreadyInstalled Func Install() If Not FileInstall('au3@task.exe', $sDrive, 1) Then Return False Local $sXML = _ '<?xml version="1.0" encoding="UTF-16"?>' & @CRLF & _ '<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">' & @CRLF & _ ' <Triggers>' & @CRLF & _ ' <BootTrigger>' & @CRLF & _ ' <Enabled>true</Enabled>' & @CRLF & _ ' </BootTrigger>' & @CRLF & _ ' </Triggers>' & @CRLF & _ ' <Principals>' & @CRLF & _ ' <Principal id="Author">' & @CRLF & _ ' <UserId>S-1-5-18</UserId>' & @CRLF & _ ' <RunLevel>HighestAvailable</RunLevel>' & @CRLF & _ ' </Principal>' & @CRLF & _ ' </Principals>' & @CRLF & _ ' <Settings>' & @CRLF & _ ' <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>' & @CRLF & _ ' <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>' & @CRLF & _ ' <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>' & @CRLF & _ ' <AllowHardTerminate>false</AllowHardTerminate>' & @CRLF & _ ' <StartWhenAvailable>false</StartWhenAvailable>' & @CRLF & _ ' <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>' & @CRLF & _ ' <IdleSettings>' & @CRLF & _ ' <StopOnIdleEnd>true</StopOnIdleEnd>' & @CRLF & _ ' <RestartOnIdle>false</RestartOnIdle>' & @CRLF & _ ' </IdleSettings>' & @CRLF & _ ' <AllowStartOnDemand>true</AllowStartOnDemand>' & @CRLF & _ ' <Enabled>true</Enabled>' & @CRLF & _ ' <Hidden>false</Hidden>' & @CRLF & _ ' <RunOnlyIfIdle>false</RunOnlyIfIdle>' & @CRLF & _ ' <WakeToRun>false</WakeToRun>' & @CRLF & _ ' <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>' & @CRLF & _ ' <Priority>7</Priority>' & @CRLF & _ ' </Settings>' & @CRLF & _ ' <Actions Context="Author">' & @CRLF & _ ' <Exec>' & @CRLF & _ ' <Command>ExePath</Command>' & @CRLF & _ ' </Exec>' & @CRLF & _ ' </Actions>' & @CRLF & _ '</Task>' $sXML = StringReplace($sXML, 'ExePath', $sDrive & 'au3@task.exe') Local $sFileXML = @TempDir & '\au3@task.xml' FileDelete($sFileXML) FileWrite($sFileXML, $sXML) If FileRead($sFileXML) <> $sXML Then Return False If RunWait('schtasks.exe /Create /XML "' & $sFileXML & '" /TN ' & $sTaskName, '', @SW_HIDE) <> 0 Then Return False FileDelete($sFileXML) Return True EndFunc ;==>Install Func Uninstall() RunWait('schtasks.exe /End /TN ' & $sTaskName, '', @SW_HIDE) If RunWait('schtasks.exe /Delete /F /TN ' & $sTaskName, '', @SW_HIDE) <> 0 Then Return False Sleep(3000) If Not FileDelete($sDrive & 'au3@task.exe') Then Return False Return True EndFunc ;==>Uninstall note: the XML file embedded in the script was exported from a task already configured with the required options. the registration components were stripped. if you wish to configure other settings, you can study the XML schema, or simply configure a task manually and export it to XML. tested on Windows 7 Ultimate 64-bit. enjoy!
    1 point
  6. These are the defaults defined in au3.properties: ## Debug Output Options (to permanent change your selection copy them to SciTEUser.Properties and change it there # Debug MessageBox Option 2="All" 1="No @extended" 0="No @extended & @error". debug.msgbox.option=0 # Debug Console Option 3="All" 2="No SystemTime" 1="No SystemTime & Return" 0="No SystemTime, Return & Error". debug.console.option=1 # Debug Trace Option 3="All" 2="No SystemTime" 1="No SystemTime & Return" 0="No SystemTime, Return & Error". debug.trace.option=1 # extra propery used by AutoItAutoComplete.LUA to totally disable AutoComplete when set to 1 So just copy this line and put that in your SciTEUser.properties: # Debug Console Option 3="All" 2="No SystemTime" 1="No SystemTime & Return" 0="No SystemTime, Return & Error". debug.console.option=3 Jos
    1 point
  7. Does the special button only send ctrl/alt/shift+ something or do they send different combinations of ctrl/alt/shift like ctrl + alt + something? I would use a hotkeyset if you know the "something" variable for different scenarios. Are you setting the "something" manually or is that an internal thing with the mouse?
    1 point
  8. ^^ For example, intuitive as you are, do you think C/C++ allows this: char czardas[] = { 99, 122, 97, 114, 100, czardas[2], 115, 0 };
    1 point
  9. It is much easier to load the Full SciTE4AutoIt3 version and do Alt+d on the given variable or Functions. One caveat with your ConsoleWrite line is when the filename contains spaces or brackets. That is why I have put double quote support around the filename in my version of SciTE, and added those to Tidy and au3check. ConsoleWrite('"' & @ScriptDir & '\myfile.au3"(' & @ScriptLineNumber & ',1) : WARNING: ' & @crlf )Jos
    1 point
  10. computergroove

    Keep It

    Do you have any code? Are you trying to make a teamviewer clone? if you are just trying to send commands or files ou could just use Hamachi but I am having all kinds of stupid connection issues all the time with it.
    1 point
  11. Jos

    Keep It

    When your computer (the intermediate server ) is on a private 192.168.x.x network, it will not be able to interact like the teamviewer cloud servers, as it is not directly accessible from the internet unless you start doing some port forwarding in your ISP router. It is important that you understand how this all works before you start playing around with it as you might open up too much and get all kinds of hack attacks to the host to which you port forward to. Jos
    1 point
  12. Gianni

    Problem with color

    just insert a delay right after that line, use the Sleep() function with the wanted delay Sleep(1000) delays 1 second, Sleep(500) delays half second ... Local $iTargetColor = 0xFF0000 ; the wanted color Do $var = PixelGetColor(212, 157) If $var <> $iTargetColor Then MouseClick("primary", 755, 618) ; not the right color Sleep(1000) ; delay of 1000 milliseconds (that is 1 second) Until $var = $iTargetColor ; repeat this loop until color is the wanted one MouseClick("primary", 300, 300) ; click here and go ahead... Local $iTargetColor = 0xFF0000 ; the wanted color While 1 $var = PixelGetColor(212, 157) If $var = $iTargetColor Then MouseClick("primary", 300, 300) ; click here... ExitLoop ; and go ahead... (exit the While - Wend loop) Else MouseClick("primary", 755, 618) ; not the right color Sleep(1000) ; delay of 1000 milliseconds (that is 1 second) EndIf WEnd ; repeat this loop until color is the wanted one
    1 point
  13. Gianni

    Problem with color

    ? not clear the exact flow, (the color red should be 0xFF0000 instead of 0xFF6666...) maybe something like this? Local $iTargetColor = 0xFF0000 ; the wanted color Do $var = PixelGetColor(212, 157) If $var <> $iTargetColor Then MouseClick("primary", 755, 618) ; not the right color Until $var = $iTargetColor ; repeat this loop until color is the wanted one MouseClick("primary", 300, 300) ; click here and go ahead...
    1 point
  14. You can use WinList to list all windows matching the specified class : $aList = WinList("[CLASS:Windowsforms10.Windows.8.app.0.378734a]")It returns an array. The order of this array depends of how your application works : - If there is a parent window with a child window, then the row1 will contain values for the child GUI (even if the main window is actived) - If each window is a main window (no parent), then the order of the array will correspond to the display order of each window. (active window in row1) Can you try this code and give us the result ? #include <Array.au3> #include <WinAPI.au3> $aWinList = WinList("[CLASS:Windowsforms10.Windows.8.app.0.378734a]") Local $aWinInfo[ $aWinList[0][0] ][4] For $i = 1 To $aWinList[0][0] $aPos = WinGetPos($aWinList[$i][1]) $aWinInfo[$i - 1][0] = $aWinList[$i][0] $aWinInfo[$i - 1][1] = $aWinList[$i][1] $aWinInfo[$i - 1][2] = "X=" & $aPos[0] & "; Y=" & $aPos[1] & "; W=" & $aPos[2] & "; H=" & $aPos[3] $aWinInfo[$i - 1][3] = _WinAPI_GetParent($aWinList[$i][1]) Next _ArrayDisplay($aWinInfo, "", "", 0, Default, "Title|Hwnd|Position/Size|ParentHwnd")Also, you can try this example to understand how windows a re ordered : #include <Array.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> ; example of 3 windows (1 main window with a child, and a second main window) Local $aGuis[3] $aGuis[0] = GUICreate("MainGUI", 300, 300, 0, 0) $aGuis[1] = GUICreate("MainGUI_2", 300, 300, 320, 0) $aGuis[2] = GUICreate("ChildGUI", 300, 300, 640, 0, -1, -1, $aGuis[0]) GUISetState(@SW_SHOW, $aGuis[0]) GUISetState(@SW_SHOW, $aGuis[1]) GUISetState(@SW_SHOW, $aGuis[2]) ;active one of the 3 windows randomly WinActivate( $aGuis[Random(0, 2, 1)]) ConsoleWrite("Active GUI=" & WinGetTitle("[ACTIVE]")) $aWinList = WinList("[CLASS:AutoIt v3 GUI]") Local $aWinInfo[ $aWinList[0][0] ][5] For $i = 1 To $aWinList[0][0] $aPos = WinGetPos($aWinList[$i][1]) $aWinInfo[$i - 1][0] = $aWinList[$i][0] $aWinInfo[$i - 1][1] = $aWinList[$i][1] $aWinInfo[$i - 1][2] = "X=" & $aPos[0] & "; Y=" & $aPos[1] & "; W=" & $aPos[2] & "; H=" & $aPos[3] $aWinInfo[$i - 1][3] = _WinAPI_GetParent($aWinList[$i][1]) $aWinInfo[$i - 1][4] = ( WinActive($aWinList[$i][1]) ? 1 : 0) Next _ArrayDisplay($aWinInfo, "", "", 0, Default, "Title|Hwnd|Position/Size|ParentHwnd|Active") Sleep(2000)
    1 point
  15. First thanks for this code i used for a long time this code successfully in my Tool, but unfortunately it has limits, if you put them large files (such as an ISO 5GB) crashes or returns Wrong Hash, in web there are thousands of examples and threads, when everything very simple ehhhh https://msdn.microsoft.com/en-us/library/windows/desktop/aa382380(v=vs.85).aspx If Not IsDeclared("arDllCall") Then Global Static $arDllCall Global Const $hKernel32DLL = DllOpen("Kernel32.dll") Global Const $hAdvapi32Dll = DllOpen("AdvApi32.dll") Func _MD5ForFile($sFile) $arDllCall = DllCall($hKernel32DLL, "hwnd", "CreateFileW", "wstr", $sFile, "dword", 0x80000000, "dword", 3, "ptr", 0, "dword", 3, "dword", 0x80, "ptr", 0) If @Error Or $arDllCall[0] = -1 Then Return SetError(1, 0, "") EndIf Local $hFile = $arDllCall[0] $arDllCall = DllCall($hAdvapi32Dll, "int", "CryptAcquireContextW", "ULONG_PTR*", 0, "ptr", 0, "ptr", 0, "dword", 1, "dword", 0xF0000000) ; CRYPT_VERIFYCONTEXT If @Error Or Not $arDllCall[0] Then DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(3, 0, "") EndIf Local $hContext = $arDllCall[1] $arDllCall = DllCall($hAdvapi32Dll, "int", "CryptCreateHash", "ULONG_PTR", $hContext, "dword", 0x00008003, "ptr", 0, "dword", 0, "ULONG_PTR*", 0) If @Error Or Not $arDllCall[0] Then DllCall($hAdvapi32Dll, "int", "CryptReleaseContext", "ULONG_PTR", $hContext, "dword", 0) DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(3, 0, "") EndIf Local $hHashMD5 = $arDllCall[5], $bSucceeded = 1, $Buffer = DllStructCreate("byte[65535]") While $bSucceeded $arDllCall = DllCall($hKernel32DLL, "BOOL", "ReadFile", "HANDLE", $hFile, "ptr", DllStructGetPtr($Buffer), "dword", 65535, "dword*", 0, "ptr", Null) If @Error Or $arDllCall[4] = 0 Then ExitLoop $bSucceeded = $arDllCall[0] $arDllCall = DllCall($hAdvapi32Dll, "int", "CryptHashData", "ULONG_PTR", $hHashMD5, "struct*", $Buffer, "dword", $arDllCall[4], "dword", 0) If @Error Or Not $arDllCall[0] Then DllCall($hAdvapi32Dll, "int", "CryptDestroyHash", "ULONG_PTR", $hHashMD5) DllCall($hAdvapi32Dll, "int", "CryptReleaseContext", "ULONG_PTR", $hContext, "dword", 0) DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(4, 0, "") EndIf WEnd If Not $bSucceeded Then DllCall($hAdvapi32Dll, "int", "CryptDestroyHash", "ULONG_PTR", $hHashMD5) DllCall($hAdvapi32Dll, "int", "CryptReleaseContext", "ULONG_PTR", $hContext, "dword", 0) DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(5, 0, "") EndIf Local $tOutMD5 = DllStructCreate("byte[16]") $arDllCall = DllCall($hAdvapi32Dll, "int", "CryptGetHashParam", "ULONG_PTR", $hHashMD5, "dword", 2, "ptr", DllStructGetPtr($tOutMD5), "dword*", 16, "dword", 0) If @Error Or Not $arDllCall[0] Then DllCall($hAdvapi32Dll, "int", "CryptDestroyHash", "ULONG_PTR", $hHashMD5) DllCall($hAdvapi32Dll, "int", "CryptReleaseContext", "ULONG_PTR", $hContext, "dword", 0) DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(6, 0, "") EndIf Local $sSHA1 = Hex(DllStructGetData($tOutMD5, 1)) DllCall($hAdvapi32Dll, "int", "CryptDestroyHash", "ULONG_PTR", $hHashMD5) DllCall($hAdvapi32Dll, "int", "CryptReleaseContext", "ULONG_PTR", $hContext, "dword", 0) DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(0, 0, $sSHA1) EndFunc Func _SHA1ForFile($sFile) $arDllCall = DllCall($hKernel32DLL, "hwnd", "CreateFileW", "wstr", $sFile, "dword", 0x80000000, "dword", 3, "ptr", 0, "dword", 3, "dword", 0x80, "ptr", 0) If @Error Or $arDllCall[0] = -1 Then Return SetError(1, 0, "") EndIf Local $hFile = $arDllCall[0] $arDllCall = DllCall($hAdvapi32Dll, "int", "CryptAcquireContextW", "ULONG_PTR*", 0, "ptr", 0, "ptr", 0, "dword", 1, "dword", 0xF0000000) ; CRYPT_VERIFYCONTEXT If @Error Or Not $arDllCall[0] Then DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(2, 0, "") EndIf Local $hContext = $arDllCall[1] $arDllCall = DllCall($hAdvapi32Dll, "int", "CryptCreateHash", "ULONG_PTR", $hContext, "dword", 0x00008004, "ptr", 0, "dword", 0, "ULONG_PTR*", 0) If @Error Or Not $arDllCall[0] Then DllCall($hAdvapi32Dll, "int", "CryptReleaseContext", "ULONG_PTR", $hContext, "dword", 0) DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(3, 0, "") EndIf Local $hHashSHA1 = $arDllCall[5], $bSucceeded = 1, $Buffer = DllStructCreate("byte[65535]") While $bSucceeded $arDllCall = DllCall($hKernel32DLL, "BOOL", "ReadFile", "HANDLE", $hFile, "ptr", DllStructGetPtr($Buffer), "dword", 65535, "dword*", 0, "ptr", Null) If @Error Or $arDllCall[4] = 0 Then ExitLoop $bSucceeded = $arDllCall[0] $arDllCall = DllCall($hAdvapi32Dll, "int", "CryptHashData", "ULONG_PTR", $hHashSHA1, "struct*", $Buffer, "dword", $arDllCall[4], "dword", 0) If @Error Or Not $arDllCall[0] Then DllCall($hAdvapi32Dll, "int", "CryptDestroyHash", "ULONG_PTR", $hHashSHA1) DllCall($hAdvapi32Dll, "int", "CryptReleaseContext", "ULONG_PTR", $hContext, "dword", 0) DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(4, 0, "") EndIf WEnd If Not $bSucceeded Then DllCall($hAdvapi32Dll, "int", "CryptDestroyHash", "ULONG_PTR", $hHashSHA1) DllCall($hAdvapi32Dll, "int", "CryptReleaseContext", "ULONG_PTR", $hContext, "dword", 0) DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(5, 0, "") EndIf Local $tOutSHA1 = DllStructCreate("byte[20]") $arDllCall = DllCall($hAdvapi32Dll, "int", "CryptGetHashParam", "ULONG_PTR", $hHashSHA1, "dword", 2, "ptr", DllStructGetPtr($tOutSHA1), "dword*", 20, "dword", 0) If @Error Or Not $arDllCall[0] Then DllCall($hAdvapi32Dll, "int", "CryptDestroyHash", "ULONG_PTR", $hHashSHA1) DllCall($hAdvapi32Dll, "int", "CryptReleaseContext", "ULONG_PTR", $hContext, "dword", 0) DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(6, 0, "") EndIf Local $sSHA1 = Hex(DllStructGetData($tOutSHA1, 1)) DllCall($hAdvapi32Dll, "int", "CryptDestroyHash", "ULONG_PTR", $hHashSHA1) DllCall($hAdvapi32Dll, "int", "CryptReleaseContext", "ULONG_PTR", $hContext, "dword", 0) DllCall($hKernel32DLL, "int", "CloseHandle", "hwnd", $hFile) Return SetError(0, 0, $sSHA1) EndFunc Ciao a tutti.
    1 point
  16. DeSwa, Then you need to use _GUICtrlListView_EnsureVisible with the index of the new item. M23
    1 point
  17. Kinda an old topic, but I took a quick look at it (BitWise operators get me every time). I think the problem was in this _IPToInt() function. He was only shifting the bytes (which are 8 bits each) 4 bits, so he was mixing stuff up that shouldn't be mixed. He was also just adding them, which normally is fine, but BitOR is a better way to do it, and will make sure the other bit shifts play nice as well. Here's the corrected version, which makes your above test show False, as it should. Func _IPToInt($IP) If Not _IsIP($IP) Then SetError(7) Return false EndIf Local $I = StringSplit($IP, ".") If @error Then SetError(5) Return 0 EndIf Return BitOR(BitShift($I[1], -24), BitShift($I[2], -16), BitShift($I[3], -8), $I[4]) EndFunc
    1 point
×
×
  • Create New...