Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/17/2022 in all areas

  1. i found the easiest way in my iconLVw.au3i insert this func to save the icon: Func _SaveToFile($sDLLName, $iIconId, $iWidth=32, $iHeight=32) ;ConsoleWrite($sDLLName & @TAB & $iIconId & @CRLF) Local $sFile = $sIconPath & '\' & StringReplace($sDLLName, '.dll', '_') & $iIconId & '.ico' ConsoleWrite($sFile & @CRLF) Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\' & $sDLLName, $iIconId, $iWidth, $iHeight) _WinAPI_SaveHICONToFile($sFile, $hIcon) _WinAPI_DestroyIcon($hIcon) EndFunc ;==>_SaveToFile in the showing loop i inserted: ; _SaveToFile($sDLLName, $iBilder) ;comment out and every icon in loop is saved in 32x32 no i have 3k+ icon's
    2 points
  2. Your initial example, when sent to the POSTMAN Echo API, sends the form data correctly. Are you sure you are posting the correct script and error message? If so, then the problem is probably the format of the POST data. It would help if you provided more information about the API. The site doesn't have API examples? You could also try URL encoding your POST data before sending it. The second $sPostData in my example has the string URL encoded. Both ways produce the same result when sent to the POSTMAN Echo API. However, your API server may want the URL encoded string when special characters exist. If so, there are several URL encoding & decoding functions posted to the forum. Just do a search for URLEncode. Example: #include <Constants.au3> #include <MyIncludes\json\json.au3> http_post_example() Func http_post_example() Local $oComErr = Null ;~ Local $sPostData = 'username=myrealusername&password=]=oN9>fh2!O' Local $sPostData = 'username=myrealusername&password=%5D=oN9%3Efh2!O' ;URL Encoded ;Register COM Error Handler $oComErr = ObjEvent("AutoIt.Error", com_error_handler) If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", _ "Unable to register COM error handler - @error = " & @error) ;Send POST request using WINHTTP COM object With ObjCreate("winhttp.winhttprequest.5.1") ;Open POST request, set request header(s), and send the request .Open("POST", "https://postman-echo.com/post") If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", _ StringFormat("(0x%X) %s", $oComErr.RetCode, $oComErr.WinDescription)) .SetRequestHeader("Content-Type" , "application/x-www-form-urlencoded") .SetRequestHeader("Accept" , "application/json") .SetRequestHeader("Cache-Control", "no-cache") .Send($sPostData) If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", _ StringFormat("(0x%X) %s", $oComErr.RetCode, $oComErr.Description)) ConsoleWrite(StringFormat("HTTP Status: %s (%s)", .Status, .StatusText) & @CRLF) ;If http status code not 200, exit with message If .Status <> 200 Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", _ StringFormat("HTTP Status Code = %s %s", .Status, .StatusText)) ;Display formatted JSON response ConsoleWrite(@CRLF & "HTTP Response:" & @CRLF) ConsoleWrite(Json_Encode(Json_Decode(.ResponseText), $JSON_PRETTY_PRINT + $JSON_UNESCAPED_SLASHES) & @CRLF) EndWith EndFunc Func com_error_handler($oError) With $oError ConsoleWrite(@ScriptName & " (" & .scriptline & ") : ==> COM Error intercepted !" & @CRLF) ConsoleWrite(@TAB & "Error Number........... " & "0x" & Hex(.number) & @CRLF) ConsoleWrite(@TAB & "Error WinDescription... " & StringStripWS(.windescription, $STR_STRIPTRAILING) & @CRLF) ConsoleWrite(@TAB & "Error Description...... " & StringStripWS(.description , $STR_STRIPTRAILING) & @CRLF) ConsoleWrite(@TAB & "Error ScriptLine....... " & .scriptline & @CRLF) ConsoleWrite(@TAB & "Error RetCode.......... " & "0x" & Hex(.retcode) & @CRLF) EndWith Return ; Return so @error can be trapped by the calling function EndFunc Output: HTTP Status: 200 (OK) HTTP Response: { "args": {}, "data": "", "files": {}, "form": { "username": "myrealusername", "password": "]=oN9>fh2!O" }, "headers": { "x-forwarded-proto": "https", "x-forwarded-port": "443", "host": "postman-echo.com", "x-amzn-trace-id": "Root=1-62fc3310-05b42b003c0bbd127b09c301", "content-length": "44", "cache-control": "no-cache", "content-type": "application/x-www-form-urlencoded; Charset=UTF-8", "accept": "application/json", "user-agent": "Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)" }, "json": { "username": "myrealusername", "password": "]=oN9>fh2!O" }, "url": "https://postman-echo.com/post" }
    2 points
  3. I want to extract a icon from shell32.dll and write it to a new file. Here my non-working script: #include <WinAPIIcons.au3> $hIcon = _WinAPI_LoadShell32Icon(71) ; the next statement writes only a hexalue (e.g. 0x01CB07C9)to the file ; how to write the icon to the file? FileWrite(@ScriptFullPath & ".ico", $hIcon) _WinAPI_DestroyIcon($hIcon) How to create the file? got it myself: #include <WinAPIGdi.au3> $hIcon = _WinAPI_LoadShell32Icon(71) _WinAPI_SaveHICONToFile(@ScriptFullPath & ".ico", $hIcon) _WinAPI_DestroyIcon($hIcon)
    2 points
  4. I am still working on "all" reported comments/issues from others (read zero!) , but this version contains the changes so far including yours. Just redownload the SciTE_changes_Dynamic_Includes.zip. Jos
    1 point
  5. Here is little improvement/optimization: On SelectionChange in Listbox with scenarios now dynamically enable/disable SaveScenario/DelScenario buttons (disable for Select All/Clear All) and those easier calling SaveScenario()/DelScenario() functions. Due to this better structurization of code is main program loop shorter and more readable: ; https://www.autoitscript.com/forum/topic/208545-listview-saveload-checked-scenarios-need-an-idea/?do=findComment&comment=1505446 #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: myName Script Function: Template AutoIt script. List #ce ---------------------------------------------------------------------------- #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListBoxConstants.au3> $t = TimerInit() $aList = IniReadSection("Example.ini", "List") ConsoleWrite("- Load INI Time " & TimerDiff($t) & @CRLF) $hWnd = GUICreate("Save Setup Example", 726, 434, 188, 227) $hLV = GUICtrlCreateListView("", 8, 8, 513, 377) _GUICtrlListView_SetExtendedListViewStyle($hLV, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) GUICtrlCreateLabel("Search", 16, 400, 38, 17) $hSearch = GUICtrlCreateInput("Search", 64, 400, 225, 21) GUICtrlCreateLabel("Scenario", 528, 8, 50, 17) $hSetup = GUICtrlCreateList("", 528, 32, 187, 110) GUICtrlSendMsg($hSetup, $LB_INSERTSTRING, 0, "Select All") ; Set Default data GUICtrlSendMsg($hSetup, $LB_INSERTSTRING, 1, "Clear All") ; Set Default data GUICtrlSendMsg($hSetup, $LB_INSERTSTRING, 2, "My Scenario") GUICtrlSendMsg($hSetup, $LB_INSERTSTRING, 3, "Scenario Test 2") GUICtrlSendMsg($hSetup, $LB_INSERTSTRING, 4, "Test 3") GUICtrlSendMsg($hSetup, $LB_SELECTSTRING, -1, "Clear All") ; Select in Config $hSetupSave = GUICtrlCreateButton("Save Scenario", 528, 152, 91, 25) $hSetupDel = GUICtrlCreateButton("Delete Scenario", 624, 152, 91, 25) EnableButtonsSaveDel($GUI_DISABLE) $Debug1 = GUICtrlCreateButton("Select Rng", 528, 312, 91, 25) $Debug2 = GUICtrlCreateButton("Debug", 624, 312, 91, 25) $Label3 = GUICtrlCreateLabel("Label3", 528, 344, 36, 17) ; Add columns _GUICtrlListView_AddColumn($hLV, "#", 45) _GUICtrlListView_AddColumn($hLV, "Group", 100) _GUICtrlListView_AddColumn($hLV, "Test Name", 300) _GUICtrlListView_AddColumn($hLV, "Status", 60) $t = TimerInit() _GUICtrlListView_BeginUpdate($hLV) $NumLen = StringLen($aList[0][0]) For $i = 1 To $aList[0][0] _GUICtrlListView_AddItem($hLV, StringFormat("%0" & $NumLen & "i", $i)) $aStr = StringSplit($aList[$i][0], "__", 1) _GUICtrlListView_AddSubItem($hLV, $i-1, StringReplace($aStr[1], "_", " "), 1) _GUICtrlListView_AddSubItem($hLV, $i-1, StringReplace($aStr[2], "_", " "), 2) ; GUICtrlCreateListViewItem("Item " & $i, $idListview) Next _GUICtrlListView_EndUpdate($hLV) ConsoleWrite("- Load LV Time " & TimerDiff($t) & @CRLF) GUISetState(@SW_SHOW) $iI = -1 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hSetup $setup_value = GUICtrlRead($hSetup) Switch $setup_value Case "Select All" CheckAll(True) EnableButtonsSaveDel($GUI_DISABLE) Case "Clear All" CheckAll(False) EnableButtonsSaveDel($GUI_DISABLE) Case Else CheckScenario($setup_value) EnableButtonsSaveDel($GUI_ENABLE) EndSwitch Case $hSetupSave SaveScenario(GUICtrlRead($hSetup)) Case $hSetupDel DelScenario(GUICtrlRead($hSetup)) Case $Debug1 $iI = Random(0, 10, 1) _GUICtrlListView_SetItemSelected($hLV, $iI) _GUICtrlListView_SetItemFocused($hLV, $iI) _GUICtrlListView_EnsureVisible($hLV, $iI + 1) EndSwitch WEnd Func EnableButtonsSaveDel($state) GUICtrlSetState($hSetupSave, $state) GUICtrlSetState($hSetupDel, $state) EndFunc Func CheckAll($on_off) For $i = 0 To _GUICtrlListView_GetItemCount($hLV) _GUICtrlListView_SetItemChecked($hLV, $i, $on_off) Next EndFunc Func CheckScenario($scenario_name) $aListCheckScenario = IniReadSection("Example.ini", $scenario_name) If @error Then CheckAll(False) Return EndIf ; comma separated list of checked names from INI for this scenario, if name contains comma then use pipe | as separator $names = ',' For $i = 1 To $aListCheckScenario[0][0] $names &= $aListCheckScenario[$i][0] & ',' Next For $i = 0 To _GUICtrlListView_GetItemCount($hLV) $name = _GUICtrlListView_GetItemText($hLV, $i, 2) If StringInStr($names,','&$name&',') Then _GUICtrlListView_SetItemChecked($hLV, $i, True) Else _GUICtrlListView_SetItemChecked($hLV, $i, False) EndIf Next EndFunc Func SaveScenario($scenario_name) $ini_section = '' For $i = 0 To _GUICtrlListView_GetItemCount($hLV) If _GUICtrlListView_GetItemChecked($hLV, $i) Then $name = _GUICtrlListView_GetItemText($hLV, $i, 2) $ini_section &= $name & '=1' & @LF EndIf Next IniWriteSection("Example.ini", $scenario_name, $ini_section) EndFunc Func DelScenario($scenario_name) $i = GUICtrlSendMsg($hSetup, $LB_FINDSTRING, -1, $scenario_name) If $i <> -1 Then GUICtrlSendMsg($hSetup, $LB_DELETESTRING, $i, '') IniWriteSection("Example.ini", $scenario_name, '') EndFunc EDIT: little optimization in EnableButtonsSaveDel()
    1 point
  6. Thanks mLipok! It worked for me too Adding an exception on Windows running the default Microsoft AV: Open Windows Defender Security Center. Click on the Virus & threat protection icon. Click on the link Virus & threat protection settings. Scroll down to Exclusions and click on the link Add or remove exclusions. Click on the button Add an exclusion. In the drop down menu select Folder. Navigate to "C:\Users\usrname\AppData\Local\AutoIt v3\Aut2exe". Click on the button Select folder.
    1 point
×
×
  • Create New...