Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all 12506 articles
Browse latest View live

GUICtrlCreateUpdown() Weird behavior (decimal numbers)

$
0
0

Hey, can someone tell me what I'm doing wrong here?

 

I'm using 3 "updown" controls to set the desired date, but when it comes to year (4digits) when I change the value it becomes a decimal number

 

Clean up gui to show the issue:

#include <EditConstants.au3> $Form1 = GUICreate("Form1", 250, 50) $input1 = GUICtrlCreateInput(@YEAR, 100, 10, 50, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_NUMBER,$ES_NOHIDESEL,$ES_READONLY)) $btn = GUICtrlCreateButton("Read",160,10,40,21) GUICtrlCreateUpdown($input1) GUISetState(@SW_SHOW) While 1     $nMsg = GUIGetMsg()     Switch $nMsg         Case -3             Exit         Case $btn             MsgBox(0,'',GUICtrlRead($input1))     EndSwitch WEnd

Am I doing something wrong?

Thanks in advance


AutoIt Script Instantly Stopping Without An Error Message

$
0
0
 

Hey there!

 

Im currently trying to make a custom auto login using an Array!

 

I'm fairly new to AutoIt but I worked out this Code:

 

#include <Array.au3>
#include <Misc.au3>
#RequireAdmin
Local $Array2D[3][3]

HotKeySet("{ENTER}", "TogglePause")

Global $Paused = False
While 1
    If $Paused = True Then
        Blockinput(1)
        $i = 2
        $rows = UBound($Array2D) - 1
          while $i < $rows
            MouseClick("left",$Array2D[$i][1],$Array2D[$i][2], 1)
            $i = $i + 1
          wend
         Blockinput(0)
         Exit
           ElseIf _IsPressed("01") Then
             $rows = UBound($Array2D)
             ReDim $Array2D[$rows + 1][3]
             $pos = MouseGetPos()
             $posX = $pos[0]
             $posY = $pos[1]
             $Array2D[$rows -1][1] = $posX
             $Array2D[$rows -1][2] = $posY
             Sleep(100)
    EndIf
WEnd

Func TogglePause()
    $Paused = True
    EndFunc

 

It worked very well but then I tried to add left clicks to it.

Looks like this:

 

#include <Array.au3>
#include <Misc.au3>
#RequireAdmin
Local $Array2D[3][4]

HotKeySet("{ENTER}", "TogglePause")

Global $Paused = False
While 1
    If $Paused = True Then
        Blockinput(1)
        $i = 2
        $rows = UBound($Array2D) - 1
          while $i < $rows
            MouseClick($Array2D[$i][3],$Array2D[$i][1],$Array2D[$i][2], 1)
            $i = $i + 1
          wend
          sleep(3000)
         Blockinput(0)
         Exit
           ElseIf _IsPressed("01") Then
             $rows = UBound($Array2D)
             ReDim $Array2D[$rows + 1][3]
             $pos = MouseGetPos()
             $posX = $pos[0]
             $posY = $pos[1]
             $Array2D[$rows -1][1] = $posX
             $Array2D[$rows -1][2] = $posY
             $Array2D[$rows -1][3] = "left"
             Sleep(100)

             ElseIf _IsPressed("02") Then
             $rows = UBound($Array2D)
             ReDim $Array2D[$rows + 1][3]
             $pos = MouseGetPos()
             $posX = $pos[0]
             $posY = $pos[1]
             $Array2D[$rows -1][1] = $posX
             $Array2D[$rows -1][2] = $posY
             $Array2D[$rows -1][3] = "right"
             Sleep(100)
    EndIf
WEnd

Func TogglePause()
    $Paused = True
    EndFunc

 

Since then it doesn't work anymore!

It returns this:

 

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Admin\Downloads\Bot\Array.au3" /UserParams    
+>01:12:26 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0   Keyboard:00000407  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0407)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Admin\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Admin\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.12.0)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\Admin\Downloads\Bot\Array.au3
+>01:12:26 AU3Check ended.rc:0
>Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\Admin\Downloads\Bot\Array.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
+>01:12:26 AutoIt3.exe ended.rc:0
+>01:12:26 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 0.5291

 

I don't have any Idea why it does that. Pls help!

 

 

 

Help with a simple pixelsearch script

$
0
0

