Archive: Get path of pointing mouse file


Get path of pointing mouse file
Could you teach us how to send to clipboard (or variable)
the full path of a file (in explorer) that the mouse is pointing to, like shell as send to nsis variable, or "send full path to clipboard" or "send full path to nsis $VarApp.exe".

Example:
(in explorer, the mouse points to a dll: )
(Shell > "Unregister dll")
Then my nsis app.exe will get the $path and execute
Regsvr32 /u $path
;;;;;;
Using classic interface on Windows 98


The current Code:
VIProductVersion 0.0.4.0
VIAddVersionKey /LANG=1046 "LegalCopyright" "Mark Luis Amóra do Nascimento"
VIAddVersionKey /LANG=1046 "FileDescription" "INFARTE - Arte em Informática do Papai Mark"
VIAddVersionKey /LANG=1046 "Compilado em :" "${__TIMESTAMP__}"
VIAddVersionKey /LANG=1046 "Programa :" "Executor"
VIAddVersionKey /LANG=1046 "FileVersion" "1.0"
#_________________________________________________________________________________________
Name "Executor"
OutFile "..\Executor.exe"
xpstyle on
!verbose 4
ShowInstDetails show
!include "${NSISDIR}\Include\WinMessages.nsh"
LoadLanguageFile "d:\Roteiro\PortugueseBR.nlf"
Caption "Papai Mark e o Executor "
var hwnd
var mem
#_________________________________________________________________________________________

Function .onInit
/* WriteRegStr HKCR "exefile\shell\Executor" "" "Abrir o Executor"
WriteRegStr HKCR "exefile\shell\Executor\command" "" "$exedir\executor.exe"
WriteRegStr HKCR "dllfile\shell\Executor" "" "Abrir o Executor"
WriteRegStr HKCR "dllfile\shell\Executor\command" "" "$exedir\executor.exe"
*/
Push $0
System::Call 'user32::OpenClipboard(i 0)'
System::Call 'user32::GetClipboardData(i 1) t .r0'
System::Call 'user32::CloseClipboard()'
Exch $0
Pop $0
StrCpy $1 $0 2 1
Strcmp $1 ":\" 0 semclip
;MessageBox MB_YesNo|MB_topmost|MB_IconQuestion "Gravar :$\r$0 ?" IdNo semclip
WriteIniStr "$exedir\m.ini" "Field 2" State $0
semclip:
Flushini m.ini
FunctionEnd


#_________________________________________________________________________________________

Page custom ShowCustom LeaveCustom
Function ShowCustom
InstallOptions::initDialog /NOUNLOAD "$exedir\m.ini"
Pop $hwnd
InstallOptions::show
Pop $0
FunctionEnd
#_________________________________________________________________________________________
Function LeaveCustom
ReadINIStr $0 "$exedir\m.ini" "Settings" "State"
StrCmp $0 0 Done
StrCmp $0 5 lembrar
StrCmp $0 7 lembrar
StrCmp $0 10 lembrar
StrCmp $0 6 Ler
StrCmp $0 8 limpar
StrCmp $0 9 Sobre
StrCmp $0 12 lembrar
StrCmp $0 13 lembrar
StrCmp $0 14 lembrar

Ler:
ReadINIStr $0 "$exedir\m.ini" "Field 14" "State"
StrCmp $0 1 0 +2
advsplash::show 295 1 1 0xc0c0c0 $exedir\splash\bt
IfFileExists $exedir\Lista.ini +3 0
MessageBox MB_OK|MB_topmost|MB_Iconinformation " A lista está vazia."
Abort
ExecShell open $exedir\Lista.ini
abort

Limpar:
ReadINIStr $0 "$exedir\m.ini" "Field 14" "State"
StrCmp $0 1 0 +2
advsplash::show 295 1 1 0xc0c0c0 $exedir\splash\bt
IfFileExists $exedir\Lista.ini +3
MessageBox MB_OK|MB_topmost|MB_Iconinformation "A lista já havia sido apagada."
Abort
Delete $exedir\Lista.ini
MessageBox MB_OK|MB_topmost|MB_Iconinformation " A lista foi apagada."
Abort

lembrar:
ReadINIStr $0 "$exedir\m.ini" "Field 14" "State"
StrCmp $0 1 0 +2
advsplash::show 100 1 1 0xc0c0c0 $exedir\splash\cb
Abort

Sobre:
ReadINIStr $0 "$exedir\m.ini" "Field 14" "State"
StrCmp $0 1 0 +2
advsplash::show 295 1 1 0xc0c0c0 $exedir\splash\bt
ExecShell open $exedir\Sobre.txt
abort

Done:
ReadINIStr $0 "$exedir\m.ini" "Field 14" "State"
StrCmp $0 1 0 +2
advsplash::show 480 1 1 0xc0c0c0 $exedir\splash\mv
FunctionEnd
#_________________________________________________________________________________________
Page instfiles
#_________________________________________________________________________________________
Section
ReadIniStr $2 "$exedir\Lista.ini" "Lista de linhas de comando efetivadas" "Total absoluto de usos"
IntOp $2 $2 + 1
WriteIniStr "$exedir\Lista.ini" "Lista de linhas de comando efetivadas" "Total absoluto de usos" $2

