Jump to content

beginner10

Active Members
  • Posts

    25
  • Joined

  • Last visited

About beginner10

  • Birthday 08/25/1991

Profile Information

  • Location
    Romania

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

beginner10's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. @TheXman Thanks for the reply. The truth is, I haven't used Winhttp in the past. I understand what you're saying, so referres is a request header, using SetRequestHeader. But is there any way to see if that header was actually set correctly? I would have expected that after sending it with SetRequestHeader(), I could see it with GetAllResponseHeaders(). But I understand why it doesn't work that way. Thanks
  2. I'm trying to set a referrer, but it's not visible in the header, ideas? $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", "https://example.com", False) $oHTTP.SetRequestHeader("Accept", "*/*") $oHTTP.SetRequestHeader("Referrer", 'http://www.123.com') $oHTTP.Send("") $oHTTP.WaitForResponse $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status $oHeader = $oHTTP.GetAllResponseHeaders() MsgBox(0,"",$oHeader) ; Referrer is not working Func MyErrFunc() MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) EndFunc ;==>MyErrFunc
  3. @Jos It is a general question, this problem is for any other site. and also the previous topic I reported. Sorry for the previous post, it was accidental. My intentions are good.
  4. Hello, Below I used _WinHttpAddRequestHeaders to send a cookie on that page, but when I display the header using Header = _WinHttpQueryHeaders($h_openRequest) ConsoleWrite(@CRLF & "HEADERS1:" & @CRLF & $Header & @CRLF & @CRLF) .... , the cookie I set does not appear there. I have been trying to solve this problem for a few weeks, but I am not successful at all, I have tried in various ways but without success. I'm still a beginner. If anyone can help me, I would be grateful. Thank you in advance. #include "Winhttp.au3" Global $hw_open = _WinHttpOpen("User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36") If @error Then MsgBox(48, "Error", "Error initializing the usage of WinHTTP functions.") Exit EndIf Global $hw_connect = _WinHttpConnect($hw_open, "www.site.com") If @error Then MsgBox(48, "Error", "Error specifying the initial target server of an HTTP request.") _WinHttpCloseHandle($hw_open) Exit EndIf $h_openRequest = _WinHttpOpenRequest($hw_connect, "POST") If @error Then MsgBox(48, "Error", "Error creating an HTTP request handle.") _WinHttpCloseHandle($hw_connect) _WinHttpCloseHandle($hw_open) Exit EndIf _WinHttpAddRequestHeaders($h_openRequest, "Cookie: test=testcookie") _WinHttpSendRequest($h_openRequest) _WinHttpReceiveResponse($h_openRequest) $Header = _WinHttpQueryHeaders($h_openRequest) ConsoleWrite(@CRLF & "HEADERS1:" & @CRLF & $Header & @CRLF & @CRLF) Exit
  5. I searched more closely and it seems that the $oHttp.SetRequestHeader("Cookie", 'test=testcookie') function is not working. Because $oHttp.GetAllResponseHeaders() does not include my cookie set.
  6. Hi, I need a little help, if anyone is willing to help me, I rarely post on the forum here, I usually try to learn on my own, but now, I have not found a solution to my problem, although I tried for a few weeks alone. I need to find in the source code of a page, the list of users, as it is in the picture attached below. This is the source code for my failed attempts, I wonder where I went wrong? #include <Array.au3> #include <String.au3> $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $url = "#########################" ; Replace this link with an online model $Get = BinaryToString(InetRead($url, 1), 4) ;ConsoleWrite(@CRLF & $Get) $Get2 = WinHttp_read($url) ConsoleWrite(@CRLF & $Get2) ClipPut($Get2) Exit Func WinHttp_read($url) $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHttp.Open("GET", $url, False) $oHttp.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36") $oHttp.SetRequestHeader("Pragma", "no-cache") $oHttp.SetRequestHeader("Cache-Control", "no-cache") $oHttp.SetRequestHeader("Referer", "########################") $oHttp.SetRequestHeader("Cookie", 'agreeterms=1') $oHttp.Send() If @error Then Return SetError(5, "", "") $oHttp.WaitForResponse() $HTMLSource = $oHttp.Responsetext $cookiesg = $oHttp.GetAllResponseHeaders() $oHttp = 0 Return $HTMLSource $oHttp.Close EndFunc ;==>WinHttp_read After testing with the first default function, InetRead, I realized that the problem is that the page is not fully loaded, and I started using WinHttp. I had some hopes with WinHttp, I used User-Agent and WaitForResponse (), but still I don't get all the source code to find the list of users in it. If you can help me with some ideas at least, I would be grateful Thank you in advance.
  7. Hi, Does anyone know how I can set the correct proxy in this script? Thank you Func _MicrosoftXMLHTTP($url) $oHttp = ObjCreate("Microsoft.XMLHTTP") ;$oHttp.setProxy(2, "209.127.191.111:9279") ;$oHttp.setProxyCredentials("user", "pass") $oHttp.Open("GET", $url, 0) $oHttp.Send() If @error Then Return SetError(1, 0, 0) $sReceived = $oHttp.ResponseText Return $sReceived EndFunc ;==>_MicrosoftXMLHTTP
  8. I'm trying to add this script to a button. So that when I press that button, I open a photo album. After I added this script to the button, it doesn't work at all. I'm trying to figure out how to solve this. #include <GUIConstants.au3> #include <GDIPlus.au3> #include <WinAPISysWin.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Form1", 275, 122, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $Button1 = GUICtrlCreateButton("Album image 1", 16, 16, 115, 41) GUICtrlSetOnEvent($Button1, "_Start") ;$Button2 = GUICtrlCreateButton("Album image 2", 16, 64, 115, 41) GUISetState(@SW_SHOW) While True Sleep(10) WEnd Func _Start() Global $hImage = _GDIPlus_ImageLoadFromFile("C:\Users\Windows 10 Pro\Desktop\Test\Images\2.jpg") Global $iImageWidth = _GDIPlus_ImageGetWidth($hImage), $iImageHeight = _GDIPlus_ImageGetHeight($hImage) Local $aPos[] = [$iImageWidth, $iImageHeight] If $iImageWidth > @DesktopWidth Or $iImageHeight > @DesktopHeight Then $aPos = _EvaluateSize(@DesktopWidth, @DesktopHeight, $iImageWidth, $iImageHeight) EndIf Global $hGUI = GUICreate("", $aPos[0], $aPos[1], -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME)) GUISetBkColor(0x000000) GUISetOnEvent($hGUI, "SpecialEvents2") Global $idPic = GUICtrlCreatePic("", 0, 0, $aPos[0], $aPos[1]) Global $hBitMap = _SetImagetoCtrl($idPic, $hImage, $aPos[0], $aPos[1]) GUIRegisterMsg($WM_SIZE, WM_SIZE) GUISetState() EndFunc ;==>_Start Func _EvaluateSize($iBaseWidth, $iBaseHeight, $iActualWidth, $iActualHeight) Local $iVal = $iBaseWidth / $iActualWidth * $iActualHeight If $iVal <= $iBaseHeight Then Return StringSplit($iBaseWidth & "|" & $iVal, "|", $STR_NOCOUNT) $iVal = $iBaseHeight / $iActualHeight * $iActualWidth Return StringSplit($iVal & "|" & $iBaseHeight, "|", $STR_NOCOUNT) EndFunc ;==>_EvaluateSize Func _SetImagetoCtrl($idPic, $hImage, $iWidth, $iHeight) Local $hResize = _GDIPlus_ImageResize($hImage, $iWidth, $iHeight) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hResize) _GDIPlus_ImageDispose($hResize) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) Return $hHBitmap EndFunc ;==>_SetImagetoCtrl Func WM_SIZE($hWnd, $nMsg, $wParam, $lParam) AdlibRegister(_ResizeImage, 5) Return 1 EndFunc ;==>WM_SIZE Func _ResizeImage() AdlibUnRegister(_ResizeImage) Local $tRECT = _WinAPI_GetClientRect($hGUI) Local $iWidth = $tRECT.right - $tRECT.left + 1 Local $iHeight = $tRECT.bottom - $tRECT.top + 1 If $iWidth > $iImageWidth And $iHeight > $iImageHeight Then Local $aPos[] = [$iImageWidth, $iImageHeight] Else Local $aPos = _EvaluateSize($iWidth, $iHeight, $iImageWidth, $iImageHeight) EndIf _WinAPI_MoveWindow(GUICtrlGetHandle($idPic), Int(($iWidth - $aPos[0]) / 2), Int(($iHeight - $aPos[1]) / 2), $aPos[0], $aPos[1]) $hBitMap = _SetImagetoCtrl($idPic, $hImage, $aPos[0], $aPos[1]) EndFunc ;==>_ResizeImage Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE Case @GUI_CtrlId = $GUI_EVENT_RESTORE EndSelect EndFunc ;==>SpecialEvents Func SpecialEvents2() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBitMap) _GDIPlus_Shutdown() Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE Case @GUI_CtrlId = $GUI_EVENT_RESTORE EndSelect EndFunc ;==>SpecialEvents2 I think this is the way, but just doesn't work, I'm omitting something. The latest script: #include <GUIConstants.au3> #include <GDIPlus.au3> #include <WinAPISysWin.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Form1", 275, 122, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $Button1 = GUICtrlCreateButton("Album image 1", 16, 16, 115, 41) GUICtrlSetOnEvent($Button1, "_Start") ;$Button2 = GUICtrlCreateButton("Album image 2", 16, 64, 115, 41) GUISetState(@SW_SHOW) Global $hGUI = GUICreate("", 800, 600, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME)) GUISetBkColor(0x000000) GUISetOnEvent($hGUI, "SpecialEvents2") Global $idPic = GUICtrlCreatePic("", 0, 0, 100, 100) GUISetState(@SW_HIDE, $hGUI) GUIRegisterMsg($WM_SIZE, WM_SIZE) While True Sleep(10) WEnd Func _Start() Global $hImage = _GDIPlus_ImageLoadFromFile("C:\Users\Windows 10 Pro\Desktop\Test\Images\2.jpg") Global $iImageWidth = _GDIPlus_ImageGetWidth($hImage), $iImageHeight = _GDIPlus_ImageGetHeight($hImage) Local $aPos[] = [$iImageWidth, $iImageHeight] If $iImageWidth > @DesktopWidth Or $iImageHeight > @DesktopHeight Then $aPos = _EvaluateSize(@DesktopWidth, @DesktopHeight, $iImageWidth, $iImageHeight) EndIf Global $hBitMap = _SetImagetoCtrl($idPic, $hImage, $aPos[0], $aPos[1]) GUISetState(@SW_SHOW, $hGUI) EndFunc ;==>_Start Func _EvaluateSize($iBaseWidth, $iBaseHeight, $iActualWidth, $iActualHeight) Local $iVal = $iBaseWidth / $iActualWidth * $iActualHeight If $iVal <= $iBaseHeight Then Return StringSplit($iBaseWidth & "|" & $iVal, "|", $STR_NOCOUNT) $iVal = $iBaseHeight / $iActualHeight * $iActualWidth Return StringSplit($iVal & "|" & $iBaseHeight, "|", $STR_NOCOUNT) EndFunc ;==>_EvaluateSize Func _SetImagetoCtrl($idPic, $hImage, $iWidth, $iHeight) Local $hResize = _GDIPlus_ImageResize($hImage, $iWidth, $iHeight) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hResize) _GDIPlus_ImageDispose($hResize) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) Return $hHBitmap EndFunc ;==>_SetImagetoCtrl Func WM_SIZE($hWnd, $nMsg, $wParam, $lParam) AdlibRegister(_ResizeImage, 5) Return 1 EndFunc ;==>WM_SIZE Func _ResizeImage() AdlibUnRegister(_ResizeImage) Local $tRECT = _WinAPI_GetClientRect($hGUI) Local $iWidth = $tRECT.right - $tRECT.left + 1 Local $iHeight = $tRECT.bottom - $tRECT.top + 1 If $iWidth > $iImageWidth And $iHeight > $iImageHeight Then Local $aPos[] = [$iImageWidth, $iImageHeight] Else Local $aPos = _EvaluateSize($iWidth, $iHeight, $iImageWidth, $iImageHeight) EndIf _WinAPI_MoveWindow(GUICtrlGetHandle($idPic), Int(($iWidth - $aPos[0]) / 2), Int(($iHeight - $aPos[1]) / 2), $aPos[0], $aPos[1]) $hBitMap = _SetImagetoCtrl($idPic, $hImage, $aPos[0], $aPos[1]) EndFunc ;==>_ResizeImage Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE Case @GUI_CtrlId = $GUI_EVENT_RESTORE EndSelect EndFunc ;==>SpecialEvents Func SpecialEvents2() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $hGUI) GUISetState(@SW_SHOW, $Form1) Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE Case @GUI_CtrlId = $GUI_EVENT_RESTORE EndSelect EndFunc ;==>SpecialEvents2
  9. @Nine Now I understand how to center an object, easy math, but I didn't think about it. Int(($iWidth-$aPos[0])/2), Int(($iHeight-$aPos[1])/2 Thanks for the support, now everything is fine, if I need improvements I will come back here. Have a merry christmas!
  10. @Nine, Thanks for the help. Of course I don’t ask for direct help, I research the script and try to solve it on my own. I changed the _ResizeImage () function, I put some ifs that check the maximum length and width, and it stops there. Now it seems to be working properly, but there are still 2 problems. 1. The picture is not centered, I don't know how to do that. 2. When you press the maximize button, it does not work. It only works when I widen the Gui. My code: #include <GUIConstants.au3> #include <GDIPlus.au3> #include <WinAPISysWin.au3> _GDIPlus_Startup() Example() _GDIPlus_Shutdown() Func Example() Local Const $BASE_WIDTH = @DesktopWidth / 2, $BASE_HEIGHT = @DesktopHeight / 2 Global $hImage = _GDIPlus_ImageLoadFromFile("C:\Users\Windows 10 Pro\Desktop\Test\Images\2.jpg") Global $iImageWidth = _GDIPlus_ImageGetWidth($hImage) Global $iImageHeight = _GDIPlus_ImageGetHeight($hImage) Local $aPos = _EvaluateSize($BASE_WIDTH, $BASE_HEIGHT, $iImageWidth, $iImageHeight) Global $hGUI = GUICreate("", $aPos[0], $aPos[1], -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME)) GUISetBkColor(0x000000) Global $idPic = GUICtrlCreatePic("", 0, 0, $aPos[0], $aPos[1]) Local $hBitMap = _SetImagetoCtrl($idPic, $hImage, $aPos[0], $aPos[1]) GUIRegisterMsg($WM_SIZE, WM_SIZE) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_DeleteObject($hBitMap) EndFunc ;==>Example Func _EvaluateSize($iBaseWidth, $iBaseHeight, $iActualWidth, $iActualHeight) Local $iVal = $iBaseWidth / $iActualWidth * $iActualHeight If $iVal <= $iBaseHeight Then Return StringSplit($iBaseWidth & "|" & $iVal, "|", $STR_NOCOUNT) $iVal = $iBaseHeight / $iActualHeight * $iActualWidth Return StringSplit($iVal & "|" & $iBaseHeight, "|", $STR_NOCOUNT) EndFunc ;==>_EvaluateSize Func _SetImagetoCtrl($idPic, $hImage, $iWidth, $iHeight) Local $hResize = _GDIPlus_ImageResize($hImage, $iWidth, $iHeight) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hResize) _GDIPlus_ImageDispose($hResize) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) Return $hHBitmap EndFunc ;==>_SetImagetoCtrl Func WM_SIZE($hWnd, $nMsg, $wParam, $lParam) AdlibRegister(_ResizeImage, 5) Return 1 EndFunc ;==>WM_SIZE Func _ResizeImage() AdlibUnRegister(_ResizeImage) Local $tRECT = _WinAPI_GetClientRect($hGUI) Local $iWidth = $tRECT.right - $tRECT.left + 1 Local $iHeight = $tRECT.bottom - $tRECT.top + 1 Local $aPos = _EvaluateSize($iWidth, $iHeight, $iImageWidth, $iImageHeight) If $aPos[0] > $iImageWidth Then ConsoleWrite(@CRLF & "MAXIM Width" & $aPos[0] & " \ " & $iImageWidth) Else If $aPos[1] > $iImageHeight Then ConsoleWrite(@CRLF & "MAXIM Height" & $aPos[1] & " \ " & $iImageHeight) Else _WinAPI_MoveWindow(GUICtrlGetHandle($idPic), 0, 0, $aPos[0], $aPos[1]) $hBitMap = _SetImagetoCtrl($idPic, $hImage, $aPos[0], $aPos[1]) ConsoleWrite(@CRLF & "LIMIT " & $aPos[0] & " \ " & $iImageWidth) EndIf EndIf EndFunc ;==>_ResizeImage
  11. Thank you for your effort. Unfortunately, the script doesn't help me for what I need, because the pictures lose their clarity when I maximize the GUI form. For example the picture below is 960x640, when I maximize Gui, the picture spreads across the screen, which is wrong, because my screen is much larger than the resolution of the picture. The picture must be centered in the middle of the GUI, and displayed at its original resolution, even if the gui form is maximized, across my entire screen. Basically, when I maximize GUI form, the picture must have the limit to increase to original resolution, no more. It would be correct for the picture to open as in screenshot number 2.
  12. Thanks for your help! The script is close to the truth, but it should be able to display the image at its maximum resolution, but no more than that. For example, if an image has 960x640, the image should be displayed at maximum this resolution, not higher than that. Basically, I would like it to behave like "windows photo viewer" I have attached a video below:
  13. I have a problem with my resize form with full image script... I have already searched the forum and I found some examples, but is not work correctly for me, so I tried to solve this problem myself. I have a resizable Gui form, $ WS_SIZEBOX. In this Gui, I want to display a larger image, and when I resize the GUI, the image should be proportional, without losing its clarity. This is my script, it works relatively well, but in many cases, the image is not fully displayed. Thanks in advance #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> _GDIPlus_Startup() $IMAGINE_PATH = "C:\Users\Windows 10 Pro\Desktop\image4.jpg" Global $IMAGINE_GDI, $LATIME, $INALTIME, $PICTURE Global $LATIME_IMG, $INALTIME_IMG _GetSize() $FORM_LATIME = 0 $FORM_INALTIME = 0 $Form2 = GUICreate("TEST", 1300, 750, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP)) AdlibRegister('_StructuraImagine', 10) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _GetSize() $IMAGINE_GDI = _GDIPlus_ImageLoadFromFile($IMAGINE_PATH) $LATIME = _GDIPlus_ImageGetWidth($IMAGINE_GDI) $INALTIME = _GDIPlus_ImageGetHeight($IMAGINE_GDI) _GDIPlus_ImageDispose($IMAGINE_GDI) _GDIPlus_Shutdown() EndFunc ;==>_GetSize Func _StructuraImagine() $Size = WinGetClientSize($Form2) If $Size[0] <> $FORM_LATIME Or $Size[1] <> $FORM_INALTIME Then $FORM_LATIME = $Size[0] $FORM_INALTIME = $Size[1] _Modifica_Imagine() EndIf EndFunc ;==>_StructuraImagine Func _Modifica_Imagine() GUICtrlDelete($PICTURE) If $LATIME > $FORM_LATIME Or $INALTIME > $FORM_INALTIME Then If $INALTIME > $LATIME Then $RATIE = $LATIME / $INALTIME $LATIME_IMG = $FORM_INALTIME $INALTIME_IMG = $FORM_INALTIME $LATIME_IMG = $INALTIME_IMG * $RATIE EndIf If $LATIME > $INALTIME Then $RATIE = $LATIME / $INALTIME $LATIME_IMG = $FORM_LATIME $INALTIME_IMG = $FORM_INALTIME $LATIME_IMG = $INALTIME_IMG * $RATIE EndIf EndIf $PICTURE = GUICtrlCreatePic($IMAGINE_PATH, 0, 0, $LATIME_IMG, $INALTIME_IMG) EndFunc ;==>_Modifica_Imagine
  14. Any idea ?
×
×
  • Create New...