Jump to content

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


Recommended Posts

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 :-)

 

 

 

 

 

 

Link to comment
Share on other sites

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 :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

@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

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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

Link to comment
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
 Share

×
×
  • Create New...