Jump to content

JohnOne

Active Members
  • Posts

    17,363
  • Joined

  • Last visited

  • Days Won

    119

Reputation Activity

  1. Like
    JohnOne got a reaction from daledale in ExitLoop not exitting   
    Implement the following into your code

    Global $ExitLoop = False ; A global variable to hold state HotKeySet("{ESC}","_ExitLoop") ; Make a function to change state to true Func _ExitLoop() ; Make a function to change state to true $ExitLoop = True EndFunc $ExitLoop = False ; Before entering your endless loop, set state to false While 1 If Not $ExitLoop Then ; Only Send if state is false Send($send1) Sleep($sleep1) Else ExitLoop ; Else exit the loop EndIf WEnd
  2. Like
    JohnOne got a reaction from fraizor in Info tool and Firefox control   
    Indeed it does work.

    The thing is, I cannot get information about the controls of the window, Specifically the WebBrowser control.
    The following msgbox from the given code says 27. It would normally say 1400, the width of the browser control (if it were available to me to pass in as a parameter)


    $hwnd = WinActivate("[CLASS:MozillaWindowClass; TITLE:Google - Mozilla Firefox]") If Not IsHWnd($hwnd) Then MsgBox(16, "Error", "$hwnd is not a handle", 3) Exit EndIf Sleep(1000) WinSetState($hwnd, "", @SW_MINIMIZE) Sleep(1000) $c = ControlGetPos($hwnd, "", "") If @error Then MsgBox(0, "ControlGetPos", @error) Else MsgBox(0, 0, $c[3]) EndIf WinSetState($hwnd, "", @SW_MAXIMIZE) Its looking more and more like I will just have to drop firefox for the time being, in favour of IE or Chrome. I dont dislike those browsers, I'm just more comfortable with FF.

    Anyway Thanks for your attention PsaltyDS.
  3. Like
    JohnOne got a reaction from fraizor in Info tool and Firefox control   
    The whole browser is a control, and could be used for instance with controlsend or controlclick.

    With IE a non active window


    $hwnd = WinActivate("Google - Windows Internet Explorer") If Not IsHWnd($hwnd) Then MsgBox(0,0,"Fail") Exit EndIf Sleep(1000) WinSetState($hwnd,"",@SW_MINIMIZE) Sleep(1000) ControlSend($hwnd,"","[CLASS:Internet Explorer_Server; INSTANCE:1]","Search String") Sleep(1000) WinSetState($hwnd,"",@SW_MAXIMIZE) Will minimize it, send string, maximize.

    If the title was Mozilla Firefox and control ID were changed to "[CLASS:MozillaWindowClass; INSTANCE:2]" the same would occur.

    But just not any more, with this new gecko control and its broken a fair few of my scripts
  4. Thanks
    JohnOne got a reaction from MarketingWithKyle in Using .NET libary with AutoIt, possible?   
    I don't believe c# libraries have classic entry points like unmanaged dlls, so dllcall will not work.
    I think I recall you have to make your dll com visible and use as an object, you should search it, there is something on the forum about it.
    EDIT: .NET CLR is nowadays possible.
     
  5. Like
    JohnOne got a reaction from ahmeddzcom in check if url exist function?   
    Try...
    ConsoleWrite( __checkConn("https://www.autoitscript.com/forum/bullshitpage") & @LF) ConsoleWrite( __checkConn("https://www.autoitscript.com/forum/") & @LF) ConsoleWrite( __checkConn("http://www.narcolepticmonkeytumor.com") & @LF) Func __checkConn($url) Return (StringLen(InetRead($url, 1)) > 0) EndFunc 
  6. Like
  7. Like
    JohnOne got a reaction from ioa747 in Tesseract Simple Example   
    There has been many questions about using tesseract of late.
    Here is a very basic example which works for me, along with the exact version of standalone tesseract executable and English language data used
    I found it some time ago at a time I thought I needed it, I do not recall from where.
    $ImageToReadPath = @ScriptDir & "\image.bmp" $ResultTextPath = @ScriptDir & "\Result" $OutPutPath = $ResultTextPath & ".txt" $TesseractExePath = @ScriptDir & "\Tesseract.exe" ShellExecuteWait($TesseractExePath, '"' & $ImageToReadPath & '" "' & $ResultTextPath & '"', "", "", @SW_HIDE) If @error Then Exit MsgBox(0, "Error", @error) EndIf MsgBox(0, "Result", FileRead($OutPutPath)) FileDelete($OutPutPath)Some Answers:
    The files contained in the download, only support English language.
    From the only documentation I got with this version...
    Original Binaries and Source can be found here: http://code.google.com/p/tesseract-ocr/I do not know where to get other languages support.
    I do not know if there is a later standalone version.
    I do not know why it does not read your image accurately.
    It does not have a virus in it.
    You can search the forums or internet to learn how to create / cut / copy / paste, or otherwise manipulate your own images.
    TesseractExample.zip
  8. Haha
    JohnOne got a reaction from MrKm in AU4 Library   
    So you have an autoit script, then what happens?
    I don't understand how a converter can replace a compiler.
    You might think you have explained this, but you have not, please detail exactly what this project aims to do, from start to finish.
  9. Confused
    JohnOne got a reaction from MrKm in AU4 Library   
    No, it's just glaringly obvious. A similar topic takes place in chat, and 5 minutes later a "new" member registers with the express intention to recruit people to do it.
    I've got no words for that, except lol.
  10. Haha
    JohnOne got a reaction from MrKm in AU4 Library   
    https://en.wikipedia.org/wiki/LOL
  11. Like
    JohnOne got a reaction from LAPIII in Absolute Beginners   
    Here is a little tutorial I decided to make. (yes another tutorial)
    It is intended for people with absolutely no knowledge of programming/scripting at all.
    It also assumes you do not know how to use autoit3 help file.
    What it does assume, is that you have installed autoit3 and scite4autoit which can be found here
    Autoit
    >
    Scite4autoit

    The most important thing to know, is how to navigate and use the helpfile
    Please do not underestimate how valuable this resource is.
    By default the help file is located in your myprograms or myprogramsx86 of you OS drive in the folder AutoIt3
    It looks like this with the ? on it, click it

    Once the helpfile loads you will see essentially two panels, the one on the left is about navigation
    The one on the right is about information, and for now, just focus on the index tab and click it
    to see something like this in the left panel

    Notice it says "Type in the keyword to find", this is where we can find what we are looking for.
    For example, if I want to find a string function, or browse all the string functions, I simply
    type "string" into the field below the prompt, and it navigates automatically to the items in the
    index, like so.

    If you highlight one of the items in the list and hit enter, or double click on an item, it will bring up
    information about that item in the right side panel, like so.

    Above I clicked on the String function and it shows me everything i need to know about that function.
    Firstly, it tells me in essence what it does. "Returns the string representation of an expression."
    Secondly, it shows me how to enter the function into scite editor "String ( expression )"
    In the scope of this post, the expession here is the paramater we pass to the function for processing.
    A paramater is any variable or literal we put inside the braces of a function.
    It also tells me the return value - "Returns a string." - a string it what is between those two quotes (text if you will)
    So what is a return value? Its what the function pumps out after you pass it the correct paramaters, you can test it
    in the example at the bottom of the right panel.
    But not before you take a look at another important part of the information, The remarks.
    "Maximum string length is 2147483647 characters (but keep in mind that no line in an AutoIt script can exceed 4095 characters.)"
    Here its telling us that if we put a string of over 4095 characters on one line in our script, it will fail.
    Never skip the remarks, it will cost you valuable time and cause you headaches.
    Every time you are going to use a function, you should have that function open in the helpfile and refer to it every step of the way.
    All the information in that panel is important, read it all, and then, notice the little button at the bottom of the example
    entitled "Open this Script", press that, and the script will automagically open in your scite4autoit editor, and is ready to run, by hitting the F5 key
    Q. What is a variable?
    A. $this_is_a_variable = "this is a literal string"; A variable will always have the $ at the beginning
    and never have a space in it (those are rules)
    Look at the example
    $var = String(10)
    ;$var is the string "10"
    ;$var is the variable here, and 10 is a literal paramater passed to the String function.
    Lets take the String function out of the equasion and consider this statement (in the scope of this post a statement is information you type into scite which is telling autoit3 something it needs to know)
    $var = 10
    Here the variable $var is now equal to the literal value 10, it is named a variable because it can change its value.
    $var = $var + 1
    $var is now equal to 11, 10 however, will always be 10.
    Lets have a look at another function, you remember how to find what we need in the helpfile? then find FileRead.
    Heres what it tells us.
    Read in a number of characters from a previously opened text file.
    This means it will read into the variable it is assigned, (think $var) the amount of individual characters we want from a file that autoit3 has already opened.
    FileRead ( "filehandle/filename" [, count] )
    This is like a prototype of the function we will enter into our editor, notice the bracets "[" and "]" they are telling us that this paramater is optional!
    more below.
    Parameters
    filehandle/filename - The handle of a file, as returned by a previous call to FileOpen. Alternatively you may use a string filename as the first parameter.
    Forget filehandle for now, filename here is the path to the file we want to read from, for example "c:usersscriptsmyfile.txt"
    count - [optional] The number of characters to read. Default read the entire file.
    Its quite common for beginners to misunderstand these [ and ], you dont type them literally into your script, they are just to let you know
    that you can completely leave out that paramater if you do not need it. In this case, if you want to read the whole file into your variable ($var)
    you would leave out everything between and including those bracets. If you do need it you would remove the bracets and enter your paramater.
    Return Value
    Success: Returns the binary/string read. @extended is set to the number of bytes/characters returned.
    This tells us the function will return a string if we gave it a filename as a paramater, since we are reading the file, the string will be the contents of the file.
    Special: Sets @error to -1 if end-of-file is reached.
    @error information tells us information about why the call to a function may have failed. It is important to check the @error state after each function you use.
    Failure: Sets @error to 1 if file not opened in read mode or other error.
    Looking at the example usually shows you how to check for errors.
    Remarks
    If a filename is given rather than a file handle - the file will be opened and closed during the function call - for parsing large text files this will be much slower than using filehandles.
    Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use a filename in this function. Use either filehandles or filenames in your routines, not both!
    Both ANSI and UTF16/UTF8 text formats can be read - AutoIt will automatically determine the type.
    A file can be read as binary(byte) data by using FileOpen with the binary flag - in this case count is in bytes rather than characters.
    There are plenty of good tutorials on this forum created by various members, which is why it is important to know how to search the forums.
    But hang on, this tutorial is about how to use the helpfile, so cast your mind way back to when we learnt how to find what we need
    It was typing it into the index tab prompt field, so type "tutorial" into that, and you will find basic tuts in their also.
  12. Like
    JohnOne got a reaction from Kambiz in Getting remainder from a division problem.   
    $rmdr = Mod(22366435,20930) MsgBox(0,0,$rmdr)
  13. Like
    JohnOne got a reaction from LxP in Run Script (x64)   
    add to script
    #AutoIt3Wrapper_UseX64=y  
  14. Thanks
    JohnOne got a reaction from seadoggie01 in what am i doing wrong here? (ScriptControl)   
    I'd try compiling as x86 and trying that.
  15. Like
    JohnOne got a reaction from Alok_Arora in Script executes only once   
    Sure.
    Post your script.
  16. Haha
    JohnOne got a reaction from guner7 in Full GUI Calculator in under 40 lines   
    1 line
    Run("calc.exe")  
  17. Like
    JohnOne got a reaction from PoojaKrishna in How do I pause a script?   
    Func _Pause() If MsgBox(1,'Paused', 'Press ok to resume, or cancel to exit') = 2 Then Exit EndFunc ;==>_Pause
  18. Like
    JohnOne got a reaction from Velislav in Tesseract Simple Example   
    There has been many questions about using tesseract of late.
    Here is a very basic example which works for me, along with the exact version of standalone tesseract executable and English language data used
    I found it some time ago at a time I thought I needed it, I do not recall from where.
    $ImageToReadPath = @ScriptDir & "\image.bmp" $ResultTextPath = @ScriptDir & "\Result" $OutPutPath = $ResultTextPath & ".txt" $TesseractExePath = @ScriptDir & "\Tesseract.exe" ShellExecuteWait($TesseractExePath, '"' & $ImageToReadPath & '" "' & $ResultTextPath & '"', "", "", @SW_HIDE) If @error Then Exit MsgBox(0, "Error", @error) EndIf MsgBox(0, "Result", FileRead($OutPutPath)) FileDelete($OutPutPath)Some Answers:
    The files contained in the download, only support English language.
    From the only documentation I got with this version...
    Original Binaries and Source can be found here: http://code.google.com/p/tesseract-ocr/I do not know where to get other languages support.
    I do not know if there is a later standalone version.
    I do not know why it does not read your image accurately.
    It does not have a virus in it.
    You can search the forums or internet to learn how to create / cut / copy / paste, or otherwise manipulate your own images.
    TesseractExample.zip
  19. Like
    JohnOne got a reaction from BlackLumiere in Arrays 101: All you need to know about them!   
    Not if you are returning it from a fuction.
    $aArray = StringSplit("123", ""); 
  20. Like
    JohnOne got a reaction from atetester132 in what am i doing wrong here? (ScriptControl)   
    I'd try compiling as x86 and trying that.
  21. Like
    JohnOne got a reaction from tremolux66 in Amending the FAQ in the help file.   
    Q: How can I make my game bot?
    A: Without any help on the forums, because it's against the rules.
    EX: None.
  22. Like
    JohnOne got a reaction from Fr33b0w in FileExist - Trigger   
    Here is an example of one way you could go about your task.


    #include <File.au3> #include <Array.au3> ; just for testing $Path = "c:software" $Summary = "summary.txt" $iCount = 0 ; to check how many folders have been processed $AFolders = _FileListToArray($Path, "*", 2) ; lists all folders to array _ArrayDisplay($AFolders) ; just for testing While 1 ; $AFolders[0] contains the amount of folders found For $i = 1 To $AFolders[0] ; loop through all found folders If FileExists($Path & $AFolders[$i] & $Summary Then ; your summery file exists here ; you can process it, but must delete, or rename it after, or it might find it twice $iCount += 1 ; you processed a file so increase the count EndIf Next If $iCount >= $AFolders[0] Then ;you processed them all ExitLoop ; bail out of loop EndIf WEnd
  23. Haha
    JohnOne got a reaction from FrancescoDiMuro in Lottery - Challenge   
    One line.
    #include "czardas.au3" _czardas() czardas.au3
    Func _czardas() Local $a2[3] = ["lost", "won", 5 & Random(1, 49, 1)] While Not StringInStr($a2[2], "|", 0, 6) $a2[2] = StringRegExpReplace($a2[2] & StringRegExpReplace($a2[2] & "|" & 5 & Random(1, 49, 1), "(" & $a2[2] & ")", ""), "\|+", "|") WEnd Return MsgBox(0, "Lottery", "You " & $a2[StringStripWS(StringRegExpReplace(StringRegExpReplace(InputBox("Enter 7 Numbers", ""), "(\A| )", "5"), "(" & $a2[2] & ")", ""), 8) = ""]) EndFunc ;==>_czardas
  24. Thanks
    JohnOne got a reaction from GoogleGonnaSaveUs in How To ReStart The Script   
    Maybe will help
  25. Like
    JohnOne got a reaction from AndrewSchultz in Return multiple data through a function   
    How so James?

    If I return SetError(2664,2274,77592) am I not returning 3 values?
×
×
  • Create New...