Jump to content

İleri düzey AutoIT örnekleri


sk8er_boi
 Share

Recommended Posts

Yardım dosyasındaki örneğe ek yapalım... Incelersin, kolay gelsin...

[codebox]#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
Local $oIE, $GUI_Button_Back, $GUI_Button_Forward
Local $GUI_Button_Home, $GUI_Button_Stop, $msg

$oIE = ObjCreate("Shell.Explorer.2")

; Create a simple GUI for our output
Local $GUI = GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
_GUICtrlCreateObj($oIE, 10, 40, 600, 360,$GUI)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 330, 420, 100, 30)

GUISetState(@SW_SHOW,$GUI) ;Show GUI

$oIE.navigate("http://www.google.com")

; Waiting for user to close the window
While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $GUI_Button_Home
$oIE.navigate("http://www.autoitscript.com")
Case $msg = $GUI_Button_Back
$oIE.GoBack
Case $msg = $GUI_Button_Forward
$oIE.GoForward
Case $msg = $GUI_Button_Stop
$oIE.Stop
EndSelect

WEnd
GUIDelete()
EndFunc ;==>Example

Func _GUICtrlCreateObj(ByRef $Obje,$objx,$objy,$objw,$objh,$hwnd = 0)
Local $OBJ_GUI = GUICreate("", $objw, $objh, $objx, $objy, 1073807360, 0, $hwnd)
Local $GC_OBJ = GUICtrlCreateObj($Obje, 0, 0, $objw + 20, $objh + 20)
GUISetState(@SW_SHOW,$OBJ_GUI)
GUISwitch($hwnd)
Return $GC_OBJ
EndFunc[/codebox]

Link to comment
Share on other sites

  • 3 hafta sonra ...

[b]Arkadaşlar Ben Şöyle birşey istiyorum mümkünmüdür bilmiyorum
Screen Alıp Atıyorum
1 yazdığım yer Hp Potumuz
2 yazdığım yer Mp Potumuz
Bunları Bana Oto Basıcak Belirli Biryerden Aşşağı indiğinde kendisi basıcak varmı böyle birşeu ?
[/b]

[Spoiler][img]http://www.tnctr.com/uploads/imgs/pre_1332355225__adsz.jpg[/img][/Spoiler]

Edited by Fox
Link to comment
Share on other sites

[quote name='blue_life' date='02 March 2012 - 10:05 ' timestamp='1330675519' post='1163790']
Yardım dosyasındaki örneğe ek yapalım... Incelersin, kolay gelsin...

[codebox]#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
Local $oIE, $GUI_Button_Back, $GUI_Button_Forward
Local $GUI_Button_Home, $GUI_Button_Stop, $msg

$oIE = ObjCreate("Shell.Explorer.2")

; Create a simple GUI for our output
Local $GUI = GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
_GUICtrlCreateObj($oIE, 10, 40, 600, 360,$GUI)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 330, 420, 100, 30)

GUISetState(@SW_SHOW,$GUI) ;Show GUI

$oIE.navigate("http://www.google.com")

; Waiting for user to close the window
While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $GUI_Button_Home
$oIE.navigate("http://www.autoitscript.com")
Case $msg = $GUI_Button_Back
$oIE.GoBack
Case $msg = $GUI_Button_Forward
$oIE.GoForward
Case $msg = $GUI_Button_Stop
$oIE.Stop
EndSelect

WEnd
GUIDelete()
EndFunc ;==>Example

Func _GUICtrlCreateObj(ByRef $Obje,$objx,$objy,$objw,$objh,$hwnd = 0)
Local $OBJ_GUI = GUICreate("", $objw, $objh, $objx, $objy, 1073807360, 0, $hwnd)
Local $GC_OBJ = GUICtrlCreateObj($Obje, 0, 0, $objw + 20, $objh + 20)
GUISetState(@SW_SHOW,$OBJ_GUI)
GUISwitch($hwnd)
Return $GC_OBJ
EndFunc[/codebox]
[/quote]

