Jump to content

ClipRun - Runs scripts from Clipboard - a must have tool !


jennico
 Share

Recommended Posts

tired of copying, pasting, saving, executing and deleting examples from the forum or helpfile ?

Then here is ClipRun !

- Runs script from clipboard: just copy example from forum to clipboard and hit button

- Options (TrayMenu):

-- Save script: if you like the script, save it directly to file.

-- Copy script: pick an older script from tmp directory and save it to destination.

-- Clean up: deletes all tmp scripts.

-- Integrate in SciTe: integrates Cliprun to SciTe. Hotkey: Shift-Alt-C. when executed from SciTe (Extras menu), no gui will be shown, just the clipboard will be executed !

as always in my scripts: no includes, no future problems!

by the way: to make older scripts and examples work again, use FreeStyle (from my sign).

HAVE FUN !

edit: changed the code because people here prefer to post example scripts with the crappy and senseless ConsoleWrite().

-- reads stdout stream and displays it in a tooltip. => working with ConsoleWrite

-- as a consequence i had to implement a multi instance handling.

-- improved scriptdir handling.

edit: v 1.3 changes:

-- Hotkey functionality (exclusively for firefox :))

-- Added: Pick & Run: run an older temporary script

-- Kill Script: kills a child process (some example scripts have the tendency to block)

-- Edit Script: opens script in SciTe (only SciTe supported!)

-- if possible, the gui title of the child script is retrieved and used as scriptname (else tmpx.au3)

-- the window title is diplayed as TrayToolTip, so the instances can be distinguished.

-- improved closing of instances

--> please observe my remarks on multi instances / threading in post 15

ClipRun.au3 - new version 1.3

#cs
    ;#=#INDEX#===================================================#
    ;#  Title .........: ClipRun.au3
    ;#  Description ...: Run AutoIt script from Clipboard
    ;#  Date ..........: 16.12.08
    ;#  Version .......: 1.3
    ;#  Changes .......: - Hotkey functionality (exclusively for firefox :))
    ;#                   - Added: Pick & Run: run an older temporary script
    ;#                            Kill Script: kills a child process (some example scripts have the tendency to block)
    ;#                            Edit Script: opens script in SciTe (only SciTe supported!)
    ;#                   - if possible, the gui title of the child script is retrieved and used as scriptname (else tmpx.au3)
    ;#                   - the window title is diplayed as TrayToolTip, so the instances can be distinguished.
    ;#                   - improved closing of instances
    ;#                   - this can be called "multithreading"
    ;#  History .......: 1.2 - 15.12.08 (support for the crappy ConsoleWrite function, now reads stdout, auto multi instances)
    ;#                   1.1 - 13.12.08 (improved finding of SciTe - thx to Jos)
    ;#                   1.0 -  9.12.08
    ;#  Author ........: jennico (jennicoattminusonlinedotde)
    ;#                   ©  2008 by jennico
    ;#===========================================================#
#ce

Opt("WinTitleMatchMode",3)
Opt("TrayOnEventMode",1)
Opt("GUIOnEventMode",1)
Opt("TrayAutoPause",0)
Opt("TrayMenuMode",1)

TraySetIcon("Clipbrd.exe",3);^!
TrayCreateItem("Clean up Scripts"&@TAB&"AltGr+D")
    TrayItemSetOnEvent(-1,"_Delete")
    HotKeySet("^!d","_Delete")
TrayCreateItem("")
TrayCreateItem("Pick && &Run Script"&@TAB&"AltGr+R")
    TrayItemSetOnEvent(-1,"_Pick")
    HotKeySet("^!r","_Pick")
TrayCreateItem("&Copy Script"&@TAB&"AltGr+C")
    TrayItemSetOnEvent(-1,"_Copy")
    HotKeySet("^!c","_Copy")
TrayCreateItem("")
TrayCreateItem("&Kill Script"&@TAB&"AltGr+K")
    TrayItemSetOnEvent(-1,"_Kill")
    HotKeySet("^!k","_Kill")
TrayCreateItem("&Edit Script"&@TAB&"AltGr+E")
    TrayItemSetOnEvent(-1,"_Edit")
    HotKeySet("^!e","_Edit")