ReadINIStr $3 "$exedir\m.ini" "Field 2" "State" ;o arquivo
ReadINIStr $1 "$exedir\m.ini" "Field 13" "State" ;o prefixo
StrCmp $1 "" sempref
StrCmp $1 " " sempref
StrCpy $3 "$1 $3"
GoTo semshell


sempref:
ReadINIStr $8 "$exedir\m.ini" "Field 10" "State" ;Abrir pelo &Shell
StrCmp $8 1 0 semshell
ReadINIStr $7 "$exedir\m.ini" "Field 7" "State" ;Mostrar &Detalhes no final.
StrCmp $7 1 +2
hidewindow
ClearErrors
ExecShell open '$3'
IfErrors exeerro certo

semshell:
ReadINIStr $7 "$exedir\m.ini" "Field 7" "State" ;Mostrar &Detalhes no final.
StrCmp $7 1 +2
hidewindow
ClearErrors
Exec '$3'
IfErrors exeerro certo


exeerro:
ReadINIStr $7 "$exedir\m.ini" "Field 7" "State"
StrCmp $7 1 +2
hidewindow
ReadINIStr $mem "$exedir\m.ini" "Field 5" "State"
StrCmp $mem 0 +3 ; ou +4, tanto faz
StrCpy $9 x
DetailPrint "Erro gravado na lista."
StrCpy $mem 0
DetailPrint "ERRO - E R R O ! - E R R R R R R O !"
DetailPrint "ERRO - E R R O ! - E R R R R R R O !"
DetailPrint "ERRO - E R R O ! - E R R R R R R O !"
DetailPrint "ERRO - E R R O ! - E R R R R R R O !"
ReadINIStr $0 "$exedir\m.ini" "Field 14" "State"
StrCmp $0 1 0 fim
advsplash::show 1200 1 1 0x000000 $exedir\splash\er
Pop $0
GoTo fim
certo:

ReadINIStr $mem "$exedir\m.ini" "Field 5" "State"
StrCmp $mem 0 0 +3
DetailPrint "Não foi gravado na Lista.ini"
GoTo fim
DetailPrint "O comando foi gravado em $exedir\Lista.ini"
ReadIniStr $1 "$exedir\Lista.ini" "Lista de linhas de comando efetivadas" "Total absoluto de usos"
StrCmp $1 100 0 naoapaga
MessageBox MB_YESNO|MB_ICONQUESTION|MB_Topmost "O arquivo de memória já atingiu 100 Ã_tens. Posso apagá-lo ?" idno naoapaga
Delete $exedir\Lista.ini
WriteIniStr "$exedir\Lista.ini" "Lista de linhas de comando efetivadas" "Total absoluto de usos" 1
naoapaga:

StrCpy $6 1

next:
ReadIniStr $4 "$exedir\Lista.ini" "Comandos Corretos" $6
StrCmp $4 "" 0 cont
ClearErrors
WriteIniStr "$exedir\Lista.ini" "Comandos Corretos" $6 $3
IfErrors 0 +2
MessageBox MB_OK|MB_ICONstop|MB_Topmost "Hove um erro inesperado ao escrever na lista."
GoTo fim

cont:
IntOp $6 $6 + 1
GoTo next

fim:
StrCmp $9 x 0 semlger
Strcpy $9 1
nexter:
ReadIniStr $5 "$exedir\Lista.ini" "Comandos Errados" $9
StrCmp $5 "" 0 conter
WriteIniStr "$exedir\Lista.ini" "Comandos Errados" $9 $3
GoTo semlger
conter:
IntOp $9 $9 + 1
GoTo nexter

IntOp $5 $5 + 1
WriteIniStr "$exedir\Lista.ini" "Último Comando Errados" $5 $3

semlger:
ReadINIStr $7 "$exedir\m.ini" "Field 7" "State"
StrCmp $7 1 +2
SetAutoClose True
Sleep 500
ReadIniStr $7 "$exedir\m.ini" "Field 12" "State"
StrCmp $7 1 0 +2
exec $exedir\executor.exe
SetAutoClose True
SectionEnd



The Ini file

[Settings]
NumFields=14
title=EXECUTOR - Executar programa composto.
BackEnabled=1
BackButtonText=Pra Trás
State=6

[Field 1]
Type=Groupbox
Left=1
Right=-1
Top=1
Bottom=46
Text=Cole, digite ou abra um arquivo e digite o complemento :
HWND=3044

[Field 2]
Type=FileRequest
Flags=GROUP|FILE_MUST_EXIST|FILE_EXPLORER|FILE_HIDEREADONLY
State="ping 200.149.10.50"
Filter=Executáveis|*.exe|Todos|*.*
Left=10
Right=-10
Top=12
Bottom=25
MinLen=8
ValidateText=Entre com um executável composto válido.
HWND=3048
HWND2=3052