@blue_life sizin bu örneğe birde arama çubuğu eklenebilirmi
veya bu örneğe göre

[codebox]
Opt("GUIResizeMode", 768)
Global $MY_OIE = ObjCreate("Shell.Explorer.2")
Global $MY_GUI = GUICreate("MİNİ EXPLORER", 640, 480, -1, -1, 0x00040000 + 0x00020000 + 0x00010000)
$IE_OBJECT = GUICtrlCreateObj($MY_OIE, 0, 0, 640, 456)
GUICtrlSetResizing(-1, 102)

GUISetState(@SW_SHOW)

$MY_OIE.navigate("www.google.com")
DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit

EndSwitch
WEnd
[/codebox]

Link to comment
Share on other sites

bana özel birşey değil mesela x:632 y:108 kırmızı olduğunda şuna bas gibi gibi birşey

[b][color="#0000FF"]blackman12[/color][/b][color="#FF0000"]: sana daha önce bunun örneği var demiştim forumda neden ısrar ediyorsun anlamadım. incelemen gereken kod bu: PixelGetColor ( x , y [, hwnd] )[/color]

Link to comment
Share on other sites

@MeHMeTBeN

Tabiki ekleyebiliriz. Kısaca, objeyi biraz aşağıya alıp, üst kısıma input eklersin. Bu kadar basit.
Mesela;

[codebox]Opt("GUIResizeMode", 768)
Global $MY_OIE = ObjCreate("Shell.Explorer.2")
Global $MY_GUI = GUICreate("MİNİ EXPLORER", 640, 480, -1, -1, 0x00040000 + 0x00020000 + 0x00010000)

Global $IE_GOOGLE = GUICtrlCreateInput("", 510, 4, 125, 24, -1)
GUICtrlSetFont(-1, 10, 800, 0)
GUICtrlSetResizing(-1, 4 + 32 + 512)

Global $IE_OBJECT = GUICtrlCreateObj($MY_OIE, 0, 32, 640, 424)
GUICtrlSetResizing(-1, 102)
GUISetState(@SW_SHOW)

$MY_OIE.navigate("www.google.com")
DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $IE_GOOGLE
_IE_GOOGLE_SEARCH(StringStripWS(GUICtrlRead($IE_GOOGLE), 3))

EndSwitch
WEnd

Func _IE_GOOGLE_SEARCH($S_Text)
Local $Goodle_Adress = "http://www.google.com.tr/"
If $S_Text <> "" Then $Goodle_Adress &= "#hl=tr&q=" & $S_Text
$MY_OIE.navigate($Goodle_Adress)
EndFunc ;==>_IE_GOOGLE_SEARCH[/codebox]

@Fox

Kısacası bir döngü içinde PixelGetColor kullanarak, belirlediğin konumlardaki renk değerini alıp, daha önceki belirlediğin renk değeriyle karşılaştırırsın. Renkler uyuşuyorsa, istediğini yaptırırsın. Yardım dosyasında gerekli örnekler vardı. Ayrıca forumda da bu konuda bir çok örnek vardı.
Neyse basit bir şey verebilirmisin dersen;

[codebox]Local $Pixel_X = 100
Local $Pixel_Y = 100
Local $Pixel_Color = "0xFFFFFF" ;Renk değerimiz Beyaz olsun

Local $PGet_Color
While 1
$PGet_Color = PixelGetColor($Pixel_X, $Pixel_Y) ;x-y
If $PGet_Color = $Pixel_Color Then
MsgBox(64,"BlueLife","Ne yaptırmak istiyorsan, bu mesajı silip eklersin")
EndIf
Sleep(50) ; Cpu Save
WEnd[/codebox]

Renkleri kodlarını almak için ben, Xinec ColorConverter 3.02 programını kullanıyorum.
Programı açıp, ikinci kutuya farenle tıklatıp bırakmadan fareni istediğin yere sürükleyip renk kodunu bulabiiyorsun.
[color="#0000FF"][u]http://bluelife.zxq.net/Files/Autoit/Tools/Pixel/xcc.rar[/u][/color]