TrayCreateItem("&Save Script"&@TAB&"AltGr+S")
    TrayItemSetOnEvent(-1,"_Save")
    HotKeySet("^!s","_Save")
TrayCreateItem("")
TrayCreateItem("&Integrate in SciTe"&@TAB&"AltGr+I")
    TrayItemSetOnEvent(-1,"_SciTe")
    HotKeySet("^!i","_SciTe")
TrayCreateItem("")
TrayCreateItem("E&xit"&@TAB&"AltGr+X")
    TrayItemSetOnEvent(-1,"_Exit")
    HotKeySet("^!x","_Exit")

Dim $scriptdir=@ScriptDir,$scriptfpl=@ScriptFullPath,$scriptfpa=FileGetShortName(@ScriptFullPath)
$scite=RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\SciTE.exe","")
Dim $reg=StringReplace($scite,"SciTE.exe",""),$tool,$file,$PID

If $CmdLine[0]=1 Then
    _ClipRun()
    Exit
EndIf

Dim $x=0,$y=0
If WinExists("ClipRun-") Then Dim $pos=WinGetPos("ClipRun-"),$x=$pos[0],$y=$pos[1]

$GUI=GUICreate("ClipRun",60,60,$x,$y,-1,128)
GUICtrlCreateButton("",0,0,60,60,64)
    GUICtrlSetImage(-1,"Clipbrd.exe",3)
    GUICtrlSetOnEvent(-1,"_ClipRun")
GUISetOnEvent(-3,"_Exit")
GUISetState()

WinSetOnTop("ClipRun","",1)
ToolTip("")

While 1
    Sleep(10)
WEnd

