AutoHotkey Community

It is currently May 26th, 2012, 10:51 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: SQL Plus!
PostPosted: September 3rd, 2009, 11:53 am 
Offline

Joined: September 3rd, 2009, 11:26 am
Posts: 93
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 September 4th, 2009, 3:34 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 4th, 2009, 2:41 am 
Offline

Joined: August 10th, 2009, 8:17 am
Posts: 12
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!!'.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 4th, 2009, 3:49 am 
Offline

Joined: August 28th, 2009, 10:33 am
Posts: 7
worked well for me

handy for my tafe class

_________________
i am the walrus. cookookachoo


Report this post
Top
 Profile  
Reply with quote  
 Post subject: SQLPlus - Nice!
PostPosted: October 29th, 2009, 5:32 pm 
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!


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Yahoo [Bot] and 16 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