Link to comment
Share on other sites

[quote name='blue_life' date='22 March 2012 - 08:34 ' timestamp='1332405284' post='1173405']
@Fox

Kısacası bir döngü içinde PixelGetColor kullanarak, belirlediğin konumlardaki renk değerini alıp, daha önceki belirlediğin renk değeriyle karşılaştırırsın. Renkler uyuşuyorsa, istediğini yaptırırsın. Yardım dosyasında gerekli örnekler vardı. Ayrıca forumda da bu konuda bir çok örnek vardı.
Neyse basit bir şey verebilirmisin dersen;

[codebox]Local $Pixel_X = 100
Local $Pixel_Y = 100
Local $Pixel_Color = "0xFFFFFF" ;Renk değerimiz Beyaz olsun

Local $PGet_Color
While 1
$PGet_Color = PixelGetColor($Pixel_X, $Pixel_Y) ;x-y
If $PGet_Color = $Pixel_Color Then
MsgBox(64,"BlueLife","Ne yaptırmak istiyorsan, bu mesajı silip eklersin")
EndIf
Sleep(50) ; Cpu Save
WEnd[/codebox]

Renkleri kodlarını almak için ben, Xinec ColorConverter 3.02 programını kullanıyorum.
Programı açıp, ikinci kutuya farenle tıklatıp bırakmadan fareni istediğin yere sürükleyip renk kodunu bulabiiyorsun.
[color="#0000FF"][u]http://bluelife.zxq.net/Files/Autoit/Tools/Pixel/xcc.rar[/u][/color]
[/quote]

[b]gerçekten çok işime yaradı peki bunu 2 renk kodu için nasıl yapabiliriz
mesela
x:100 y:100 0x331100 olduğunda 2'e bas
x:200 y:200 0x990000 olduğunda 5'e bas gibi[/b]

Edited by Fox
Link to comment
Share on other sites

@Fox

Aşağıdaki işini görüyor mu?
[codebox]Local $Pixel_X = 100
Local $Pixel_Y = 100
Local $Pixel_Color = Binary("0x331100") ;Renk değerimiz Beyaz olsun

Local $Pixel_X2 = 200
Local $Pixel_Y2 = 200
Local $Pixel_Color2 = Binary("0x990000") ;Renk değerimiz Beyaz olsun

Local $PGet_Color
While 1
$PGet_Color = PixelGetColor($Pixel_X, $Pixel_Y) ;x-y
If $PGet_Color = $Pixel_Color Then
Send("2")
EndIf

$PGet_Color = PixelGetColor($Pixel_X2, $Pixel_Y2) ;x-y
If $Pixel_Color2 = $Pixel_Color Then
Send("5")
EndIf
Sleep(50) ; Cpu Save
WEnd[/codebox]

Edit: Sonradan aklıma geldi. Hex yerine Binary yazılacaktı :) Düzeltiyorum...

Edited by blue_life
Link to comment
Share on other sites