Hello, I've spent a lot of time this week (over 20 hours) trying to perfect a script that I need but with no real success. I've mostly used macro software that are user friendly but they aren't very efficient. I almost succeeded with one software but it caused problems with my mouse, the script wouldn't perform the actions I needed fast enough so it would move my mouse and cause problems.

 

About the script: 

 

- There are 27 objects placed in horizontal lines, in total 3 rows with 9 objects in each row. They are equidistant from one another so it would look like this:

 

1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8 9

 

Each number is a bar with 2 colors like a percentage, when the percentage is 100% the bar is fully green and when it's 1% it's almost completely red, when it's 100% red the object disappears in this manner:

 

1 2 3 4 5 6 7 8 9

1 2 3 4 6 7 8 9 1

2 3 4 5 6 7 8 9

 

In this case the 5th object in the second row became completely red and disappeared, the remaining objects moved up 1 spot and there are now 28 objects. The goal of my script is to pixel search the red color at 29 different spots for the 29 objects at a specific coordinate of when the bar is 70% red, if the bar is 70% red then it will detect a red pixel instead of a green one at that coordinate: YraOt0q.png

When it detects a red pixel, it will select the object by left clicking at the red pixel and then press delete to remove the object. Once this process is done, I will manually reselect the 28 objects with an addtional new 29th object with a box using my mouse, this last part will be manual, but if the first part that is scripted isn't instantanous so it nterferes with my mouse and I'm not able to reselect 29 objects with the newly added one. The bars will become red quickly, maybe 3-4 red pixels per second, so I have to be able to reselect 29 objects and enable the script to delete 1 object as fast as possible to be able to repeat this 3 times in a second.

 

This is what my original script in that software looked like:

scAPxbB.png

xXTp31M.png

8vSjndt.png

 

Again, this script works, but it moves my mouse so I'm not able to reselect stuff quickly enough (I see my mouse moving on the screen and the final mouse location is different every time). When I press F1 the script should turn on, and constantly check for red pixels at those 29 locations, if one is found it will select it by clicking there and pressing delete. If another red pixel appears at the 29 spots a minute later it will do it again automatically without me pressing hotkeys. To disable the script I will repress F1,

_Singleton; 1 instance; but newest one

$
0
0

Hello,

 

I think I have a problem, that probably have more of you.

 

First of all I want that only one instance of my script (au3 and not a compiled on) is running.

But if I change the source-Code I want to kill the old script und start the newer script.

Second. If I change my script in the source-code I want to reload it.

Reload doesn't work easy.

I tried to do it by a function, where I check if the modification-date of the file has changed.

But I can't check, if theres anonther script running.

 

Can you help me?

 

Thank U.

Bye

Adding Text

$
0
0

Hello, I found that its quite challenging to do this:

 

text.txt:

  1. Hello, I am a text file :). I love line No. 1

I want to change it like this:

  1. I am line No. 1 now :P
  2.  
  3. Hello, I am a text file :). I love line No. 1

How can I do this in AutoIt without storing it?

Spoiler

Thanks in advance! :)

 

TD :)

ControlCommand is not working

$
0
0

Hi all,

This is my code. It is giving me the currect line number but it won't give me the right line text.

  1. Local $title = WinGetTitle("[CLASS:SciTEWindow]")
  2.  
  3. Global $Current_lineNumber = ControlCommand($title, "S", 350, "GetCurrentLine"," ")
  4.  
  5. Global $CurrentLine_Text = ControlCommand($title, "S", 350, "GetLine", $Current_lineNumber)
  6.  
  7. MsgBox(0,"", "Line Number is = " & $Current_lineNumber & " Text is =  " & $CurrentLine_Text)

This is the result

 

Attached Thumbnails

  • 000087.jpg

_ArrayAdd() function not compatable with old version

$
0
0
I just updated to the newest version of AutoIT and when I add a line of text containing "|" characters to my array using _ArrayAdd(), the array ends up with each element containing a part of my string broken at "|".
 
