I am trying to write a script to do the above 2 things. So here is where I am at:
to launch a program this is the code
!x::
run, C:\Program Files (x86)\CherryTree\bin\cherrytree.exe
to collapse the hierarchy tree in that program this is the code
+^L (i.e. Shift+CTRL+L)
I am stuck on how to merge those lines of code in 1 script so that they are executed consecutively when the script is activated.
In 1 script: launch a program & execute a command Topic is solved
Re: In 1 script: launch a program & execute a command
example here for notepad
alt+x start once notepad and send text / otherwise just activate it and send text
alt+x start once notepad and send text / otherwise just activate it and send text
Code: Select all
pr=notepad
sc=ahk_exe Notepad.exe
return
!x::
IfWinNotExist,%sc%
{
Run, %pr%,,,pid1
WinWait,%SC%
}
IfWinNotActive ,%SC%,,WinActivate,%SC%
WinWaitActive,%SC%
Send,Send to notepad if active`r`n
return
Re: In 1 script: launch a program & execute a command Topic is solved
Hi,
Try the following:
Try the following:
Code: Select all
!x::
run, C:\Program Files (x86)\CherryTree\bin\cherrytree.exe,,, OutputVarPID ; run the program and store its process ID in 'OutputVarPID'
WinWait, ahk_pid %OutputVarPID% ; wait for the first window belonging to the process to appear
WinActivate ; activate the window (actually, if all parameters are omitted, the 'last found' window - set by the WinWait command above - is used instead)
WinWaitActive ; same remark as above
sleep, 100
Send, {Shift Down}{Ctrl Down}l{Shift Up}{Ctrl Up}
return
Re: In 1 script: launch a program & execute a command
Hi Garry, thanks for replying. I was not sure exactly what you meant, so I tried AhkUser's suggestion. That worked.
Re: In 1 script: launch a program & execute a command
Hi AhkUser, thanks for helping out. Yes, your script works, so I am a happy bunny , esp. because it is a workaround for a feature that is not working in the Windows version of Cherrytree, which is a good note-taking app.
I see your location is France, so I say: je vous remercie encore une fois, et peut-être à la prochaine. Salut !
I see your location is France, so I say: je vous remercie encore une fois, et peut-être à la prochaine. Salut !
Re: In 1 script: launch a program & execute a command
I'm not sure if this works ( didn't tried the program cherrytree.exe )
just an idea , if use hotkey alt+x again , shouldn't start program cherrytree again
EDIT : modified used PID
just an idea , if use hotkey alt+x again , shouldn't start program cherrytree again
EDIT : modified used PID
Code: Select all
pr=calc.exe
sc=ahk_exe calc.exe
;---------------------
;pr=notepad.exe
;sc=ahk_exe notepad.exe
;---------------------
;pr=C:\Program Files (x86)\CherryTree\bin\cherrytree.exe
;sc=ahk_exe cherrytree.exe
return
;-------------------------------------------------------
!x::
IfWinNotExist,%sc%
{
Run, %pr%,,,pid1
scx:= "ahk_pid " . PID1
WinWait,%scx%
}
IfWinNotActive ,%scx%,,WinActivate,%scx%
WinWaitActive,%scx%
;-Shift+CTRL+L =
msgbox,TEST = Send`, {Shift Down}{Ctrl Down}l{Shift Up}{Ctrl Up}
return
;========================================================
Last edited by garry on 23 Jan 2018, 09:04, edited 1 time in total.
Re: In 1 script: launch a program & execute a command
Garry, what does this code do? Right now I am able to launch CT and collapse its tree with just 1 keyboard combination.garry wrote:I'm not sure if this works ( didn't tried the program cherrytree.exe )
just an idea , if use hotkey alt+x again , shouldn't start program cherrytree againCode: Select all
pr=C:\Program Files (x86)\CherryTree\bin\cherrytree.exe sc=ahk_exe cherrytree.exe return !x:: IfWinNotExist,%sc% { Run, %pr%,,,pid ;- pid not used in this script WinWait,%sc% } IfWinNotActive ,%sc%,,WinActivate,%sc% WinWaitActive,%sc% ;msgbox,after WinWaitActive = Send`, {Shift Down}{Ctrl Down}l{Shift Up}{Ctrl Up} ;-Shift+CTRL+L = Send, {Shift Down}{Ctrl Down}l{Shift Up}{Ctrl Up} return
Re: In 1 script: launch a program & execute a command
I was thinking , the program starts again if use alt+x again
I modified script above
bent U van Nederland ?
http://jabod.studyit.nl/boudewijn/
I modified script above
Code: Select all
pr=calc.exe
sc=ahk_exe calc.exe
;---------------------
;pr=notepad.exe
;sc=ahk_exe notepad.exe
;---------------------
;pr=C:\Program Files (x86)\CherryTree\bin\cherrytree.exe
;sc=ahk_exe cherrytree.exe
return
;-------------------------------------------------------
!x::
IfWinNotExist,%sc% ;- shoul'd start only once
{
Run, %pr%,,,pid1
scx:= "ahk_pid " . PID1
WinWait,%scx%
}
IfWinNotActive ,%scx%,,WinActivate,%scx%
WinWaitActive,%scx%
;-Shift+CTRL+L =
;Send, {Shift Down}{Ctrl Down}l{Shift Up}{Ctrl Up}
return
;========================================================
http://jabod.studyit.nl/boudewijn/
Re: In 1 script: launch a program & execute a command
Why would I use Alt+X again? I only use it once to launch a number of programs, incl. CT, and after that I stay away from Alt+X.
So what does your code do? I don't understand the calc.exe and the notepad.exe parts.
Ja, ik ben Nederlander. Waarvoor zijn de mp3 files in de link?
So what does your code do? I don't understand the calc.exe and the notepad.exe parts.
Ja, ik ben Nederlander. Waarvoor zijn de mp3 files in de link?
Re: In 1 script: launch a program & execute a command
just if accidentally pressed again ...Why would I use Alt+X again? I only use it once to launch a number of programs, incl. CT, and after that I stay away from Alt+X.
this was for testSo what does your code do? I don't understand the calc.exe and the notepad.exe parts.
oude muziek om te luisteren als je het alleen leuk vindtJa, ik ben Nederlander. Waarvoor zijn de mp3 files in de link?
(Ik ben oud ... maar ik denk dat je niet ...)
Re: In 1 script: launch a program & execute a command
Thanks Garry, but I would not press Alt+X again accidentally.
Dank voor de muziek, ik ben een klein beetje oud
Dank voor de muziek, ik ben een klein beetje oud
Who is online
Users browsing this forum: haomingchen1998, MrDoge and 242 guests