Jump to content

Autoit Get Fonksiyonu Nasıl Kullanabilirim


erguntunc
 Share

Recommended Posts

karaladım birşeyler ama olmadı url varsa input içine yazsın istiyorum

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form = GUICreate("Adres kontrol", 429, 216)
$siteurl = GUICtrlCreateInput("", 120, 72, 169, 21)
$Label2 = GUICtrlCreateLabel("Örnek:http://tnctr.com", 120, 40, 167, 20)
$varmiyokmu = GUICtrlCreateButton("varmı yokmu", 108, 160, 195, 33)
$Input1 = GUICtrlCreateInput("", 64, 110, 337, 21)
$Label3 = GUICtrlCreateLabel("Adres", 16, 112, 31, 17)
GUISetState(@SW_SHOW)
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

	Case $varmiyokmu
    $HTTP.Open("GET", $siteurl)
    $var = $siteurl
    if $var = $siteurl Then
    GUICtrlSetData($Input1, GUICtrlRead($siteurl) & "/egitim")
    Else
    GUICtrlSetData($Input1, GUICtrlRead($siteurl) & "Böyle bir url yok")
    Endif
	EndSwitch
WEnd
 
Edited by erguntunc
Link to comment
Share on other sites

$HTTP.Open("GET", $siteurl)
gibi kullanımı neye göre yaptın açıkçası anlayamadım?Yapmak istediğin şeyi de açıkçası anlayamadım.Eğer girilen şey url değil mi diye anlamak istiyorsan şöyle bi kalıp kullanabilirsin.

$a = StringRegExp($sURL, "(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?")
eğer url ise 1 döner değilse 0. Edited by MostWanted
Link to comment
Share on other sites

Hayır hocam öyle demek istemedim $siteurl input'a girilen urlnin /egitim uzantısı varmı yokmu onu kontrol etmek istiyorum mesela kullanıcı $siteurl inputuna http://tnctr.com girdi diyelim /forum/97-autoit/ uzantısı varmı sitede yokmu onu kontrol etmek istiyorum varsa Input1 içine http://tnctr.com/forum/97-autoit/ yazsın yoksa Böyle bir url yok yazsın böyle demek istemiştim.

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form = GUICreate("Adres kontrol", 429, 216)
$siteurl = GUICtrlCreateInput("", 120, 72, 169, 21)
$Label2 = GUICtrlCreateLabel("Örnek:http://tnctr.com", 120, 40, 167, 20)
$varmiyokmu = GUICtrlCreateButton("varmı yokmu", 108, 160, 195, 33)
$Input1 = GUICtrlCreateInput("", 64, 110, 337, 21)
$Label3 = GUICtrlCreateLabel("Adres", 16, 112, 31, 17)
GUISetState(@SW_SHOW)
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

	Case $varmiyokmu
		$sURL = GUICtrlRead($siteurl)
		$linkontrol = StringRegExp($sURL, "(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?")
		if $linkontrol then
			$isExist = HttpGet($sURL, "/eğitim") ;eğitimden başka bişi aramak istiyorsan burayı değiştir
			if $isExist Then
			GUICtrlSetData($Input1, GUICtrlRead($siteurl) & "/egitim")
			Else
			GUICtrlSetData($Input1, "Böyle bir url yok")
			Endif
		Else
			MsgBox(0, "Hata", "Girdiğiniz url geçerli değil!")
		EndIf
	EndSwitch
WEnd


Func HttpGet($sURL, $sPath = "")
	Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
	if StringLeft($sPath, 1) <> "/" then $sPath = "/" & $sPath
	$oHTTP.Open("GET", $sURL & $sPath , False)

	If (@error) Then Return SetError(1, 0, 0)

	$oHTTP.Send()
	If (@error) Then Return SetError(2, 0, 0)

	If ($oHTTP.Status = 200) Then Return True
	Return 	False

EndFunc
Kod gayet güzel çalışıyor fakat şöyle bi açığı var şimdiden görebiliyorum.Diyelim ki server çöktü veya herhangi bi nedenden dolayı o sayfaya ulaşılamazsa da bu kod "böyle bi link yok" diye dönecek.Bunu ;
 
	If ($oHTTP.Status = 200) Then Return True
satırını
 
	If ($oHTTP.Status <> 404) Then Return True
yaparak çözebilirsin.Ancak bu sefer de diyelim ki sayfa yok ama server da problem varsa kod o sayfa var diye dönecektir.Neyse çok önemli bir şey olmadığını varsayarak o durumları yoksaydım.Kısaca bağlantı da veya server da sorun yoksa bu kod çalışır :) . (Bu arada bu çocuk beni azarladı sonra gitti http get kullandı demeyesin diye not düşeyim, objeyi olutşturmadan önce http kullanmışsın ve copy paste yaptığın çok belli oluyordu çünkü en az bi kere çalıştırsan compile bile olmadığını görecektin.) Edited by MostWanted
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...