Func _ClipRun()
    $PID=Run("Autoit3.exe "&FileGetShortName(_Temp()),@SystemDir,@SW_SHOW,6)
    If $CmdLine[0]=0 Then
        $tmp=$scriptfpa
        If @Compiled=0 Then $tmp="Autoit3.exe "&$scriptfpa
        $2nd=Run($tmp)
        WinSetTitle($gui,"","ClipRun-")
        GUISetState(@SW_HIDE)
    EndIf
    While ProcessExists($PID)
        For $j=0 To 1
            While 1
                If $j=0 Then
                    $line=StdoutRead($PID)
                Else
                    $line=StderrRead($PID)
                EndIf
                If @error Then ExitLoop
                If $line Then
                    _Adlib()
                    Sleep(50)
                    If $CmdLine[0]=1 Then
                        TrayTip(" Console Output : ",$line,5,1+2*$j)
                    Else
                        $pos=WinGetPos($GUI)
                        ToolTip($line,$pos[0]+$pos[2]-15,$pos[1]+$pos[3]-15," Console Output : ",1+2*$j,5)
                    EndIf
                    AdlibEnable("_Adlib",5000)
                EndIf
                $List=WinList()
                For $i = 1 To $List[0][0]
                    $tmp=$List[$i][1]
                    If WinGetProcess($tmp)=$PID And BitAND(WinGetState($tmp),2) Then
                        If $tool=$List[$i][0] Then ExitLoop
                        $tool=$List[$i][0]
                        TraySetToolTip($tool)
                        FileMove($file,StringLeft($file,StringInStr($file,"\",2,-1))&$tool&".au3",1)
                        ExitLoop
                    EndIf
                Next
                Sleep(50)
            Wend
        Next
        Sleep(25)
    WEnd
    If WinExists("ClipRun") Then
        WinSetOnTop("ClipRun","",1)
        Exit
    EndIf
    If $CmdLine[0]=0 And ProcessExists($2nd) Then
        $pos=WinGetPos("ClipRun")
        WinMove("ClipRun","",$pos[0],$pos[1])
        WinSetTitle($gui,"","ClipRun")
        GUISetState(@SW_SHOW)
        ProcessClose($2nd)
    EndIf
    _Adlib()
    AdlibDisable()
    WinSetOnTop("ClipRun","",1)
EndFunc

Func _Pick()
    If _Open()=0 Then _ClipRun()
EndFunc

Func _Edit()
    Run($scite&" "&FileGetShortName(_Temp()))
EndFunc

Func _Copy()
    If _Open()=0 Then _Save()
EndFunc

Func _Save()
    WinSetOnTop("ClipRun","",0)
    If ClipGet()="" Then Return MsgBox(0,"Empty Clipboard","Nothing to save      ")
    $tmp=$tool&".au3"
    If $tmp=".au3" Then $tmp=$file
    $dest=FileSaveDialog("Save ClipRun script - Choose name and destination",$scriptdir&"\" _
        ,"AutoIt3 Scripts (*.aut;*.au3)",18,$tmp)
    WinSetOnTop("ClipRun","",1)
    If @error Then Return
    $open=FileOpen($dest,10)
    FileWrite($open,ClipGet())
    FileClose($open)
EndFunc

Func _SciTe()
    FileCreateShortcut($scriptfpa,@ProgramsCommonDir&"\AutoIt v3\ClipRun  ©  by jennico.lnk" _
        ,"",""," Runs Script from Clipboard","Clipbrd.exe","",1);
    $scitePath=$reg&"\au3.properties"
    If FileExists($scitePath)=0 Then $scitePath=$reg&"\properties\au3.properties"
    $a=FileRead($scitePath)
    If @error Then Return MsgBox(0,"SciTe Path not found.","Please enter the path manually in line 166.      ")
    If StringInStr($a,"Jennico ClipRun") Then Return
    For $i=0 To 40
        If StringInStr($a,"command."&$i)=0 Then
            $open=FileOpen($scitePath,1)
            FileWrite($open,@CRLF&"# "&$i&" Jennico ClipRun"&@CRLF&"command."&$i&'.$(file.patterns.au3)="$(autoit3dir)\AutoIt3.exe" "' _
                &$scriptfpl&'" "$(FilePath)"'&@CRLF&"command.name."&$i&".$(file.patterns.au3)=ClipRun  ©  by jennico"&@CRLF& _
                "command.shortcut."&$i&".$(file.patterns.au3)=Shift+Alt+C"&@CRLF&"command.subsystem."&$i&".$(file.patterns.au3)=2"& _
                @CRLF&"command.save.before."&$i&".$(file.patterns.au3)=2"&@CRLF&"command.replace.selection."&$i& _
                ".$(file.patterns.au3)=0"&@CRLF&"command.quiet."&$i&".$(file.patterns.au3)=1")
            Return FileClose($open)
        EndIf
    Next
EndFunc

Func _Temp()
    $i=0
    SoundPlay(@WindowsDir&"\Media\start.wav")
    While FileExists(@TempDir&"\ClipRun\tmp"&$i&".au3")
        $i+=1
    WEnd
    $file=@TempDir&"\ClipRun\tmp"&$i&".au3"
    $open=FileOpen($file,10)
    FileWrite($open,ClipGet())
    FileClose($open)
    Return $file
EndFunc

Func _Open()
    WinSetOnTop("ClipRun","",0)
    $file=FileOpenDialog("Pick ClipRun script - The highest numbered is the last created" _
        ,@TempDir&"\ClipRun\","ClipRun Scripts (*.au3)",3)
    $err=@error
    If $err=0 Then ClipPut(FileRead($file))
    WinSetOnTop("ClipRun","",1)
    Return $err
EndFunc

Func _Kill()
    ProcessClose($PID)
EndFunc

Func _Delete()
    FileDelete(@TempDir&"\ClipRun\*.au3")
EndFunc

Func _Exit()
    If WinExists("ClipRun-") Then WinClose("ClipRun-")
    Exit
EndFunc

Func _Adlib()
    TrayTip("","",0)
    ToolTip("")
EndFunc
Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

It's very similar to my InstantRun... but not passing from SciTE

Very good work :)

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

thx, i have not come across your script before. :)

edit: well, i tried your script now, but i think it's very different.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

well, 200 views and only one comment ?

don't u like this ? i use it every day !

:) j

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

well, 200 views and only one comment ?

don't u like this ? i use it every day !

:) j

Hi,

Don't worry, i find it very very awesome ! I use it all the time when I want to test script from forum, good work !

[5 stars]

Edit : It would be better that you regroup all temp script in the main tray because at least ive some tray :)

Edit 2 : You can make list of temp scripts in menu tray (not veryuseful but its an example)

Edited by FireFox
Link to comment
Share on other sites

  • Developers

does this work properly with the latest versions of SciTE4AutoIt3?

$scitePath=StringReplace(RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\SciTE.exe","") _
        ,"SciTE.exe","")&"\au3.properties"

