Sign in to follow this  
Followers 0
Mag91

Beginner Question - Filepath - change letters - search for specific data

5 posts in this topic

#1 ·  Posted

Hey Community,

cause im too new in the Auto it world i will try it with the your help. hopefully.

I woud like to know how i can handle my Problem.

----

I have a Excel Data with 362 random numbers.
For Example:

1166642335374

1172899897343

.....

this numbers are a part of the filepath ...example

D:\Projekte\1166_64233_5374

as u can see its the first number of the Excel data. After the first 4 numbers it shoud make a "_" than another 5 "_"

This is my first question. How can i handle this to make it Shell execute.

 

--------

Second question:

If i am in the path.

For Example:

D:\Projekte\1166_64233_5374

the code shoud search for specific PDF Files.

They are named like: 0050569E364B1ED79B900F73E62660EC.pdf

the first 15 letters are always the same

0050569E364B1ED

when he found this data he has to copy it on a Folder on the Desktop.

(There can also be 2 or 3 pdfs in one Folder with this letters)

----

Please give me some help :-)

 

 

 

 

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hi @Mag91, and welcome to the AutoIt forum :)

What you're trying to do is:

1) Read from an Excel worksheet;

2) You have a string, which it's lenght is 13 characters, and, after 4 characters, you have to put an underscore ( "_" ), then, after other 5 characters, you have to put another "_" ( after the 9th character, so );

3) You have to shell these combined paths ( for me, it's not needed the Shell(), and search for PDF files in them, and those PDF files have the first 15 characters which are always the same, copy them to the Desktop folder.

Not so difficult to do :)

Did you test some code? Show us what you got :)

1 person likes this

Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#3 ·  Posted

Exactly!!!