[Field 3]
Type=Groupbox
Left=1
Right=-1
Top=50
Bottom=98
Text=Prefixo :
HWND=3056

[Field 4]
Type=Label
Left=120
Right=-5
Top=62
Bottom=72
Text=Esta é a primeira parte da linha de comando.
HWND=3060

[Field 5]
Type=Checkbox
Text=&Anotar na Lista
Flags=NOTIFY
State=1
Left=10
Right=76
Top=105
Bottom=115
HWND=3064

[FIELD 6]
Type=Button
Flags=NOTIFY
Text=&Ver a Lista
Left=-66
Right=-10
Top=108
Bottom=123
HWND=3068

[Field 7]
Type=Checkbox
Text=Mostrar &Detalhes no final.
Flags=NOTIFY
State=0
Left=10
Right=110
Top=116
Bottom=126
HWND=3072

[Field 8]
Type=Button
Flags=NOTIFY
Text=&Limpar a Lista
Left=-127
Right=-71
Top=108
Bottom=123
HWND=3076

[Field 9]
Type=Button
Flags=NOTIFY
Text=&Informações
Left=-65
Right=-10
Top=28
Bottom=43
HWND=3080

[Field 10]
Type=Checkbox
Text=Abrir pelo &Shell. O programa não é um executável.
Flags=NOTIFY
State=0
Left=10
Right=-80
Top=30
Bottom=40
HWND=3084

[Field 11]
Type=Groupbox
Left=1
Right=-1
Top=98
Bottom=130
Text=
HWND=3088

[Field 12]
Type=Checkbox
Text=&Reabrir
Flags=NOTIFY
State=1
Left=82
Right=122
Top=105
Bottom=115
HWND=3092

[Field 13]
Type=Combobox
State=""
ListItems=| |Regsvr32 |Regsvr32 /s |Regedit |Regedit /s |Regsvr32 /u |notepad |command.com /c |
Left=10
Right=110
Top=60
Bottom=-1
Flags=Notify
HWND=3096

[Field 14]
Type=Checkbox
Text=S&om
Flags=NOTIFY
State=0
Left=10
Right=40
Top=80
Bottom=90
HWND=3108


Not sure if I got the point of what you're trying to achieve...
Do you want users to select a dll which installer should unregister?
If this is the matter you may do it simply and easily by adding a FileRequest on a custom page where users should browse for the dll which you're able to unregister within NSIS, no need to execute Regsvr32.


No.
First, why:
We test, reg and unreg, use parameters.
-------------------------------
Second, What I do NOW:
>Point to notepad.exe
>Right click over notepad.exe.
>Shell opens (open, sendto, cut, copy, Copy this path, etc)
>I click on "Copy this path" ( a camtech soft, http://camtech2000.net/) and the full path of notepad is sent to clipboard.
>I right click over notepad.exe again and
>Shell opens

>Now, I click on "Open the Executor" (my app)
>The Executor gets the clipboard data and puts into a listbox. On other listbox, I choose or write the first part of the command line and... Go!
The command (exec, execwait) can be so:
"c:\ExeScope.exe c:\Windows\notepad.exe"
And so, ExeScope will analyse the notepad.exe.
-------------------------------------------------------
Third, What I want to:
Nsis can get clipboard data but can't get the path of a selected file on explorer. I want to do only one right click:

>Point to notepad.exe
>Right click over notepad.exe.
>Now, I click on "Open with the Executor" (my app)
>The Executor gets the FULL PATH of notepad.exe and puts into a listbox or variable. On other listbox, I choose or write the first part of the command line and... Go!
The command (exec, execwait) can be so:
"c:\ExeScope.exe c:\Windows\notepad.exe"
And so, ExeScope will analyse the notepad.exe.


>Right click over notepad.exe.
>Now, I click on "Open with the Executor" (my app)
>The Executor gets the FULL PATH of notepad.exe
This sounds like you have added "Open with the Executor to the shell command. If you did that, you could have the shell command add the filename that was clicked as a parameter to pass to Executor.

"%1" after the Executor command will pass the filename with path. Take a look in your registry at an example like NSIS.Script (HKCR\NSIS.Script\shell\compile\command).

Executor will need to be modified to look at its command line for the filename, instead of looking at the clipboard.

Don

Getting closer.
WriteRegStr HKCR "exefile\shell\Executor\command" "" '$exedir\executor.exe "%1"'
YEs, but how the Executor will read %1 ?

I 've tried and read the help file but nothing. I only find command line to the COMPILER.

Example, how to get the %1:
_________________________
Outfile Eureka.exe
Name Darmok
Section "In the ocean"
MessageBox MB_OK|MB_topmost|MB_Iconexclamation "Tempa!
when the walls falled %1"
Exec "Command.com /c %1"
SectionEnd
GetOut
_________________________


In the manual, Section E.1.11 Get Parameters

!include "FileFunc.nsh"
!insertmacro GetParameters
Section
${GetParameters} $R0
; $R0="[parameters]"
SectionEnd

When the walls falls
Your eyes uncovered

THANK YOU!