So, if I had a string like "A|B|C|D", and I did an _arrayAdd($ar, "A|B|C|D), my array then contains 6 elements:
[0] = 5
[1] = A
[2] = B
[3] = C
[4] = D
 
I see that the calling syntax in the old AutoIT version is quite different than the new syntax:
old:
_ArrayAdd(ByRef $avArray, $vValue)
 
new:
_ArrayAdd ( ByRef $aArray, $vValue [, $iStart = 0 [, $sDelim_Item = "|" [, $sDelim_Row = @CRLF [, $hDataType = 0]]]] )
 
The new syntax is not backwards compatible.
 
Sample code:
#include <Array.au3> global $ar, $str, $outstr = "" $str = "A|B|C|D" $ar = stringsplit("","") _ArrayAdd($ar, $str) $outstr &= ubound($ar) & @crlf for $x = 0 to ubound($ar) - 1      $outstr &= $ar[$x] & @CRLF Next msgbox(0, "INFO", $outstr)
New Version info: Version 3.4.4   Jul 13 2014 20:07:38
 
Old Version info: Version 3.3.6    Dec 30 2013 15:53:31

 

Typo in helpfile


Change UserAgent in Firefox

$
0
0

Hi,

need help to change in firefox useragent

 

My script is very simple:

   Run('"C:\Program Files\Mozilla Firefox\firefox.exe"')
   Sleep(5000)
   Send("http://www.google.com")
   Send("{ENTER}")
   Sleep(5000)

...

So,i need to open browser each time with new UserAgent

Currently i am using User Agent Switcher add for firefox and with mouse move/select manual useragent

 

but,i am curious if t could set useragent direct with au3 function

 

*NOTE: Only for Firefox

How do we reconcile the results of the function _IsPressed() with HotKeySet()

$
0
0
Respected programmers, tell me how to get the arguments in the correct format for the function HotKeySet () from the results function _IsPressed ()?
 
I need to allow the user to choose the key(eg left/right arrow), when pressed, will be called the desired function through HotKeySet ().
 
Thanks!

How to get nth line text from a given text with Regexp

$
0
0

Hi all,

How to get nth line text from a given text with Regexp. For example, i have a text from a window which contains 15 lines.

And i need to get the text from 5th line (it may vary). How to do it. I have tried some patters like "(^ &)\5" and "[^ $]{5}". But didn't work.

Overlay PNG on Animated GIF

$
0
0

Hello friends, I'mw orking on a loginf orm for one of my projects, and I'm having a problem. I want to overlay some pngs on top of an animated gif.

 

I'm tryign to do this by making a child window then using gdi to render the png to the child window, but the png wont render on the child window.

 

The files including the script are at

 

http://prodynamics.tk/login.zip

 

sorry it was too big to upload to the forum ( :

Are there any examples of old 2d scrolling games using gdiplus

$
0
0

The title says it all really. I've tried to achieve this using arrays  & dividing the gui into chunky blocks , but so far have fail.... 

 

Any idea would be appreciated.

 

Thanks

Keeping one window inside a second window

$
0
0

Hello all, I have two windows my script creates but I would like to always keep the second window inside the first. I am able to bring it back down if it goes too far up, and back right if it goes too far left, but I'm stumpped on how to bring it up if its too far down and left if it's too far right, I've spent the better part of a half an hour trying different calculations but I just can't seem to get it to position itself back to the right place, and if the child window goes in the bottom left corner it glitched back and fourth between the bottom and left side of the gui.

 

I know there has to be an easier way to do it, I've seen it in the past. Anyways here's my (faulty) code.

AutoIt         
#include <File.au3> #include <Constants.au3> #include <WindowsConstants.au3> ;~ #include "_GUIResourcePic.au3" #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> Global $sFile, $label1 _GDIPlus_Startup() ; Make GUI Global $hGuix = GUICreate("Secure Instant Messenger - Login - BETA", 720, 405) Global $iCtrlID = GUICtrlCreatePic("", 0, 0, 720, 405, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetState(-1, $GUI_DISABLE) ;~ _GUICtrlPic_SetImage($iCtrlID, "", True) GUISetState() $mainpos = WinGetPos("Secure Instant Messenger - Login - BETA")  DisplayImage(@ScriptDir&"\loginform.png", $mainpos[0]+30, $mainpos[1]+ 270) Global $iPlay = 1 ;~ $Label1 = GUICtrlCreateLabel("Version 0.1.0.0", 152, 64, 139, 19) ;~ GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; Loop till end While 1     Switch GUIGetMsg()         Case -3             Exit     EndSwitch     if WinExists(@ScriptDir&"\loginform.png") Then     $mainpos = WinGetPos("Secure Instant Messenger - Login - BETA")     $loginpos = WinGetPos(@ScriptDir&"\loginform.png")     if $loginpos[0] < $mainpos[0] Then         WinMove(@ScriptDir&"\loginform.png", "", $mainpos[0]+5, $loginpos[1])     EndIf     if $loginpos[1] < $mainpos[1] Then         WinMove(@ScriptDir&"\loginform.png", "", $loginpos[0], $mainpos[1]+40)     EndIf     if $loginpos[0]+$loginpos[2] > $mainpos[2]+$mainpos[0] Then         WinMove(@ScriptDir&"\loginform.png", "", $loginpos[0]-$loginpos[3]+50, $loginpos[0]+$loginpos[2])     EndIf     if $loginpos[1]+$loginpos[3] > $mainpos[3]+$mainpos[1] Then         WinMove(@ScriptDir&"\loginform.png", "",($mainpos[3]+$mainpos[1])-(($mainpos[3]+$mainpos[1])-$loginpos[0]), ($mainpos[2]+$mainpos[0])-$loginpos[1] )     EndIf     EndIf WEnd Func DisplayImage($sFile, $iPosX = -1, $iPosY = -1, $iAlpha = 0xFF, $bTopmost = True)     Local Const $hBmp_Background = _GDIPlus_BitmapCreateFromFile($sFile) ;load the image     If @error Then Return SetError(1, 0, 0) ;image cannot be loaded     Local Const $iW = _GDIPlus_ImageGetWidth($hBmp_Background), $iH = _GDIPlus_ImageGetHeight($hBmp_Background) ;get the dimension of the background image     Local Const $hGUI = GUICreate($sfile, $iW, $iH, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST * $bTopmost, $WS_EX_TOOLWINDOW),$hguix) ;create GUI with appropriate styles and extented style (borderless transparent GUI)     GUICtrlCreateLabel("", 0, 0, $iW, $iH, Default, $GUI_WS_EX_PARENTDRAG) ;create a hidden label for GUI dragging     GUISetState(@SW_SHOW, $hGUI) ;show GUI     Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) ;define an empty bitmap where all the gfx stuff will copied to     Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the context to the bitmap to be able to copy / draw to the bitmap     _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp_Background, 0, 0, $iW, $iH) ;draw background image to the empty bitmap     ;display GDI+ with transparency on desktop     Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert GDI+ image to GDI to display it on the screen using GDI functions     Local Const $hScrDC = _WinAPI_GetDC($hGUI) ;get the device context (dc) handle of the GUI     Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) ;create a compatible dc handle     Local Const $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) ;selects the GDI bitmap object into the specified device context     Local Const $tSize = DllStructCreate($tagSIZE) ;create a $tagSIZE struct (x = width, y = height)     DllStructSetData($tSize, "X", $iW) ;set data for width     DllStructSetData($tSize, "Y", $iH) ;set data for height     Local $tSource = DllStructCreate($tagPOINT) ;create a $tagPOINT struct (x = x position, y = y position)     Local $tBlend = DllStructCreate($tagBLENDFUNCTION) ;create $tagBLENDFUNCTION struct -> see help file for more info     DllStructSetData($tBlend, "Alpha", $iAlpha) ;set the alpha channel of the GUI -> 255 = opaque, 0 = transparent     DllStructSetData($tBlend, "Format", 1) ;set the format to 1 -> bitmap has alpha channels     DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $hGUI, "handle", $hScrDC, "ptr", 0, "struct*", $tSize, "handle", $hMemDC, "struct*", $tSource, "dword", 0, "struct*", $tBlend, "dword", $ULW_ALPHA) ;display bitmap on screen     ;release resources otherwise memory will filled up (memory leak)     _GDIPlus_GraphicsDispose($hGfx)     _GDIPlus_BitmapDispose($hBitmap)     Local $aResource[7] = [$hGUI, $hScrDC, $hHBitmap, $hMemDC, $tBlend, $tSize, $tSource] ;return the handle to release it later     Return $aResource EndFunc   ;==>DisplayImage ; This function releases the resources of a specific image and closes it Func ReleaseResources(ByRef $aResource)     If Not IsArray($aResource) Then Return SetError(1, 0, 0)     If UBound($aResource) <> 7 Then Return SetError(2, 0, 0)     _WinAPI_ReleaseDC($aResource[0], $aResource[1])     _WinAPI_DeleteDC($aResource[3])     _WinAPI_DeleteObject($aResource[2])     GUIDelete($aResource[0]) EndFunc   ;==>ReleaseResources ; To fade in an image leave $bIn at default (True); to fade out specify False. ; There are also options to set the ending transparency level (0 transparent, 255 opaque), speed and delay. ; If you change the speed or delay be sure to specify $bIn and $iTrans, otherwise you'll wonder why the fade-in or out isn't what you hoped for. ; The default values are specified in the function below. Func _Fader($res1, $bIn = True, $iTrans = 255, $speed = 3, $delay = 10  )     If Not IsArray($res1) Then Return SetError(1, 0, 0)     If UBound($res1) <> 7 Then Return SetError(2, 0, 0)     Switch $bIn         Case True             For $a = 0 To $iTrans Step $speed                 DllStructSetData($res1[4], "Alpha", $a)                 DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen                 Sleep($delay)             Next         Case Else             For $a = $iTrans To 0 Step -$speed                 DllStructSetData($res1[4], "Alpha", $a)                 DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen                 Sleep($delay)             Next     EndSwitch EndFunc   ;==>_FadeIn

required image is attached

Attached Thumbnails

  • loginform.png

Need help with MouseGetPos :/

$
0
0

Hi

I'd like my script to ask me where it should click.

 

First it should ask me where I'd like it to click (maybe save the position in a variable) and then click the same position all the time.

 

I'm making a script for photoshop for inputing names and saving files each in seperate pdf.

Everything works great but  everytime I run it on different file the position I need it to click on is different.

I need it to ask me where it should click everytime I run it.

 

Here's my script:

AutoIt         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $file = FileOpen("lista.txt", 0) ; Check if file opened for reading OK If $file = -1 Then     MsgBox(0, "Error", "Unable to open file.")     Exit EndIf ; Read in lines of text until the EOF is reached While 1     Local $line = FileReadLine($file) Local $i     If @error = -1 Then MsgBox(262144,"The End", "The End !!!") ExitLoop                Clipput($line) While 1        Local $hWnd = WinWait("[CLASS:Photoshop]", "", 10)     ; Activate the Photoshop window using the handle returned by WinWait.     WinActivate($hWnd)     MouseClick("left", 562, 613, 3) ; <<<<------ THIS IS THE THING THAT BOTHERS ME <<<<-------     Sleep(1000)     Send("^v")     sleep(300)     send("^s")     Do     sleep(200)     until PixelGetColor(342, 299)=0xFFF791         sleep(200)     $i=$i+1     Send($i)     Sleep(500)     Send("{ENTER}")     Do     sleep(200)  until PixelGetColor(416, 319)=0x21A121  Send("{ENTER}")  Do     sleep(200)  until PixelGetColor(447, 438)=0xFFFFFF                 ExitLoop   WEnd WEnd FileClose($file)

Thx for your help ;)


Preventing disappearance of cursor on touch screens

$
0
0
Hello, i'd like to ask how i can prevent the disappearance of cursor on touch screens-it's like if you don't touch it for 2-3 secs it disappears until you touch again. I want to prevent tthat, if it's possible.(I'm going to use it for a script that lets the user note on screen like a pen) Thank you

P.S : if it's possible, it would only work when script is the active window

How to retrieve file path opened by process by process PID

$
0
0

I want to get the full path of some file opened by some process

for example multiple notepad processes are running and I got the PID for each notepad.exe process so when using

_ProcessGetPath

I get the path of notepad.exe not the file.txt which opened by process, Now how to retrieve the txt file path ?

Creating a borderless input?

$
0
0

I've searched but I can't seem to find an answer to this question, is it possible to make a text input control with no border?

 

And if so, how?

 

Thanks in advance, sorry if this is a basic question, I really did search the help file and forums.

Putting controls over top of a GDI animation?

$
0
0

Hello all! I have a script which was originally written for me by UEZ to help me answer the question of overlaying a png on a gif, but now I'm having another small problem. I can't seem to place controls over the animation without creating child guis for the controls.

 

Do I have to use child windows, or is there a way to get my controls to show up on top of the animation(GDI+)?

Trigger a RunOnce or Add a script to run on boot which self-deletes the boot entry?

$
0
0

Hey Guys,

I have a script that I run that requires a second part to be ran after you reboot... 

How best would I do this, the file that I want to run once after the next reboot is: \IN\PReg.exe

Obviously I could do:

RegWrite('HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce', 'P REG', 'REG_SZ', 'C:\Folder\In\PReg.exe')

 

Is there a specific way I should do it?

Viewing all 12506 articles
Browse latest View live