Jump to content

Question: how to get the path of a file


Ericlee
 Share

Recommended Posts

this script is to move a file to certain folder through hotkey after clicked by mouse. but it looks lengthy, and always make mistake. if using the filemove function, it will be better, however, i can get the path of the file. the simplified script is:

#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)

HotKeySet('#a','Example')

While 1
Sleep(100)
WEnd

Func Example()
Local $Button_1, $Button_2, $msg,$pos

$pos = MouseGetPos()
MouseClick("left",$pos[0] ,$pos[1])
Send('^c')
; the above 3 line relize the function of copying the file that i place the mouse on. and i want to replace it by a script that can get the path of the file. 

GUICreate("My GUI Button")

Opt("GUICoordMode", 2)
$Button_1 = GUICtrlCreateButton("Button 1", 10, 30, 100)
GUISetState() 
; creat a GUI with one botton

While 1
    $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE ; if i click the close botton then exit the loop 
                ExitLoop                
            Case $msg = $Button_1
                ShellExecute('D:\05  文献阅读'); open D:\Folder1
                Sleep(1000); wait for 1s
                Send('^v') ;copy the file to the folder1
                Sleep(1000); wait for another 1s
                WinClose("[ACTIVE]", ""); colse folder1
                ExitLoop ;exit the loop,
                                ; i want using filemove() so there will be less mistake.
            EndSelect
        WEnd
        GUIDelete() ;when exit the loop, delete the GUI
EndFunc
Edited by Ericlee
Link to comment
Share on other sites

I want to keep the file at is original plase, and it can not simplify my script. so send "^x" is not appropriate

Then how do you explain this comment from your script?

; i want using filemove() so there will be less mistake.

Whatever ... try this code:

#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)

HotKeySet('#a','Example')

While 1
Sleep(100)
WEnd

Func Example()
    Local $Button_1, $Button_2, $msg,$pos

    $pos = MouseGetPos()
    MouseClick("left",$pos[0] ,$pos[1])
    Send('^c')
    ; the above 3 line relize the function of copying the file that i place the mouse on. and i want to replace it by a script that can get the path of the file. 
    FileCopy(ClipGet(), "D:\Folder1\")
    
EndFunc

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...