Jump to content

Can not redeclare a constant


Go to solution Solved by water,

Recommended Posts

Posted (edited)

This is my script to move a window to the left or right side of my screen:

 
HotKeySet("^3", "movemenu")


While 1
    Sleep(10000)
WEnd


Func movemenu()
$Form1 = ''
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Local $ActiefVenster = WinGetTitle("[ACTIVE]", "")
$Form1 = GUICreate("Form1", 125, 100, 265, 142)
$Left =        GUICtrlCreateButton("Left", 16, 8, 89, 25)
$Right =       GUICtrlCreateButton("Right", 16, 32, 89, 25)
$LeftBig =     GUICtrlCreateButton("LeftBig", 16, 64, 89, 25)


GUISetState(@SW_SHOW)


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
 Case $GUI_EVENT_CLOSE
    GuiDelete($Form1)
    Return


Case $Left
  WinMove($ActiefVenster, "",0,0,@DesktopWidth/2,@DesktopHeight-41)
Case $Right
  WinMove($ActiefVenster, "",@DesktopWidth/2,0,@DesktopWidth/2,@DesktopHeight-41)
Case $LeftBig
  WinMove($ActiefVenster, "",0,0,@DesktopWidth*0.65,@DesktopHeight-41)


EndSwitch
WEnd
EndFunc

 

However..

When I use the shortcut, close the GUI and reuse the shortcut for another window movement it gives an error:

File "C:\Program Files (x86)\AutoIt3\Include\ButtonConstants.au3"):

Global Const $BS_GROUPBOX = 0x0007

Global Const ^ ERROR

Error: Can not redeclare a constant

------------------------------------

How can I resolve this error?

Whats wrong in my script?

Edited by remin
Posted

Move the #include directives to the top of your script. They shouldn't be placed in a function!

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Oh.. thank you very much.

Hope you don't mind if I ask you a few more questions...

(or if you prefer that I open new topics please tell it to me)

I'm converting my scripts from autohotkey to autoit.

I noted a few problems.

1) Does autotit has this menu feature ?

    http://www.autohotkey.com/docs/commands/Menu.htm

2) WinGetClientSize gives the size of the client area.

    I need the size of the entire active window.

    Is there no keyword in autoit to do this?

  • Solution
Posted (edited)
  • Autoit offers a few commands to work with menus. The function to use depends on what you want to do (tray menu etc.)
  • WinGetPos returns the position, with and height of a window
Edited by water

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

:D

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 10/15/2013 at 7:37 AM, water said:

 

  • Autoit offers a few commands to work with menus. The function to use depends on what you want to do (tray menu etc.)

 

A little update:

Please see attachment what I wanted to create in autoit

(not a right click menu but a menu like this one which pop-up (where the mouse is) after using a hotkey)

post-48231-0-34033400-1381835976_thumb.j

Posted

Is this a menu you want to "attach" to an application? If yes, which application?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 10/15/2013 at 12:01 PM, water said:

Is this a menu you want to "attach" to an application? If yes, which application?

 

No, it is not attched to an application.

I created this menu in autohotkey.

Its activated by an hotkey. The hotkey pops-up this menu.

I click on it to change case of text.

After clicking on an item, the menu is deleted.

Posted

Can you post the AHK code?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Sure 

^8::       ;; Convert Case MENU
KeyWait, Ctrl


Menu,convert2,Add
Menu,convert2,Delete
menu,convert2,Add,&Upper Case,dcUpper
menu,convert2,Add,&Lower Case,dcLower
menu,convert2,Add,&Title Case,dcTitle
menu,convert2,Add,&Title Case >1,dcTitle>1
menu,convert2,Add,&Sentence Case,dcSentence
Menu,convert2,Show
Return


;---------------------
dcStart:  ;SUB Start
Send, ^x
KeyWait, Ctrl
ClipWait
Return
;---------------------
dcEnd:    ;SUB End
Sleep, 200
Send, ^v
KeyWait, Ctrl
sleep, 200
Return
;---------------------  


dcUpper:
GoSub, dcStart
StringUpper, Clipboard, Clipboard
GoSub, dcEnd
return


dcLower:
GoSub, dcStart
StringLower, Clipboard, Clipboard
GoSub, dcEnd
return


dcTitle:
GoSub, dcStart
StringLower, Clipboard, Clipboard
Clipboard := RegExReplace(Clipboard, "(^|\s|\n^)(\w)", "$1$U2")
GoSub, dcEnd
return


dcTitle>1:
GoSub, dcStart
StringLower, Clipboard, Clipboard
Clipboard := RegExReplace(Clipboard, "(^|\s|\n^)(\w)(\w+)", "$1$U2$3")
GoSub, dcEnd
return


dcSentence:
GoSub, dcStart
StringLower, Clipboard, Clipboard
Clipboard := RegExReplace(Clipboard, "(((^|([.!?]+\s+))[a-z])| i | i')", "$u1")
GoSub, dcEnd
return

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...