Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/22/2017 in all areas

  1. trancexx

    WinHTTP functions

    The other day mikeytown2 posted one post in HTTP UDF's thread that got me thinking if there is better (different) method to send requests through the HTTP protocol to HTTP servers. There is Winhttp.dll that ships with windows and that is its main purpose. I couldn't find any examples of using this dll in AutoIt, so I came up with this. Microsoft about Windows HTTP Services: Microsoft Windows HTTP Services (WinHTTP) provides developers with an HTTP client application programming interface (API) to send requests through the HTTP protocol to other HTTP servers... .. blah, blah, and so on... This is an example of getting page header: #include "WinHttp.au3" Opt("MustDeclareVars", 1) ; Open needed handles Local $hOpen = _WinHttpOpen() Local $hConnect = _WinHttpConnect($hOpen, "msdn.microsoft.com") ; Specify the reguest: Local $hRequest = _WinHttpOpenRequest($hConnect, Default, "en-us/library/aa384101(VS.85).aspx") ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) Local $sHeader = _WinHttpQueryHeaders($hRequest) ; ...get full header ; Clean _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Display retrieved header MsgBox(0, "Header", $sHeader)Everything you need to be able to use this UDF can be found at WinHttp site. Remember, basic understanding of the HTTP protocol is important to use this interface. ProgAndy, trancexx WinHttp.au3 is completely free and no one has right to charge you for it. That's very important. If you feel WinHttp.au3 was helpful to you and you wish to support my further work you can donate to my personal account via PayPal address: trancexx at yahoo dot com I will appreciate that very much. Thank you in advance! :kiss:
    1 point
  2. Another method: #include <IE.au3> $oIE = _IECreate("https://www.supermakler.pkobp.pl/plus/demo/", 1) $oDivs1 = _IETagNameGetCollection($oIE, "Div") For $oDiv1 In $oDivs1 If StringInStr($oDiv1.id, "x-auto-") Then If StringStripWS($oDiv1.innertext, 8) = "Zlecenia" Then $oDivs2 = _IETagNameGetCollection($oDiv1, "Div") For $oDiv2 In $oDivs2 If StringStripWS($oDiv2.ClassName, 7) = "x-nodrag x-tool-refresh x-tool epm-toolButton x-component" Then _IEAction($oDiv2, "Click") EndIf Next EndIf EndIf Next
    1 point
  3. JLogan3o13

    I've on question

    @Titas If you are asking whether you can automate a Chrome window, the answer is yes. There is a Chrome UDF in our Examples forum, with plenty of examples to get you started. As to someone writing the command for you, we prefer the "teach a man to fish methodology"; take a look at the UDF and its examples, and try it out on your own. If you get stuck, post here what you have tried on your own, and we will do our best to help.
    1 point
  4. sreemannem, Welcome to the AutoIt forum. Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing "Bypassing of security measures - log-in and security dialogs" - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. M23
    1 point
  5. ripdad

    [SOLVED] Registry export

    ShellExecuteWait('REG', 'EXPORT "HKCU\SOFTWARE\Nend Software\Tray Radio" "' & @ScriptDir & '\test.reg"') You have to use double quotes in command lines when spaces are in it.
    1 point
  6. Subz

    [SOLVED] Registry export

    Sorry missed your space in the reg you need to use, something like this: Run(@ComSpec & ' /c REG EXPORT "HKCU\SOFTWARE\Nend Software\Tray Radio" "' & @ScriptDir & '\test.reg"')
    1 point
  7. ? are you trying to capture data from the whole table? if so then you can easily get the table content using the _IETableWriteToArray() function #include <IE.au3> #include <Array.au3> Local $sSpanishWord = "tener" ;to have Local $oIE = _IECreate ("http://www.spanishdict.com/conjugate/" & $sSpanishWord) Local $oTable = _IETableGetCollection($oIE, 2) Local $aTableData = _IETableWriteToArray($oTable, True) _ArrayDisplay($aTableData)
    1 point
  8. i found something that might be the problem, and it is in the way the data is manipulated, here is the code that the client uses this is to send data ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1024); byte[] buffer = new byte[1024]; this is to get data while ((bytesRead = inputStream.read(buffer)) != -1) { byteArrayOutputStream.write(buffer, 0, bytesRead); response += byteArrayOutputStream.toString("UTF-8"); and here is how android server sends the data OutputStream outputStream; String msgReply = "Hello from Server, you are #" + cnt; try { outputStream = hostThreadSocket.getOutputStream(); PrintStream printStream = new PrintStream(outputStream); printStream.print(msgReply); printStream.close(); maybe in autoit im not sending it right because the app get stuck in this part and it never receive the data
    1 point
  9. jchd

    Angle of 2 points

    What I mean is that, given only points A and B there are two very different angles one may consider. The first is α the angle formed by vectors from the origin O to point A and to point B. The angle α doesn't depend on the length of vectors OA and OB as soon as A and B are distinct from O. The second angle may be the angle γ between a reference direction (say North for instance) and the line AB. Note that then B is moved to B' this angle becomes β while at the same time, α remains constant.
    1 point
  10. Creating an application that could read any autoit code and convert it into efficient C code would be a mammoth undertaking. Whilst it is relatively easy to convert simple statements that use AutoIts built in functions, handling more complex statements and the UDF libraries would be a nightmare. The effort required is just not going to be worth anyone's time. I use AutoIt daily in an enterprise environment and have hundreds of scripts ranging from small 10 liners that I use once to do something like update a 1.5TB xml file to 80,000 line scripts that orchestrates a full testing and validation flow line. As others have said the speed of AutoIt in most day to day use cases is not an issue. If speed is an issue then I would write the application directly in C so that I can make full use of the direct control that C give you rather than some inevitably less than optimal automatically generated code. The main reason I use AutoIt is the speed that I can create an application that does the job require. Usually this is much quicker than I could even just write a detailed requirements document require by our IS department before they will event give a rough quote.
    1 point
  11. No idea what this means. What did you try to code? It could very well be somebody tackled this issue before but to me it is as simple as this: #include <Misc.au3> Func _My_VersionCompare($sVersion1, $sVersion2) $V1 = StringSplit($sVersion1, ".") $V2 = StringSplit($sVersion2, ".") If $V1[0] = 4 Then $sVersion1 = $V1[1] & "." & $V1[2] & $V1[3] & "." & $V1[4] EndIf If $V2[0] = 4 Then $sVersion2 = $V2[1] & "." & $V2[2] & $V2[3] & "." & $V2[4] EndIf Return _VersionCompare($sVersion1, $sVersion2) EndFunc ;==>_My_VersionCompare ConsoleWrite('_VersionCompare("10.000.2345", "10.00.00.2345") = ' & _VersionCompare("10.000.2345", "10.00.00.2345") & ' >Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite('_My_VersionCompare("10.000.2345", "10.00.00.2345") = ' & _My_VersionCompare("10.000.2345", "10.00.00.2345") & ' >Error code: ' & @error & @CRLF) ;### Debug Console Agree? Jos
    1 point
  12. Well I have solved it myself after searching for... I got a code for WinAPI that makes it what I want. #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $Form1 = GUICreate("Form1", 364, 153, 192, 124) $label1 = GUICtrlCreateLabel("Chance", 80, 32, 59, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $label2 = GUICtrlCreateLabel("Payout", 228, 31, 53, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("49.50", 144, 104, 97, 41) $Chance = GUICtrlCreateInput("49.50", 56, 63, 121, 21) $Payout = GUICtrlCreateInput("2", 208, 63, 121, 21) GUISetState(@SW_SHOW) Global $WhichFunc = 0 Global $aFuncs[2] $aFuncs[0] = _Func_1 $aFuncs[1] = _Func_2 Global $RW = 1 GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Chance Case $Payout Case $Button1 $aFuncs[$WhichFunc] () $WhichFunc = Not $WhichFunc EndSwitch WEnd Func WM_COMMAND($hWinHandle, $iMsg, $wParam, $lParam) If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $Chance Then Chance() EndIf If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $Payout Then Payout() EndIf EndFunc ;==>WM_COMMAND Func Chance() $Read1 = GUICtrlRead($Chance) $data = 99 / $Read1 GUICtrlSetData($Payout, $data) $data = 99 / $data If $RW = 1 Then GUICtrlSetData($Button1, $data) Else _Func_1() EndIf EndFunc Func Payout() $Read2 = GUICtrlRead($Payout) $data1 = 99 / $Read2 $data1 = Round($data1, 5) GUICtrlSetData($Chance, $data1) If $RW = 1 Then GUICtrlSetData($Button1, $data1) Else _Func_1() EndIf EndFunc Func _Func_2() $Read1 = GUICtrlRead($Chance) GUICtrlSetData($Button1, $Read1) $RW = 1 EndFunc Func _Func_1() $Read2 = GUICtrlRead($Chance) $Read2 = 99.99 - $Read2 GUICtrlSetData($Button1, $Read2) $RW = 2 EndFunc
    1 point
  13. This is a totally different solution. A system image list is used to store icons, which are extracted from files/folders with _WinAPI_ShellGetFileInfo. File/folder names are specified by PIDLs. The code contains a version of _WinAPI_ShellGetFileInfo that supports PIDLs. Then the icons are shown in a listview. #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <WinAPICom.au3> #include <WinAPIShPath.au3> #include <WinAPIShellEx.au3> Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Initialize COM _WinAPI_CoInitialize() ; Create GUI Local $hGui = GUICreate( "Drop files or folders (one at a time) on the listview to show icons", 550, 300, 300, 200, -1, BitOR( $WS_EX_ACCEPTFILES, $WS_EX_TOPMOST ) ) ; System image list Local $hImlLarge = _WinAPI_ShellGetImageList() ; Create ListView Local $idListView = GUICtrlCreateListView( "", 0, 0, 550, 300 ) GUICtrlSetStyle( $idListView, BitOR( $GUI_SS_DEFAULT_LISTVIEW, $LVS_ICON ) ) GUICtrlSetState( $idListView, $GUI_DROPACCEPTED ) Local $hListView = GUICtrlGetHandle( $idListView ) _GUICtrlListView_SetExtendedListViewStyle( $hListView, $LVS_EX_DOUBLEBUFFER ) _GUICtrlListView_SetImageList( $hListView, $hImlLarge, 0 ) ; Show GUI GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_DROPPED Local $sFile = @GUI_DragFile Local $iImage = GetIconIndex( $sFile ) Local $sText = StringRight( $sFile, StringLen( $sFile ) - StringInStr( $sFile, "\", 0, -1 ) ) _GUICtrlListView_AddItem( $hListView, $sText, $iImage ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup _WinAPI_CoUninitialize() GUIDelete( $hGui ) Exit EndFunc Func GetIconIndex( $sFileName ) Local $pPIDL = _WinAPI_ShellILCreateFromPath( $sFileName ) Local $tSHFILEINFO = DllStructCreate( $tagSHFILEINFO ) Local $iFlags = BitOr( $SHGFI_PIDL, $SHGFI_SYSICONINDEX ) _WinAPI_ShellGetFileInfoEx( $pPIDL, $iFlags, 0, $tSHFILEINFO ) Local $iIcon = DllStructGetData( $tSHFILEINFO, "iIcon" ) _WinAPI_CoTaskMemFree( $pPIDL ) Return $iIcon EndFunc Func _WinAPI_ShellGetFileInfoEx($pPIDL, $iFlags, $iAttributes, ByRef $tSHFILEINFO) Local $aRet = DllCall('shell32.dll', 'dword_ptr', 'SHGetFileInfoW', 'ptr', $pPIDL, 'dword', $iAttributes, 'struct*', $tSHFILEINFO, 'uint', DllStructGetSize($tSHFILEINFO), 'uint', $iFlags) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Take a look at System Image Lists if you want to show state information (overlay icon (eg. the small link overlay in lower left corner of an icon), ghosted state (used for protected system folders) or compressed state (blue text color if compressed file)).
    1 point
×
×
  • Create New...