All properties files are now located in the subirectory properties.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

@jos: i don't know, i use v 1.74. maybe you can post the correct line if people want to correct this ?

maybe:

$scitePath=StringReplace(RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\SciTE.exe","") ,"SciTE.exe","")&"\Properties\au3.properties"

? thx.

@FireFox : i thought about this, but since the temp scripts don't have names, you will soon forget them. i don't think it makes real sense. instead i added the option to save the current file with a proper name. so if you want to keep it, you can do that.

thank you all !!! i was getting a bit desperate and began to feel lonely in this forum. some kind of attention is always nice for a poor scripter.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

  • Developers

@jos: i don't know, i use v 1.74. maybe you can post the correct line if people want to correct this ?

maybe:

$scitePath=StringReplace(RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\SciTE.exe","") ,"SciTE.exe","")&"\Properties\au3.properties"
Looks good... now how come you haven't upgraded to the latest versions of SciTE4AutoIt3 ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

updated the script according to jos' hint. i hope it is okay like this. so v 1.1 now.

j.

edit: well maybe it's a shame, but i thought ... the newest autoit includes the newest scite .... ???

in fact, i didn't really care about it, but i will do now !

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

I will finish my Scriptner as soon as I can, it will have this functions :

Hotkeys :

-Ctrl+Alt+V = Save clipboard script to tempdir

-Ctrl+Alt+E = Edit last saved script

-Ctrl+Alt+R = Run last saved script

Tray menus :

-Clean all script saved to temp folder

-Refresh tempfolder and create list of temp scripts

-Open temp script folder

-Save temp script to specified directory

Edited by FireFox
Link to comment
Share on other sites

posted new version 1.2

changes:

- console read to tooltip.

- automatic multi instance handling because of console read. (complicated)

- improved handling of scriptdir.

to everyone: please do not use ConsoleWrite when posting your script !

cheers j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

well, then you have a list ion the tray:

tmp0.au3

tmp1.au3

tmp2.au3

tmp3.au3

tmp4.au3

tmp5.au3

tmp6.au3

tmp7.au3

tmp8.au3

tmp9.au3

....

tmp276.au3

why should this be useful ?

i will add the tray option to open tmp directory, okay.

j

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

updated version 1.3 in first post. i partly implemented firefox' ideas, because he gave me 5 stars :)

- Hotkey functionality (exclusively for firefox :))

-- Added: Pick & Run: run an older temporary script

-- Kill Script: kills a child process (some example scripts have the tendency to block)

-- Edit Script: opens script in SciTe (only SciTe supported!)

- if possible, the gui title of the child script is retrieved and used as scriptname (else tmpx.au3)

- the window title is diplayed as TrayToolTip, so the instances can be distinguished.

- improved closing of instances

- this can be called "multithreading"

some remarks on the multiple instances:

my first code simply ran a script and left it alone, being free for the next click.

then i had to change the code, because more and more members use the trendy, but crappy and stupid ConsoleWrite() in their scripts, which affords some kind of console reading. therefore cliprun has to wait until the child script finishes in order to read the std output and display it in a tool/tray tip. consequently, the current cliprun instance is "occupied" and i have had to find a way to enable immediate standby for another script to be executed.

now cliprun opens a second cliprun instance when a child script is being executed (and a third, fourth ... as many as you run child scripts). you will always see only one gui (the "free" one), while the occupied ones are hidden.

though, in the taskbar every instance has its icon. if the child process has a gui with title, the cliprun icon that runs this process will have the title displayed in its traytip. every child process has its own cliprun icon and options menu.

when closing the child process, the parent cliprun instance will be closed as well. you don't have to worry about abandoned instances. if everything works like i want it to, there will no instances be left. this needs some further testing.

please pass me a line if anything does not work as described.

this script has become far more complicated than intended. i just wanted to make a simple tool. now it realizes some kind of multithreading.

well, have fun !

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

Scriptner 1.0

What is it ? Same thing like ClipRun but different !

Functions :

-Check file in temp folder at start

-Check if any AutoIt3 error exists

-Reduce memory itself

Hotkeys :

-Ctrl+Alt+V = Save clipboard script to tempdir

-Ctrl+Alt+E = Edit last saved script

-Ctrl+Alt+R = Run last saved script

-Ctrl+Alt+K = Kill process of autoit

Tray menus :

-Clean all script saved to temp folder

-Refresh tempfolder and create list of temp scripts

-Open temp script folder

-Save temp script to specified directory

Script :

;================================================================================
;#  Title .........: Scriptner.au3                                                #
;#  Description ...: Run AutoIt script from Clipboard                            #
;#  Date ..........: 16.12.08                                                    #
;#  Version .......: 1.0                                                        #
;#  Author ........: FireFox                                                    #
;#           ©  2008 d3mon Corporation                                            #
;================================================================================

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)
;~ Local $FILE
_ReduceMemory(@ScriptName)

