AutoHotkey Community

It is currently May 27th, 2012, 9:14 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: October 19th, 2011, 1:52 am 
Offline

Joined: February 16th, 2010, 8:01 am
Posts: 800
Location: SciTE
Download Link: Code tester (Click to see code or right click, and save as, to run it)

Author: jpjazzy

Tools/Scripts used:
Learning Ones post message for a slave script - http://www.autohotkey.com/forum/viewtop ... highlight=

Description:
This is just a simple script to test some of my scripts. I figured some of you guys might find it useful since I didn't see anything out there so I made my own. This script simply tests code. Type in the code box your test code and try it or use F12 over highlighted code to test it. End the code with the specified button or just simply hit F11 to end it. Nothing too complex. Just a nice tool I think.

Screenshots:
http://vvcap.net/db/pA8Hp1xDnRNGuUalxHjW.htp
http://vvcap.net/db/rX00Mtlb8Wggm6d-nrG2.htp
http://vvcap.net/db/mZcKoBOcWg9cIvElTpai.htp

Upates:

    10/19/2011 - Compatibility without interupting standard F-Keys implemented & ability to hide the GUI with F1. From now on you have to hold the keys for about 1 second to execute a command.
    10/18/2011 - Script release date


Code:
Code:
SetTitleMatchMode, 2
OnExit, GuiClose ; On exit, clean up
GuiShowFlag := 1 ; Flag to hide or show the GUI

Gui, Add, Edit, x22 y60 w440 h270 vTempCode WantCtrlA, Input code here
Gui, Font, S10 CDefault Bold, Times New Roman
Gui, Add, Text, x92 y10 w290 h40 +Center, Input Test Code
Gui, Add, Button, x362 y330 w100 h30 gTestTempCode, Test code         ;GUI GENERATION
Gui, Add, Button, x262 y330 w100 h30 gEndTest, End testcode
Gui, Add, Button, x22 y330 w100 h30 gClearTempCode, Clear code
Gui, Show, x127 y87 h379 w479, RealTime Code tester
Return

$F1::
KeyWait, F1, T.5
If !ErrorLevel
{
   Send, {F1}
   return
}
If (GuiShowFlag = 1)
{
   Gui, Hide
   GuiShowFlag--
}
Else If (GuiShowFlag = 0)
{
   Gui, Show
   GuiShowFlag++
}
KeyWait, F1
return

$F11::         ; HOTKEY TO END TEST
KeyWait, F11, T1
If !ErrorLevel
{
   Send, {F11}
   return
}
EndTest:
PostMessage("Slave script", 1)   ; exits/deletes slave script
TrayTip, Status:, Test code ended and deleted.
KeyWait, F11
return

ClearTempCode:
GuiControl,, TempCode,
return

GuiClose:
PostMessage("Slave script", 1)   ; exits/deletes slave script
ExitApp

$F12::         ; HOTKEY TO TEST HIGHLIGHTED CODE
KeyWait, F12, T1
If !ErrorLevel
{
   Send, {F12}
   return
}
GuiControl,, TempCode,
Sleep 200
Clipsave := ClipboardAll
Send, ^c
GuiControl,, TempCode, %Clipboard%
Clipboard := Clipsave
TestTempCode:
DetectHiddenWindows, On
If Winexist("TempTestCode.ahk") ; If the test code is running close it before running a new one.
{
   PostMessage("Slave script", 1)   ; exits/deletes slave script
}
DetectHiddenWindows, Off

Gui, Submit, NoHide
FileAppend,
(
#Persistent
#SingleInstance, Force
Progress, m2 b fs13 Y0 zh0 WMn700, Test script is running
Gui 99: show, hide, Slave script ; hidden message receiver window
OnMessage(0x1001,"ReceiveMessage")
%TempCode%
return

ReceiveMessage(Message) {
   if Message = 1
   ExitApp
}
), %A_ScriptDir%\TempTestCode.ahk
Run, %A_ProgramFiles%\AutoHotkey\AutoHotkey.exe "%A_ScriptDir%\TempTestCode.ahk" ; run script
Sleep, 100
IfWinExist, ahk_class #32770      ; IF THERE IS AN ERROR LOADING THE SCRIPT SHOW THE USER
{
   Sleep 20
   WinActivate, ahk_class #32770
   Clipsave := ClipboardAll
   Send, ^c
   CheckWin := Clipboard
   Clipboard := Clipsave
   IfInString, CheckWin, The program will exit.
   {
   IfExist, %A_ScriptDir%\TempTestCode.ahk
   FileDelete, %A_ScriptDir%\TempTestCode.ahk
   TrayTip, ERROR, Error executing the code properly
   return
   }
}
TrayTip, Status:, Test code is now running on your machine.
return

; ===================================================== FUNCTIONS ==================================================
PostMessage(Receiver, Message) {                                   
   oldTMM := A_TitleMatchMode, oldDHW := A_DetectHiddenWindows
   SetTitleMatchMode, 3
   DetectHiddenWindows, on
   PostMessage, 0x1001,%Message%,,, %Receiver% ahk_class AutoHotkeyGUI
   SetTitleMatchMode, %oldTMM%                                              ; POST MESSAGE TO END THE TEST SCRIPT AND DELETE IT
   DetectHiddenWindows, %oldDHW%                                                ; Thank you to learning one for this example function
   IfExist, %A_ScriptDir%\TempTestCode.ahk
   FileDelete, %A_ScriptDir%\TempTestCode.ahk
}

_________________
AutoHotkey Basic - Windows 7
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 1st, 2011, 6:14 am 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
Very cool. Just what I needed. So many times I copy and pasted from the forum in to my editor, saved it then ran it, then deleted the temp.ahk file.

This does it much quicker and cleaner.

_________________
Check out my scripts.
(MyIpChanger) (XPSnap) (SavePictureAs)

All my scripts are tested on Windows 7, AutoHotkey_L 32 bit Ansi unless otherwise stated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 1st, 2011, 7:24 am 
Offline

Joined: February 16th, 2010, 8:01 am
Posts: 800
Location: SciTE
Thank you. This is definitely not the first of it's type, but I liked the layout of it and I use it frequently now when posting code in the "Ask for help" section. If you notice any bugs or things that could be improved, let me know. Thanks again and cheers.

_________________
AutoHotkey Basic - Windows 7
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Rajat, SKAN and 8 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group