AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SQL Plus!

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
xXDarknessXx



Joined: 03 Sep 2009
Posts: 93

PostPosted: Thu Sep 03, 2009 10:53 am    Post subject: SQL Plus! Reply with quote

In tafe i was bored so i made an easier way to use SqlPlus from Oracle, SqlPlus didnt allow editing what you have typed unless u backspace back to the error and retype the sentance, with my script it adds a bar at the bottom of the window that you can type in and edit openly.

some shortcuts I have added are:

Hold Left Alt = Makes the edit bar at the bottom invisible\transparent.

Control+Up Arrow = Get Previously sent commands [i dont know how deep this goes]

Control+Down Arrow = Get Next sent commands


Code:
#SingleInstance Force
SetControlDelay -1

IfNotExist , AutoSQL+.ini
{
   IniWrite , DEFAULT, AutoSQL+.ini , Settings , UserName
   IniWrite , DEFAULT , AutoSQL+.ini , Settings , Password
   runwait AutoSQL+.ini
}

IfWinNotExist, ahk_class SqlplusWClass
{
   IniRead , USER, AutoSQL+.ini , Settings ,  UserName
   IniRead , PASS, AutoSQL+.ini , Settings ,  Password
   
   run C:\ora\devsuite10\BIN\sqlplusw.exe S%USER%/%PASS%@stud ;~ Put the path of the sqlplusw.exe
   winwait, ahk_class SqlplusWClass
   goto SQLEasy
}
Else
{
   WinActivate, ahk_class SqlplusWClass
   goto SQLEasy
}
return
   
SQLEasy:
Gui 1: -caption
Gui 1: +ToolWindow +AlwaysOnTop +border
Gui 1: color , White
Gui 1: font, s10 w700 , Verdana
GuiHidden = 0
WinGetPos , posX, posY, winW, winH, ahk_class SqlplusWClass

newY := posY + winH - 67
newX := posX + 3
newW := winW - 26

editW := newW - 85
butX := 5 + editW
miniX := winW - 40

Gui 1: Add, Edit, x0 y0 w%editW% h45 vSQLEdit +Center +Multi
Gui 1: Add, Button, x%butX% y5 w55 h35 Default, Enter
Gui 1: Add, Button, x%miniX% y0 w15 h45 vHider, >

SetTimer , moveToolbar , 10
refresh:
Gui 1: Show, x%newX% y%newY% w%newW% h45, Easy SQL
GuiControl,, SQLEdit,
GuiControl, Focus, SQLEdit
Return

moveToolbar:
IfWinActive, ahk_class SqlplusWClass
{
   WinGetPos , posX, posY, winW, winH, ahk_class SqlplusWClass
   
   newY := posY + winH - 67
   
   if(GuiHidden = 1)
   {
      newX := posX + winW - 37
      newW := 14
      miniX = 0
   }
   Else
   {
      newX := posX + 3
      newW := winW - 26

      editW := newW - 85
      butX := 5 + editW
      miniX := winW - 40
      
      GuiControl, Move, SQLEdit, x0 y0 w%editW% h45
      GuiControl, Move, Enter, x%butX% y5
   }
   
   GuiControl, Move, Hider, x%miniX% y0

   Gui 1: Show, NoActivate x%newX% y%newY% w%newW% h45, Easy SQL
}
else
{
   IfWinNotActive, Easy SQL
   {
       Gui 1: hide
   }
}

IfWinNotExist, ahk_class SqlplusWClass
{
   exitapp
}
SetTimer , moveToolbar , 10
return

#IfWinActive, Easy SQL
{
   Enter::
   NumpadEnter::
   ButtonEnter:
      SentCount++
      CommandNumber = %SentCount%
      Gui 1: Submit , NoHide
      WinActivate , ahk_class SqlplusWClass
      WinWaitActive, ahk_class SqlplusWClass
      ControlSend , , %SQLEdit%; , ahk_class SqlplusWClass
      ControlSend , , {Enter} , ahk_class SqlplusWClass
      Command%SentCount% = %SQLEdit%
      Gui 1: show
      GuiControl, Focus, SQLEdit
      SendInput, {end}
      SendInput, ^a
   return
   
   ^Up::
      if(CommandNumber > 1)
         CommandNumber--
      newCommand := Command%CommandNumber%
      GuiControl,, SQLEdit, %newCommand%
   Return
   
   ^Down::
      if(CommandNumber < SentCount)
         CommandNumber++
      newCommand := Command%CommandNumber%
      GuiControl,, SQLEdit, %newCommand%
   Return
   
   LAlt::
      Winset, trans , 10 , Easy SQL
   return
   
   LAlt up::
      Winset, trans , off , Easy SQL
   return
}

Button>:
   WinGetPos , posX, posY, winW, winH, ahk_class SqlplusWClass
   newY := posY + winH - 67
   
   if(GuiHidden = 0)
   {
      newX := posX + winW - 37
      newW := 14
      miniX = 0
      
      GuiHidden = 1
      GuiControl, Hide, SQLEdit
      GuiControl, Hide, Enter
      GuiControl,, Hider, <
   }
   Else
   {
      newX := posX + 3
      newW := winW - 26

      editW := newW - 85
      butX := 5 + editW
      miniX := winW - 40
      
      GuiHidden = 0
      GuiControl, Show, SQLEdit
      GuiControl, Show, Enter
      
      GuiControl,, Hider, >
   }

   GuiControl, Move, Hider, x%miniX% y0
   Gui 1: Show, NoActivate x%newX% y%newY% w%newW% h45, Easy SQL
return

GuiClose:
ExitApp


I was wondering if i can have some input, like how i could improve this =][/u]


Last edited by xXDarknessXx on Fri Sep 04, 2009 2:34 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
ZANZA



Joined: 10 Aug 2009
Posts: 12

PostPosted: Fri Sep 04, 2009 1:41 am    Post subject: Reply with quote

hey works great!

ty
_________________
Beta. Software undergoes beta testing shortly before it's released. Beta is Latin for "still doesn't work."

The programmer's national anthem is 'AAAAAAAARRRRGHHHHH!!'.
Back to top
View user's profile Send private message Visit poster's website
alexizle



Joined: 28 Aug 2009
Posts: 7

PostPosted: Fri Sep 04, 2009 2:49 am    Post subject: Reply with quote

worked well for me

handy for my tafe class
_________________
i am the walrus. cookookachoo
Back to top
View user's profile Send private message
bbunk
Guest





PostPosted: Thu Oct 29, 2009 4:32 pm    Post subject: SQLPlus - Nice! Reply with quote

simple idea:

had you thought about any way to display the command number in the window, to show where you are in the list (also wrap-around)

more complex thoughts:

it might be very useful to expand the ini usage to contain multiple login sources, with varied userids and passwords; i suppose a login GUI would use the ini data for this

the ini might be able to contain often-used commands (text), that could be saved or recalled by hotkey and/or GUI interface.

All in all, i'm loooking forward to using this as is to be more productive.

Thanks!
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group