$ListM = TrayCreateMenu("List")
TrayCreateItem("Clean List", $ListM)
TrayItemSetOnEvent(-1, "_Clean")
TrayCreateItem("Refresh List", $ListM)
TrayItemSetOnEvent(-1, "_RefreshTempFolder")
$ViewM = TrayCreateMenu("View List", $ListM)
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_Exit")
_RefreshTempFolder()
TraySetToolTip("Scriptner <d3montools>")

If FileFindFirstFile(@TempDir & "\Scriptner\*.au3") = -1 Then
    DirCreate(@TempDir & "\Scriptner")
    Global $NB = 0
Else
    $FIRST = FileFindFirstFile(@TempDir & "\Scriptner\*.au3")
    $TEMPNB = 0
    While 1
        $NEXT = FileFindNextFile($FIRST)
        If @error Then ExitLoop
        $TEMPNB = $TEMPNB + 1
    WEnd
    Global $NB = $TEMPNB
    FileClose($FIRST)
EndIf

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _Clean()
    TrayTip("Scriptner <d3montools>", "Cleaning temp folder...", 3, 4)
    FileDelete(@TempDir & "\Scriptner\*.au3")
    TrayItemDelete($ViewM)
    $ViewM = TrayCreateMenu("View List", $ListM)
    TrayCreateItem("Temp Folder...", $ViewM)
    TrayItemSetOnEvent(-1, "_TempFolder")
    TrayCreateItem("Nothing", $ViewM)
    TrayTip("Scriptner <d3montools>", "Temp folder cleaned !", 3, 4)
    _ReduceMemory(@ScriptName)
EndFunc   ;==>_Clean

Func _RefreshTempFolder()
    TrayItemDelete($ViewM)
    $ViewM = TrayCreateMenu("View List", $ListM)
    TrayCreateItem("Temp Folder...", $ViewM)
    TrayItemSetOnEvent(-1, "_TempFolder")

    $FIRST = FileFindFirstFile(@TempDir & "\Scriptner\*.au3")
    While 1
        $NEXT = FileFindNextFile($FIRST)
        If ($NEXT <> "") Then
            $FILE = TrayCreateItem($NEXT, $ViewM)
;~             $FILE = TrayCreateMenu($NEXT, $ViewM)
;~             TrayCreateItem("Edit", $FILE)
;~             TrayCreateItem("Run", $FILE)
        Else
            ExitLoop
        EndIf
        If @error Then ExitLoop
    WEnd
    FileClose($FIRST)
    _ReduceMemory(@ScriptName)
EndFunc   ;==>_RefreshTempFolder

#Region temp -------------------------------------------------------------
Func _TempFolder()
    ShellExecute("explorer.exe", @TempDir & "\Scriptner")
    _ReduceMemory(@ScriptName)
EndFunc   ;==>_TempFolder
#EndRegion temp -------------------------------------------------------------

