-
Posts
21 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by diff
-
Hello, feeling dumb that I can't resolve my issue, my point is to not use Global variables in bigger projects at all. So I have 2 functions, the first is main function and the second searching for information from websites and attaches the extracted information to variables. Func main() ...does some code... ..then later i have some code which need to use variables from web_extraction() function.. example: StringStripWS($var1, 3) Of course I get here error that variable $var1 possibly not declared EndFunc Func web_extraction() ..does some code... ...extracts information from websites.. $var1 = "extracted info 1" $var2 = "extracted info 2" etc etc. EndFunc Of course I can write at the beginning Global $var1, $var2 and this will work, but how I can use $var1, $var2 which kill itself after function ends in main function? I have read a lot of information about $params in function and etc. tried everything and still receive that the variables are possibly not declared and just stay blank inside. Any examples how correctly to write this?
-
Func with parameters with saving results
diff replied to diff's topic in AutoIt General Help and Support
In my case I cannot process both values at the same time within function, so the $_iFlag option works perfectly for me and separates values data with two different variables. Amazing, totally forgot about flags with Switch, thank you _ArrayToString I use because the collected words from $firstValue and $secondValue I need only in one line delimited by comma, so I thought that this could be the best solution for me -
Hello, maybe this topic exist in forum, I just don't know how should I search it. The idea of my function is go get 2 inputs from GUI and run on same function. It's looks like this ; GUI has these created inputs $firstInput = GUICtrlCreateInput("", x, x, x, x) $secondInput = GUICtrlCreateInput("", x, x, x, x) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $buttonToExecute $firstValue = GUICtrlRead($firstInput) $secondValue = GUICtrlRead($secondInput) _executionFunc($firstValue) _executionFunc($secondValue) EndSwitch WEnd So the function collect data to Array for $firstValue and then converts _ArrayToString to another variable $collectedDataFromFirstValue = "here is all collected data from array" with all data in one variable (which is good for me), then next step is run function again with $secondValue and here is my issue, how I can save all my collected values in $collectedDataFromFirstValue without overwrite? Because If the function runs again with all $firstValue data saved before in array then it gets overwritten by $secondValue and moved again to $collectedDataFromFirstValue. Hope I explained well to understand what I meant.
-
Sorry for double post, just adding solution with multiple pictures if someone will need it I added a loop to add more screenshots, probably it could be written better, but it's working for me and I am still learning So the pictures will be added in ascending order like My examples: {Pic1.jpg} {Pic2.jpg} {Pic3.jpg} My extra code below on @Nine example: #include <Word.au3> $picName = "Pic" $picFormat = ".jpg" Local $oWord = _Word_Create() Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\V.doc", Default, Default, True) $oSearchRange = _Word_DocRangeSet($oDoc, -1) $oRangeFound = _Word_DocFind($oDoc, "Dijon", $oSearchRange) $oSearchRange = _Word_DocRangeSet($oDoc, $oRangeFound, $wdParagraph, 1) Local $i = 1 While 1 _Word_DocPictureAdd($oDoc, @ScriptDir & "\" & $picName & $i & $picFormat, Default, Default, $oRangeFound) _Word_DocRangeSet($oDoc, $oRangeFound, $wdParagraph, 1) ; to add pics in ascending order $i += 1 If FileExists(@ScriptDir & "\" & $picName & $i & $picFormat) = 0 Then ExitLoop EndIf WEnd
-
Yeah, sorry for the typos as I wasn't be able to copy now the code so I wrote from my memory. I have fixed the first post now. I have quickly checked your solution and looks like now the image is inserted exactly where I needed, I will try later to do this with more pictures in a row if that will work. Thank you for the solution, looks so simple where I was stuck
-
Hello, so I have started to learn to use the Word UDF and got issue to add my pictures after exact paragraphs. I was searching in the forum for the solution, checked with examples and still I don't understand how to add pictures after paragraph in new line. My word document has like 8 pages and for example on page I have paragraph named "My examples:" and here starts my problem. I have tried to do this: #include <Word.au3> Local $oWord = _Word_Create() Local $oDoc = _Word_DocOpen($Word, @ScriptDir & "\examples.docx", Default, Default, True) $oSearchRange = _Word_DocRangeSet($oDoc, -1, $wdParagraph, 0) $oRangeFound = _Word_DocFind($oDoc, "My examples:", $oSearchRange) _Word_DocPictureAdd($oDoc, @ScriptDir & "\pic1.jpg", Default, Default, $oRangeFound) And here the picture adds before the paragraph My examples: on same line and looks like {pic1}My Examples: What I want to see is: My examples: {PICTURE IN NEW LINE} which is pic1.jpg from my code. How I can do that? I want to add 3 pictures in a row in new line each like: My examples: {pic1.jpg} {pic2.jpg} {pic3.jpg} Hope I explained this well, but you can ask me if you need any additional information to clarify.
-
Hi, was searching in the forum for solution but didn't found anything similar, so my problem is that after user selects Excel file the other _Excel_ functions doesn't work. I created a logic, that if any user changes file name or file location then has option to select the file location manually with FileDialogOpen This is how it looks: $fileLocation = "C:\Users\Desktop\File.xlsx" If Not FileExists($fileLocation) Then MsgBox(48, "File not found", "File not found, please select") FileOpenDialog("Select file", "C:\Users\", "Excel (*.xlsx*)") EndIf $oExcel = _Excel_Open(1, 1, 1, 1, 1) $xlBook = _Excel_BookOpen($oExcel, $fileLocation) $xlBook.Sheets("Users").Activate .....and continues other $xlBook.Sheets functions....... So if the File.xlsx is found on this location everything works correctly the sheet .Active works as expected, but if the File.xlsx not found and user selects in other directory same file, then all my $xlBook.Sheets functions doesn't work and crashes on first one which is $xlBook.Sheets("Users").Activate What did I missed? Thank you for the help
-
I don't know why but in my situation only works with partial search included in _ArrayFindAll with your code. Thank you guys, modified from both codes and got it working by adding partial search.
-
Hello, having issue to count duplicates in array, tried _ArrayFindAll but it doesn't find by word? _ArrayUnique only shows the words without value how many duplicates. for example I have ; Extracted array from excel which looks like something like this: #include <Array.au3> Local $aArray[0] $aArray = [John, Martin, Potter, John, Marta, Lola, John] How I can count John how many time he was duplicated, I need in return only value which is 3? Tried $name = "John" $findDup = _ArrayFindAll($aArray, $name, 0, 0, 0) MsgBox(0, "", $findDup) but doesnt work :{
-
The recent code is a little bit different but I can show similar example from my previous topics on this forum. So, some of selections in the list will have only Name2 without Address, City and Country inside and I need to show MsgBox notice when user selects empty Name2 in droplist and clicks Select. GUI below and .ini from previous post: #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <ButtonConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 251, 137, 192, 124) $Combo1 = GUICtrlCreateCombo("", 40, 24, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) $Button1 = GUICtrlCreateButton("Select", 152, 56, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $ini = 'companies.ini' Global $sections = IniReadSectionNames($ini) If IsArray($sections) Then For $a = 1 To UBound($sections) - 1 GUICtrlSetData($Combo1, $sections[$a]) Next EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Address = IniRead($ini, guictrlread($Combo1), 'Address', '') $Country = IniRead($ini, guictrlread($Combo1), 'Country', '') $City = IniRead($ini, guictrlread($Combo1), 'City', '') ConsoleWrite('Address '&$Address&@TAB&' Country '&$Country&@TAB&' City '&$City&@CRLF) MsgBox(64 + 262144, guictrlread($Combo1), 'Address '&$Address&@TAB&' Country '&$Country&@TAB&' City '&$City&@CRLF) EndSwitch WEnd
-
Hello, is it possible to create MsgBox notice after user select from GUI drop down list a text but that text have no action in code, so I want to make a notice what the user should do if his selection cannot do any action. Drop down list I have made in .ini file and the GUI reads it to show for user all possible selections. So for example: .ini has this list [Name1] City=NY Country=USA [Name2] here is nothing, so my code should detect selection Name2 and give MsgBox notice after user click button Select
-
Thank you for the help all, I have fixed that myself.
-
From the code its looks like what I need, but dropdown list shows nothing to select, I'm looking at the code and seems like everything is good but why nothing to select?
-
Hi, sorry for a late answer, I have started it but stuck. here is my code: #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <ButtonConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 251, 437, 192, 124) $Combo1 = GUICtrlCreateCombo("", 40, 24, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) $Button1 = GUICtrlCreateButton("Select", 152, 56, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $ini = 'companies.ini' Global $sections = IniReadSectionNames($ini) If (Not @Error) Then GUICtrlSetData($Combo1, _ArraytoString($sections, "|", 1), $sections[1]) ;~ For $a = 1 To UBound($sections) - 1 ;~ ConsoleWrite($sections[$a] & @CRLF) ;~ Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $test = _ArrayToString(IniReadSection($ini, guictrlread ($Combo1)),"=",1) MsgBox($MB_SYSTEMMODAL, "", $test) EndSwitch WEnd Here I receive dropdown list with my companies and when I click Select (for testing only with MsgBox trying) I see everything I wrote in my .ini file after section. My ini looks like this: [Company1] Address=Kdkeooe st. 22-11 Country=India City=Mumbai [Company2] Address=Koeeeee 100st. Country=America City=New York So after clicked Select I see full string (and its not what I wanted to see): Address=Koeeeee 100st. Country=America City=New York But I need to fill my PDF and the result after selection should show somehow separetely address, country and city to fill my 3 fields in PDF. I mean If I selected in droplist Company1 then it should somehow save 3 seperate fields to variables? from Section Company1 which is address, country and city and then I want to automate PDF filler to write these results seperately to every field. I hope you understand what I meant. PDF filler I already created but it works only with variables I coded to paste from code to PDF, here I want to copy 3 fields from droplist section and paste them seperately in to PDF fields.
-
Hello, I have an idea for my script but having trouble to create it. So, how should it work? For example, I have a script with GUI where users after execution get a droplist to select a company, for example: from 10 random companies, and the user selects one of them. Every single company cointans address with minimum 3 words inside, for example $company1 = "Address str." & "ApartNr" & "Postcode" $company2 = "Address str." & "ApartNr" & "Postcode" and more 8 others. When the user selects $company1 in droplist, the script should seperate these 3 words and paste to 3 different fields in PDF form file. Like Address.str {TAB} ApartNr {TAB} PostCode. Is this possible to do with 10 random companies together in list? I was looking in forum something similar but didn't find anything.
-
Yeah I understand that it's not on/off, I tried random ms to set but it was still writing too long. Looks like ClipPut works better if I add delay at least Sleep(200) about which was talking @Danp2. So, probably I solved my problem by adding everywhere Sleep(200) after ClipPut()
-
You mean with Send()? If yes, then it takes time while Send writes all the text and Opt SendKeyDownDelay, SendKeyDelay doesn't work here with 0 or 1 delay.
-
Hello, still learning and trying to understand AutoIT but having problem in filling my PDF file. So my code looks like similar to this: Global $1 = "text text 44444444" Global $2 = "texting2 texting2" Global $3 = "newtext3 next3" ShellExecute ("C:\Users\XXX\Desktop\myPDF.pdf") WinWaitActive("MyPDF.pdf - Adobe Acrobat Reader DC") Send ("{TAB}") ClipPut($1) Send ("^v") Send ("{TAB 3}") ClipPut($2) Send("^v") Send ("{TAB}") ClipPut($3) Send("^v") So its fill my PDF form, the first field looks good, the code add the text text 4444, then second should be $2 with texting2 texting2 but for some reason the code uses for second and third field after TAB only variable $3. So, I receive in $2 and $3 for some reason same newtext3 next3 in both, why its skipping the variable $2? Maybe there also much better solution for instant text? Because Send writes with delay by letters which I don't like. Thanks!
-
Extract full line from seached word in web
diff replied to diff's topic in AutoIt General Help and Support
I understand, but does it will help if the pages stay on the same page and in the link of the website doesn't change anything? -
Extract full line from seached word in web
diff replied to diff's topic in AutoIt General Help and Support
Wow, looks that simple and works perfectly at least with this website of HTML code. Thank you Also, another question, what if my website will have other pages from 1 to 20 for example, so I use CTRL+F to find word example. When the search ends, it automatically jumps to another just by searching with ctrl+f the same word and shows on another page instantly (when I click enter all the time in CTRL+F), is it possible to make something similar with a script? What can I read to understand how I can make it? Can't give you the web for example as it is restricted for public view. :{ -
Hello, I'll try to explain what I am looking for. For example let's take this website: https://www.bristol.ac.uk/arts/exercises/grammar/grammar_tutorial/page_05.htm What I want to make is: the script does something like CTRL + F and finds a line with word example. If some of the lines found with word example, I want to copy all possible full lines with the word example (even if it's not a complete sentence) to a variable. Screenshot below: So now, as you see, for example, the script found here 2 lines with word example, and now I want to copy both full lines with this word to a variable in AutoIt. Is it possible to make it work? Maybe you have something similar created already or can give me an idea of how I can create a code that would do that for me? Or perhaps it's not possible at all? Sorry for my bad English, hope you understood what I meant