[b]ben şöyle birşeyler karaladım ve çalıştı
yine bir sorun var hotkeyi oyun içinde çalıştıramadım (:
alt - tab yaptığımda hotkey çalışıyor :pardon: [/b]
[code]Global $Paused
HotKeySet("q", "Pause")
Local $Pixel_X = 200
Local $Pixel_Y = 40
Local $Pixel_Color = "0x331100"

Local $Pixel_X2 = 91
Local $Pixel_Y2 = 56
Local $Pixel_Color2 = "0x331100"

Local $PGet_Color
While 1

$PGet_Color = PixelGetColor($Pixel_X, $Pixel_Y) ;x-y
If $PGet_Color = $Pixel_Color Then
Send("1")

EndIf

$PGet_Color = PixelGetColor($Pixel_X2, $Pixel_Y2) ;x-y
If $PGet_Color = $Pixel_Color2 Then
Send("3")
EndIf
Sleep(50) ; Cpu Save
WEnd
Func Pause()
$Paused = NOT $Paused
While $Paused
Sleep (50)
WEnd
EndFunc; => Pause()
[/code]

Link to comment
Share on other sites

[quote name='blue_life' date='22 March 2012 - 18:32 ' timestamp='1332441158' post='1173656']
@Fox

İlgili oyun q harifini rezerve ediyor olabilir. q yerine farklı bir hotkey atayıp dene. Eğer olmuyorsa, _IsPressed fonkisyonunu deneyebilirsin...
[/quote]

herhanqi bir tuşda denedim malesef başarız oldum
_IsPressed hakkında hiç bilgim yok :pardon:

Link to comment
Share on other sites

[codebox]
[b]_IsPressed[/b]
Check if key has been pressed


#include <Misc.au3>
_IsPressed($sHexKey [, $vDLL = 'user32.dll'])



[b]Parameters[/b]
$sHexKey Key to check for $vDLL [b][optional][/b] Handle to dll or default to user32.dll
[b]Return Value[/b]
True: 1 False: 0
[b]Remarks[/b]
If calling this function repeatedly, you should open 'user32.dll' and pass the handle.
Make sure to close the handle at end of script using DllClose.

_IsPressed() will return 1 until the key is released.
Even brief key presses can result in multiple returns within a loop.
If the code called does not include a blocking function (such as MsgBox) and the user does not require multiple returns, the script should wait until _IsPressed() returns 0 before continuing.

01 Left mouse button
02 Right mouse button
04 Middle mouse button (three-button mouse)
05 Windows 2000/XP: X1 mouse button
06 Windows 2000/XP: X2 mouse button
08 BACKSPACE key
09 TAB key
0C CLEAR key
0D ENTER key
10 SHIFT key
11 CTRL key
12 ALT key
13 PAUSE key
14 CAPS LOCK key
1B ESC key
20 SPACEBAR
21 PAGE UP key
22 PAGE DOWN key
23 END key
24 HOME key
25 LEFT ARROW key
26 UP ARROW key
27 RIGHT ARROW key
28 DOWN ARROW key
29 SELECT key
2A PRINT key
2B EXECUTE key
2C PRINT SCREEN key
2D INS key
2E DEL key
30 0 key
31 1 key
32 2 key
33 3 key
34 4 key
35 5 key
36 6 key
37 7 key
38 8 key
39 9 key
41 A key
42 B key
43 C key
44 D key
45 E key
46 F key
47 G key
48 H key
49 I key
4A J key
4B K key
4C L key
4D M key
4E N key
4F O key
50 P key
51 Q key
52 R key
53 S key
54 T key
55 U key
56 V key
57 W key
58 X key
59 Y key
5A Z key
5B Left Windows key
5C Right Windows key
60 Numeric keypad 0 key
61 Numeric keypad 1 key
62 Numeric keypad 2 key
63 Numeric keypad 3 key
64 Numeric keypad 4 key
65 Numeric keypad 5 key
66 Numeric keypad 6 key
67 Numeric keypad 7 key
68 Numeric keypad 8 key
69 Numeric keypad 9 key
6A Multiply key
6B Add key
6C Separator key
6D Subtract key
6E Decimal key
6F Divide key
70 F1 key
71 F2 key
72 F3 key
73 F4 key
74 F5 key
75 F6 key
76 F7 key
77 F8 key
78 F9 key
79 F10 key
7A F11 key
7B F12 key
7C-7F F13 key - F16 key
80H-87H F17 key - F24 key
90 NUM LOCK key
91 SCROLL LOCK key
A0 Left SHIFT key
A1 Right SHIFT key
A2 Left CONTROL key
A3 Right CONTROL key
A4 Left MENU key
A5 Right MENU key
BA ;
BB =
BC ,
BD -
BE .
BF /
C0 `
DB [
DC \
DD ]


[b]Related[/b]

[b]Example[/b]

#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")

While 1
If _IsPressed("10", $hDLL) Then
ConsoleWrite("_IsPressed - Shift Key was pressed." & @CRLF)
; Wait until key is released.
While _IsPressed("10", $hDLL)
Sleep(250)
WEnd
ConsoleWrite("_IsPressed - Shift Key was released." & @CRLF)
ElseIf _IsPressed("1B", $hDLL) Then
MsgBox(0, "_IsPressed", "The Esc Key was pressed, therefore we will close the application.")
ExitLoop
EndIf
Sleep(250)
WEnd

DllClose($hDLL)
[/codebox]




Seni tekrarında uyarmıcam!


Link to comment
Share on other sites

@Fox

[codebox]#include <Misc.au3>
Local $hDLL = DllOpen("user32.dll")
Global $Paused = False

Local $Pixel_X = 200
Local $Pixel_Y = 40
Local $Pixel_Color = "0x331100"

Local $Pixel_X2 = 91
Local $Pixel_Y2 = 56
Local $Pixel_Color2 = "0x331100"

Local $PGet_Color
While 1
If _IsPressed("51", $hDLL) Then ;Q harfi
While _IsPressed("51", $hDLL)
Sleep(250)
WEnd
$Paused = Not $Paused
EndIf

If $Paused = True Then
Sleep(50)
ContinueLoop
EndIf

$PGet_Color = PixelGetColor($Pixel_X, $Pixel_Y) ;x-y
If $PGet_Color = $Pixel_Color Then
Send("1")

EndIf

$PGet_Color = PixelGetColor($Pixel_X2, $Pixel_Y2) ;x-y
If $PGet_Color = $Pixel_Color2 Then
Send("3")
EndIf
Sleep(50) ; Cpu Save
WEnd
DllClose($hDLL)[/codebox]

Link to comment
Share on other sites

  • 2 ay sonra...

@zamaneberduşu bunlar kesinlikle daha önce değinmediğimiz konular (!).Kesinlikle buraya yazmadan önce arama bulamazsın.Ha belki sabit konularda gözüne şu çarpar ama kesinlikle işine yaramaz (!).

http://www.tnctr.com/topic/130213-autoit-v3-ile-katylymsyz-kurulum-oernekleri/

Link to comment
Share on other sites

beyler bana 'F' tuşuna basınca 'CAPSLOCK' açılacak tekrar 'F' basınca kapanacak
- yani şöyle 'CAPSLOCK' tuşu yerine 'F' basmak istiyordum
şöyle birşeyler karaladım oluyor ama bazen karışıyor
daha basit veya daha kararlı olabilirmi acaba

[code]#include <Misc.au3>
Local $hDLL = DllOpen("user32.dll")
Global $Paused = False
While 3
If _IsPressed("46", $hDLL) Then
While _IsPressed("46", $hDLL)



Opt("SendCapslockMode",0)
Sleep(150)
Send("{CAPSLOCK toggle}")


WEnd
$Paused = Not $Paused

Sleep(20) ; Cpu Save
EndIf
WEnd
DllClose($hDLL) [/code]

Link to comment
Share on other sites

[quote name='blackman12' date='07 June 2012 - 18:06 ' timestamp='1339092412' post='1209764']
Çok basit bir işi çok zor bir hale getirmişsin:
[code]
Opt("SendCapslockMode",0)
HotKeySet("f","CapsLock")
HotKeySet("e","Cikis")
While 1
WEnd

Func CapsLock()
Send("{CAPSLOCK toggle}")
EndFunc

Func Cikis()
Exit
EndFunc[/code]
[/quote]


eline sağlık çalışıyor fakat oyun içinde çalışmıyor
benim karaladıklarım oyun içindede çalışıyor neden olabilir ?

Link to comment
Share on other sites

  • 1 ay sonra...

1-) programımın background dında png resmi koymak ıstıyorum
2-) buttonlarlar var buttonlara 1.hali ve 2. hali yani basılınca baska bi resim basılmayınca baska bi resim olarak gozukmesını ıstıyorum yada button gibi çökmesini

bunlar hakkında yardımcı olabilecek arkadas var mı

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...