I'm thinking of using the WinWaitActive function to play a sound file every time the currently active program finished a task (ie. After Effect finished rendering, Word finished saving, etc.).
From what I know about WinWaitActive, I'll need to write a script for each internal process of each application. That's a huge amount of automation scripts. Is there any way to make a single script that will work with all programs and processes?
Try something like this:
#include<array.au3>
Global $window_Array[1]
$window = "dokument - wordpad"
checkWin()
;ConsoleWrite(_ArrayToString($window_Array, #CR))
Func checkWin()
Global $var = WinList()
For $i = 1 To $var[0][0]
If $var[$i][0] <> "" Then _ArrayAdd($window_Array, $var[$i][0])
Next
If _ArraySearch($window_Array, $window, 0, 0, 0) <> - 1 Then
MsgBox(0, "", "Found!")
Else
MsgBox(0, "", "Not Found!")
EndIf
EndFunc ;==>checkWin
This script does not pause until the button is enabled:
While Not ControlCommand('Network config', '','QWidget1', 'IsEnabled', '')
Sleep(500)
WEnd
The button is grayed out initially.
Windows title: Network config
CLassnameNN: QWidget1
How can I fix this?
Local $cE = 0
AdlibRegister("enControl", 1000)
While 1
WEnd
Func enControl()
Local $wActive = WinActivate("Network config")
Local $isActive = WinActive($wActive)
If $isActive = 0 Then
ConsoleWrite("Could not make window active")
Return
EndIf
$cE = ControlEnable("Network config", ", "QWidget1")
If $cE = 0 Then
ConsoleWrite("Could not enable the control")
Else
ConsoleWrite("Succesfully enabled the control")
Sleep(500)
EndIf
EndFunc
Making sure the window is active and using ControlEnable function should help.
Hello there everyone,
I have recently downloaded a bot for a game that I play, this bot uses Autoit to automate movements on screen, alongside Autoit I downloaded some scripts that allow me to automate in-game movements. I downloaded these scripts on my main pc and my laptop so I can run them on 2 accounts if need be. The download is exactly the same and although the bot works perfectly on my PC, it does something weird on my laptop:
The cursor seems to be able to go to places I have specificly told it to go but once it needs to imagesearch or pixelsearch it simply stops. The program doesnt stop running and will continue performing the actions that it can perform, at the right timing, however all imagesearching functions get left out.
The only major diference between the pc and laptop is that the laptop is running windows 8.
Things Iv tried by searching prior to asking here:
I have read that imagesearch.dll should be in sysWOW64 in order for it to work and I beleive I have done that by copying the DLL files and pasting them in syswow64. That did not help.
I also tried adding #requireadmin to the top of the script which did not help either.
this is happening with ALL the scripts I downloaded. They all work on pc and none work on laptop. I dont have alot of understanding with this code as I did not write it myself. However I have familirized myself with it a little as I do edit it for my personal uses on my pc and make it work very well. So I thought that it not functioning on my laptop must be some amateur mistake about windows 8 or similar.
here is an example script.
#RequireAdmin
#include <Misc.au3>
HotKeySet("{[}", "MakeLock")
HotKeySet("{z}", "Start")
HotKeySet("{ESC}", "_Exit")
HotKeySet("{x}", "Shafts")
HotKeySet("{c}", "Heads")
HotKeySet("{v}", "bsb")
$handle = WinGetHandle("Wurm Online", "")
Global $running=0
Global $shaftLoc
Global $headLoc
Global $shaft=0
Global $head=0
Global $bsb=0
Global $bsbloc
Func _Exit()
Exit
EndFunc ;==>_Exit
Func Getfrombsb()
MouseMove($bsbloc[0], $bsbloc[1], 5)
MouseDown("left")
Sleep(100)
MouseMove($shaftloc[0], $shaftloc[1], 5)
Sleep(100)
MouseUp("left")
sleep(2500)
send ("4")
sleep(250)
Send("{Enter}")
sleep(3000)
EndFunc
Func Shafts()
MsgBox(0, "", "title of items")
$shaft=1
EndFunc
Func Drop()
MouseMove($shaftloc[0], $shaftloc[1], 5)
MouseDown("left")
Sleep(250)
MouseMove($bsbloc[0], $bsbloc[1], 5)
MouseUp("left")
EndFunc
Func bsb()
MsgBox(0, "", "item in bsb")
$bsb=1
EndFunc
Func Heads()
MsgBox(0, "", "Click on what ur continuing")
$head=1
EndFunc
Func continue()
MouseMove($shaftloc[0], $shaftloc[1], 5)
MouseClick("left")
Sleep(100)
MouseMove($shaftloc[0], $shaftloc[1], 5)
MouseClick("right")
Sleep(1000)
$line = GetLine()
If IsArray($line) Then
Local $random2 = Random(200, 250, 1)
MouseMove($line[0], $line[1]+3*16-8, 5)
Sleep($random2-51)
MouseMove($line[0]+120, $line[1]+3*16-8, 5)
Sleep($random2+38)
MouseMove($line[0]+120, $line[1]+3*16-8+2*16, 5)
Sleep(500)
MouseMove($line[0]+200, $line[1]+3*16-8+2*16, 5)
Sleep($random2+161)
MouseMove($line[0]+200, $line[1]+3*16-8+2*16+44, 25)
Sleep($random2)
MouseClick("left")
EndIf
EndFunc
Func Start()
if $running==0 Then
$running=1
TrayTip("", "Macro started", 5)
ElseIf $running==1 Then
$running=0
TrayTip("", "Macro stopped", 5)
EndIf
EndFunc
Func GetLine()
$pos = MouseGetPos()
$samp = $pos
For $i = 0 To 48 Step 1
$samp[0] = $pos[0]+32
$samp[1] = $pos[1]+$i
$s0 = PixelGetColor($samp[0], $samp[1], $handle)
If $s0 == 0xFFFFFF Then
$s1 = PixelGetColor($samp[0]+1, $samp[1], $handle)
If $s1 == 0xFFFFFF Then
$s2 = PixelGetColor($samp[0]+2, $samp[1], $handle)
$s3 = PixelGetColor($samp[0]+3, $samp[1], $handle)
If $s2 == 0xFFFFFF AND $s3 == 0xFFFFFF Then
$line = $samp
ExitLoop
EndIf
EndIf
EndIf
$line = 0
Next
Return $line
EndFunc
While (1)
if _IsPressed("01") And $shaft==1 Then
$shaftloc = MouseGetPos()
$shaft=0
MsgBox(0, "", "shaft loc loaded")
endif
if _IsPressed("01") And $head==1 Then
$headloc = MouseGetPos()
$head=0
MsgBox(0, "", "head loc loaded")
EndIf
if _IsPressed("01") And $bsb==1 Then
$bsbloc = MouseGetPos()
$bsb=0
MsgBox(0, "", "bsb loc loaded")
EndIf
if $running==1 Then
Getfrombsb()
Local $random = Random(24000, 25000, 1)
continue()
Sleep($random)
sleep(500)
Drop()
sleep(2000)
Drop()
sleep(2000)
EndIf
Sleep(10)
WEnd
After watching exactly what it does and does not do, I can see that problem arrises with the section of code below it does everything up until; $line = GetLine()
$line = GetLine()
If IsArray($line) Then
Local $random2 = Random(200, 250, 1)
MouseMove($line[0], $line[1]+3*16-8, 5)
Sleep($random2-51)
MouseMove($line[0]+120, $line[1]+3*16-8, 5)
Sleep($random2+38)
MouseMove($line[0]+120, $line[1]+3*16-8+2*16, 5)
Sleep(500)
MouseMove($line[0]+200, $line[1]+3*16-8+2*16, 5)
Sleep($random2+161)
MouseMove($line[0]+200, $line[1]+3*16-8+2*16+44, 25)
Sleep($random2)
MouseClick("left")
EndIf
EndFunc
Any help would be appreciated. And although I am not familiar with code that much I do know how to use stack overflow well as my brother is a .net developer. I will mark the question that helps me and upvote and such.
Kind regards.
I know what your problem is.. I think. Try turning the output of PixelGetColor() into Hex.
Also, when it outputs, it doesnt include the "0x" at the beginning of the color tag.
So, you could say:
#Include <Misc.au3> ;for the _ispressed() function
Do
Until _IsPressed("01") ;wait for click
$mouse = MouseGetPos() ;Get cursor info
$color = Hex(PixelGetColor($mouse[0], $mouse[1]), 6) Get info on the pixel under the mouse.
;Lets just say the color is white
If $color == "FFFFFF" Then
MsgBox(0, "Success", "Colors match!")
EndIf
As for the ImageSearch not working, that could be a problem with AutoHotKey's compatability with Windows 8. Because of AutoIt not having a ImageSearch function, developers use AutoHotKey's ImageSearch function, and wrap it up in an AutoIt library. That may be where the problem is cominh
I need this script to work, but without using _IEFormGetObjByName or _IEFormGetCollection, and while knowing only the Name of the radio buttons.
$oIE = _IE_Example ("form")
$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName ("input")
For $element In $oArray
If $element.Name = "radioExample" Then
_IEFormElementRadioSelect ($oDoc,2, "radioExample", 1, "byIndex")
msgbox(0,"","Found it")
Endif
Next
_IEFormElementGetValue & _IEAction work great, just reference them to the $oElement, and search for an appropriate $element.Name, but I can't get the _IEFormElementRadioSelect to work.
The only difference between the _IEFormElementRadioSelect command from the example script found in the AutoIt helpfile is the reference to $oDoc. In the helpfile this is $oForm, which is found with a _IEFormGetObjByName, which I can't use (the site I'm automating doesn't return any forms).
Replace your _IEFormElementRadioSelect with _IEAction($element, "click")
Try this example; you can see the radio items being selected as the script runs:
#include <IE.au3>
$oIE = _IE_Example("form")
$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName("input")
For $element In $oArray
If $element.Name = "radioExample" Then
_IEAction($element, "click")
Sleep(2000)
EndIf
Next
I'm writing an automation script with autoit: http://www.autoitscript.com/autoit3/index.shtml. In the process I need to take a screenshot of a user selected area.
How can I recognize the mouse-drag select operation with Autoit 3? I basically need some way to get the coordinates of the selected rectangle...
rasim from the Autoit forums was kind enough to answer this question of mine with a working example: http://www.autoitscript.com/forum/index.php?showtopic=86894&st=0&gopid=623824&#entry623824
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <ScreenCapture.au3>
Global Const $WM_LBUTTONDOWN = 0x0201
Global $hDLL = DllOpen("User32.dll")
Global $Drag = False
Global $aCoord_Start
Global $aCoord_End
Global $iLeft, $iTop, $iRight, $iBottom
Global $sCapture = False
HotKeySet("{Esc}", "_Exit")
Global $pStub_MouseProc = DllCallbackRegister ("_Mouse_Handler", "int", "int;ptr;ptr")
Global $hHookMouse = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($pStub_MouseProc), _WinAPI_GetModuleHandle(0), 0)
While 1
If $sCapture Then
$sCapture = False
_ScreenCapture_Capture(#ScriptDir & "\Capture.jpg", $iLeft, $iTop, $iRight, $iBottom)
EndIf
Sleep(100)
WEnd
Func _Mouse_Handler($nCode, $wParam, $lParam)
If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookMouse, $nCode, $wParam, $lParam)
Switch $wParam
Case $WM_LBUTTONDOWN
$aCoord_Start = MouseGetPos()
Case $WM_MOUSEMOVE
If _IsPressed("01", $hDLL) Then $Drag = True
Case $WM_LBUTTONUP
$aCoord_End = MouseGetPos()
If $Drag = True Then
$Drag = False
If $aCoord_Start[0] < $aCoord_End[0] Then
$iLeft = $aCoord_Start[0]
$iRight = $aCoord_End[0]
Else
$iLeft = $aCoord_End[0]
$iRight = $aCoord_Start[0]
EndIf
If $aCoord_Start[1] < $aCoord_End[1] Then
$iTop = $aCoord_Start[1]
$iBottom = $aCoord_End[1]
Else
$iTop = $aCoord_End[1]
$iBottom = $aCoord_Start[1]
EndIf
$sCapture = True
Return 0
EndIf
EndSwitch
Return _WinAPI_CallNextHookEx($hHookMouse, $nCode, $wParam, $lParam)
EndFunc
Func _Exit()
DllCallbackFree($pStub_MouseProc)
_WinAPI_UnhookWindowsHookEx($hHookMouse)
DllClose($hDLL)
Exit
EndFunc