i write a xyplorer script to check duplicated files ,i want the script to check when the user press hotkey (like ctrl + j) ,the script will stop running and write some variable's value to a text
is it possible to do that ?
Thanks in advance
hotkey to stop running script and write variable value to file
Re: hotkey to stop running script and write variable value to file
Imho not possible (through internal stuff). ESC stops a script but afaik it does that
forcefully.
That doesn't mean that it is impossible at all. A small .ahk / .au3 tool that provides
a hotkey could set a permanent variable that your XY script checks on each
loop. When it recognizes that the variable has changed -> Do what you want
it to do...
forcefully.
That doesn't mean that it is impossible at all. A small .ahk / .au3 tool that provides
a hotkey could set a permanent variable that your XY script checks on each
loop. When it recognizes that the variable has changed -> Do what you want
it to do...
One of my scripts helped you out? Please donate via Paypal
Re: hotkey to stop running script and write variable value to file
You can run the script by an UDC with the CTRL+J hotkey.
Write the in a way so that its "_initialize" toggles a permanent/global variable on start.
And your main script probably already runs in a loop. Put in a condition somewhere in the loop that checks for that variable, if it's set, then your script stops and writes the results etc. (Also reset that var)
Hope that gives you some ideas.
Write the in a way so that its "_initialize" toggles a permanent/global variable on start.
And your main script probably already runs in a loop. Put in a condition somewhere in the loop that checks for that variable, if it's set, then your script stops and writes the results etc. (Also reset that var)
Hope that gives you some ideas.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: hotkey to stop running script and write variable value to file
Thank you for the help ,i 'm using autohotkey too, can you please tell me how to do that with autohotkey (i'm so glad to see it's possible)highend wrote:Imho not possible (through internal stuff). ESC stops a script but afaik it does that
forcefully.
That doesn't mean that it is impossible at all. A small .ahk / .au3 tool that provides
a hotkey could set a permanent variable that your XY script checks on each
loop. When it recognizes that the variable has changed -> Do what you want
it to do...
(actually i thought about that ,but i don't know how to make xyplorer read variable value of autohotkey (without using clipboard or read from file))
Last edited by xnmp on 19 Oct 2017 11:58, edited 1 time in total.
Re: hotkey to stop running script and write variable value to file
Thank you for the helpSammaySarkar wrote:You can run the script by an UDC with the CTRL+J hotkey.
Write the in a way so that its "_initialize" toggles a permanent/global variable on start.
And your main script probably already runs in a loop. Put in a condition somewhere in the loop that checks for that variable, if it's set, then your script stops and writes the results etc. (Also reset that var)
Hope that gives you some ideas.
from what i understand , i should write permanent variable for script 1 ,for example $checkvar and set value to "1" when i run that script by ctrl + j
and in my main script (script2) , it set $checkvar to "0" on start ,and check that variable in loop ,if value ==1 it stop the script
but i don't know how to make permanent variable for all script like that, can you please tell me how ,something like this
in script 1
Code: Select all
$checkvar = 1 ;
Code: Select all
global $checkvar = 0 ; //// declare the global variable and set value on start
//in loop
foreach {
if $checkvar == 1 {
// do what ever i want
break;
}
Re: hotkey to stop running script and write variable value to file
You don't need a global, but permanent variable. Check the perm command from the help file
In .ahk it looks like this.
In .ahk it looks like this.
Code: Select all
#NoEnv
;#NoTrayIcon
#Persistent
#SingleInstance force
SetBatchLines, -1
#IfWinActive, ahk_class ThunderRT6FormDC
^j::
Send_WM_COPYDATA("::perm $P_StopScript = 1")
return
#IfWinActive
; ====================================
; = GOTO: FUNCTIONS - Send_WM_COPYDATA
; ====================================
Send_WM_COPYDATA(message) {
WinGet, XYHwnds, List, ahk_class ThunderRT6FormDC
if !(XYHwnds)
return
size := StrLen(message)
if !(A_IsUnicode) {
VarSetCapacity(data, size * 2, 0)
StrPut(message, &data, size, "UTF-16")
} else {
data := message
}
VarSetCapacity(COPYDATA, A_PtrSize * 3, 0)
NumPut(4194305, COPYDATA, 0, "Ptr")
NumPut(size * 2, COPYDATA, A_PtrSize, "UInt")
NumPut(&data, COPYDATA, A_PtrSize * 2, "Ptr")
Loop, %XYHwnds%
{
thisHWND := XYHwnds%A_Index%
result := DllCall("User32.dll\SendMessageW", "Ptr", thisHWND, "UInt", 74, "Ptr", 0, "Ptr", ©DATA, "Ptr")
}
return
}
One of my scripts helped you out? Please donate via Paypal
Re: hotkey to stop running script and write variable value to file
Thank you very much , it's really helpful,i will try it
Re: hotkey to stop running script and write variable value to file
[/code]
More likexnmp wrote: in script 1in script 2Code: Select all
$checkvar = 1 ;
Code: Select all
global $checkvar = 0 ; //// declare the global variable and set value on start //in loop foreach { if $checkvar == 1 { // do what ever i want break; }
Code: Select all
foreach ($thing, $things) {
if $P_StopScript { break; }
// do things on $thing
}
// things to do after stop
write($your_variable);
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: hotkey to stop running script and write variable value to file
i see, thank you very much for the help