#Region While ------------------------------------------------------------
While 1
    Sleep(100)
    If _IsPressed("11") _
            And _IsPressed("12") _
            And _IsPressed("56") Then
        If (ClipGet() <> "") Then
            Global $NB = $NB + 1
            FileWrite(@TempDir & "\Scriptner\temp" & $NB & ".au3", ClipGet())
        EndIf
        _ReduceMemory(@ScriptName)
    EndIf

    If _IsPressed("11") _
            And _IsPressed("12") _
            And _IsPressed("52") Then
        While 1
            If Not _IsPressed("11") Then ExitLoop
        WEnd
        If FileExists(@TempDir & "\Scriptner\Temp" & $NB & ".au3") Then
            Run("Autoit3.exe " & @TempDir & "\Scriptner\temp" & $NB & ".au3")
        Else
            $NBRUN = $NB - 1
            While 1
                If FileExists(@TempDir & "\Scriptner\temp" & $NBRUN & ".au3") Then ExitLoop
                If $NBRUN = -1 Then ExitLoop
                $NBRUN = $NBRUN - 1
            WEnd
            If $NBRUN <> -1 Then
                Run("Autoit3.exe " & @TempDir & "\Scriptner\temp" & $NBRUN & ".au3")
            EndIf
        EndIf
        _ReduceMemory(@ScriptName)
    EndIf

    If _IsPressed("11") _
            And _IsPressed("12") _
            And _IsPressed("45") Then
        While 1
            If Not _IsPressed("11") Then ExitLoop
        WEnd
        If FileExists(@TempDir & "\Scriptner\temp" & $NB & ".au3") Then
            ShellExecute(@TempDir & "\Scriptner\temp" & $NB & ".au3", "", "", "Open")
        Else
            $NBOPEN = $NB - 1
            While 1
                If FileExists(@TempDir & "\Scriptner\temp" & $NBOPEN & ".au3") Then ExitLoop
                If $NBOPEN <= -1 Then ExitLoop
                $NBOPEN = $NBOPEN - 1
            WEnd
            If $NBOPEN <> -1 Then
                ShellExecute(@TempDir & "\Scriptner\temp" & $NBOPEN & ".au3", "", "", "Open")
            EndIf
        EndIf
        _ReduceMemory(@ScriptName)
    EndIf

    If _IsPressed("11") _
            And _IsPressed("12") _
            And _IsPressed("4B") Then
        If ProcessExists("AutoIt3.exe") Then
            ProcessClose("AutoIt3.exe")
            TrayTip("Scriptner <d3montools>", "Process AutoIt3.exe closed !", 2, 1)
        ElseIf ProcessExists("AutoIt3A.exe") Then
            ProcessExists("AutoIt3A.exe")
            TrayTip("Scriptner <d3montools>", "Process AutoIt3A.exe closed !", 2, 1)
        Else
            TrayTip("Scriptner <d3montools>", "No AutoIt process to close !", 2, 1)
        EndIf
    EndIf

    If WinActive("AutoIt Error", "") Then
        WinSetState("AutoIt Error", "", @SW_MINIMIZE)
        $Error = MsgBox(64, "Scriptner <d3montools>", "An Autoit error has been detected !" & @CRLF & "Do you want to open last script ?")
        If $Error = 1 Then
            WinClose("AutoIt Error", "")
            If FileExists(@TempDir & "\Scriptner\temp" & $NB & ".au3") Then
                ShellExecute(@TempDir & "\Scriptner\temp" & $NB & ".au3", "", "", "Open")
            Else
                MsgBox(48, "Scriptner <d3montools>", "Error while opening last script : Not found !")
            EndIf
        EndIf
        _ReduceMemory(@ScriptName)
    EndIf

    TraySetToolTip("Scriptner <d3montools>" & @CRLF & "Last script :" & " temp" & $NB & ".au3")
WEnd
#EndRegion While ------------------------------------------------------------

;===============================================================================
; Function Name: _IsPressed
; Author(s): ezzetabi and Jon
Func _IsPressed($sHexKey, $vDLL = 'user32.dll')
    Local $a_R = DllCall($vDLL, "int", "GetAsyncKeyState", "int", '0x' & $sHexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc   ;==>_IsPressed
;===============================================================================

;===============================================================================
; Function Name: _ReduceMemory
; Author(s): jftuga
Func _ReduceMemory($i_PID = -1)
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf

    Return $ai_Return[0]
EndFunc   ;==>_ReduceMemory
;===============================================================================

Enjoy ! :)

Note : if anyone can help me to make traymenu onevent for all temp script wich I can run them and edit them (of course its variable)

Link to comment
Share on other sites

  • Developers

Scriptner 1.0

What is it ? Same thing like ClipRun but different !

If this is true then why hijack this thread ?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

If this is true then why hijack this thread ?

Jos

Im not hijack this thread, we have just work alone on our own and posted on the same topic our work that's all...

I someone dont like mine, perhaps he would enjoy jennico's one :)

Edited by FireFox
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...