i know my code is like shit for known Auto it programmers... but here

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("BigBag", 188, 48, 553, 270)
$Button1 = GUICtrlCreateButton("Start", 8, 8, 169, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

HotKeySet("{F10}", "stop")

Func STOP()
While 1
Sleep(120)
WEnd
EndFunc

While 2
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1 ;Start

;=============Find Project===============
sleep (2000)

If ProcessExists ("EXCEL.EXE") Then
    WinActivate ("BigBag_ab_31.01.17.xlsx - Excel")
    EndIf
sleep (500)
Send("{CTRLDOWN}c{CTRLUP}")                                     ;COPY PROJECT NUMBER FROM EXCEL
sleep (500)

ShellExecute ("Z:\Projektdetails\")
WinWaitActive ("Projektdetails", "Projektdetails", 10)
WinMove ("Projektdetails", "", 0, 0, 1000, 750)
sleep (100)
$HWND = WinWaitActive("Projektdetails", "")
ControlClick($HWND, "", "[CLASSNN:ToolbarWindow322; INSTANCE:2; ID:1287]", "LEFT", 1)
Send("{CTRLDOWN}v{CTRLUP}")


EndSwitch
WEnd

The code is just form with a start button
It Begins with ctrl c to copy the number from the Excel worksheet.
Then it execute a part of the path and put the copied data behind the path.
 

i can tell him now to go 4 letters left and set a underscore "_" and another 6 left to set another underscore.

But i know its to simple. i dont want to make him mouseclick or send ("{left}"). i want a better way.

its to superficial (I hope that's the right word) - its not deep enough

for the 3rd Point i have no idea :S

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@Mag91

First of all, don't say these things

43 minutes ago, Mag91 said:

i know my code is like shit for known Auto it programmers

Everyone starts from the basic, and, within time, improve himself with the right path...

Then, let's talk about the approach you'd like to implement with your script.

I saw that you're opening the Excel worksheet to copy the row of the file to "format" ( xxxx_xxxxx_xxxx ), but, why don't using an _Excel* function?

You already know the name of the Excel file, so you could open it ( without see anything ), load the content of the file in an array ( with _Excel_RangeRead() ), and work on the content of the array, instead of having windows which activate and copy-paste data from program to program.

I can point you to the right direction ( which could be a lot, so my "solution" could not be the best/the only one you have to do... ), but you have to decide how to proceed with your script.

 

Edited by FrancescoDiMuro
1 person likes this

Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#5 ·  Posted

1 hour ago, FrancescoDiMuro said:

@Mag91

First of all, don't say these things

Everyone starts from the basic, and, within time, improve himself with the right path...

Then, let's talk about the approach you'd like to implement with your script.

I saw that you're opening the Excel worksheet to copy the row of the file to "format" ( xxxx_xxxxx_xxxx ), but, why don't using an _Excel* function?

You already know the name of the Excel file, so you could open it ( without see anything ), load the content of the file in an array ( with _Excel_RangeRead() ), and work on the content of the array, instead of having windows which activate and copy-paste data from program to program.

I can point you to the right direction ( which could be a lot, so my "solution" could not be the best/the only one you have to do... ), but you have to decide how to proceed with your script.

 

Thanks a lot!

will try to handle the first step when im home <3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • VeryGut
      By VeryGut
      I'm trying to insert the following formula in cell A2 using my script:
      =if(A1=""; "YES"; "NO")
      To my understanding, the line of code should be similar to this:
      _Excel_RangeWrite($MasterFile, Default, "=if(A1=""; "YES"; "NO")", "A2")
      However, it does not work, probably due to the multiple quotation marks that confuse the script :C
      How do I avoid this problem?
    • BlazerV60
      By BlazerV60
      Hello all,
      I've been trying to figure out how to launch Google Chrome in the background (hidden) but it doesn't seem possible. I've tried the following methods:
      ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "", "", "", @SW_HIDE) Also I've tried:
      ShellExecute(@ComSpec, "/c start chrome.exe","","",@SW_HIDE) Lastly I tried:
      RunWait('"'&@ProgramFilesDir&'\Google\Chrome\Application\chrome.exe" --silent-launch',@ScriptDir)  
      But all of them launch my chrome browser without hiding it. Does anyone know a workaround for this or if AutoIT just can't Chrome? 
      Bonus points if you know how to make it launch chrome hidden and make it go to https://www.autoitscript.com
       
      Thank you,
      Brian
    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i have a question about Excel, i have to create several charts one below the other dynamically.
      I have thought to use:
       
      $oRangeLast = .UsedRange.SpecialCells($xlCellTypeLastCell) $iRowCount = .Range(.Cells(1, 1), .Cells($oRangeLast.Row, $oRangeLast.Column)).Rows.Count  
      And then to use it in this way:
      $Graph_position = "=Test1!A"&$iRowCount+2&":K"&$iRowCount+24 But it doesn't work with charts.
      Does anyone have a suggestion?
       
    • mLipok
      By mLipok
      Here:
      https://github.com/nachbar/TRichViewToPdfUsingDebenu/blob/master/Unit1.cpp
      I found a code in C++ for file format conversion from RTF to PDF with using Debenu QuickPDF.
      I know how to use Debenu QuickPDF in AutoIt .
      My question is about RTF part of this code:
       
      HDC hdcNew = debenu->GetCanvasDC( RTFPRINTINGDOTSPERINCH * RTFPAGEWIDTHININCHES, RTFPRINTINGDOTSPERINCH * RTFPAGEHEIGHTININCHES); canvas = new TCanvas; canvas->Handle = hdcNew; RVReportHelper1->DrawPage( PageCounter, canvas, true, RTFPRINTINGDOTSPERINCH * RTFPAGEHEIGHTININCHES); // LastPageHeight);  
      First there is hdcNew declaration , and this is not the problem.
      My problem is in converting the following code snippet, to AutoIt
      canvas = new TCanvas; canvas->Handle = hdcNew; RVReportHelper1->DrawPage( PageCounter, canvas, true, RTFPRINTINGDOTSPERINCH * RTFPAGEHEIGHTININCHES); // LastPageHeight);
      If you remember, I created RTFPrinter sometime ago. But it was some time ago , and created by trial and error, rather than in-depth analysis.
      Also, it was just a modification of another script, not my own work from scratch.
      So now I'm looking for help how to adapt this code snippet to AutoIt.
      Any tips ?
       
      Regards,
      mLIpok
       
    • LoneWolf_2106
      By LoneWolf_2106
      Hi all,
      i have an empty csv file, i have a non formatted text file.
      What do i want to do?
      I want to automate the process "get external data" in Excel, i want to import the data from the text file and basically create a csv file with a specific character encoding.
      Is it possible with AutoIT?