Sign in to follow this  
Followers 0
Dolemite50

Toolbars for other programs

15 posts in this topic

Hi,

If I design a toolbar for Notepad, how do I go about setting it to always run when Notepad is open, and only appear when Notepad is the active window?

Thanks a lot.

Share this post


Link to post
Share on other sites



Well you could make the script execute notepad and then use your script instead of opening notepad

or

Have the script running and keep looking for a notepad process... I would suggest the first, though you wont be able to open a text file...


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Have a look at:

While 1
    If WinExist("classname=Notepad") And BitAND(WinGetState("classname=Notepad"), 2) Or WinActive("title, or handle to your toolbar window") Then
        ; Do whatever here
    Else
        ; Hide toolbar here
    EndIf

    Sleep(100)
WEnd

Well you could make the script execute notepad and then use your script instead of opening notepad

or

Have the script running and keep looking for a notepad process... I would suggest the first, though you wont be able to open a text file...

That's not right, you could make your application accept command-line parameters

Look at $CmdLine[0] in the helpfile

Edit:

Added onto example code.

Edit2:

Added further onto example code.

Edited by FreeFry

Share this post


Link to post
Share on other sites

Well you could make the script execute notepad and then use your script instead of opening notepad

or

Have the script running and keep looking for a notepad process... I would suggest the first, though you wont be able to open a text file...

Thanks again. :whistle:

I think I can get by with just launching my toolbars seperately, but what I'm not sure of is how I would go about making my toolbar "a part" of the program so that if I minimize the app, it minimizes. If I launch another app on top of that window, the toolbar is not shown. If I close the app, the toolbar closes, etc. Is that possible?

Share this post


Link to post
Share on other sites

That's the second time you responded while I was responding to the first response, I hope you don't think I was ignoring you. :whistle:

I think that you pretty much answered my first question, and brought up another. The manual was a little vague on the command-line parameters so I've been trying to find an example of how to do something like this:

Create a toolbar that has seperate options for different apps.

Store the different apps' toolbar options in seperate ini files. (Notepad.ini, Calculator.ini,..etc)

Launch the Toolbar with a parameter so that it can choose the ini dynamically: Run("MyToolbar.exe Notepad")

Possible?

Thanks again. :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hehe, no worries.

That will be hard to find an example of. But, it's very possible:)

Check out:

IniWrite and IniRead

The $CmdLine array works like this:

$CmdLine[0] contains the number of parameters, in other words:

program.exe paramter1 paramter2 "parameter 3" < -- note that parameters with spaces in them needs to be contained inside quotes " "

Running your program with that example, would set $CmdLine[0] to 3

$CmdLine[1] = parameter1

$CmdLine[2] = parameter2

$CmdLine[3] = "parameter 3"

Note: that what you want to do would not require the use of command-lines...

You could just detect the window that is active, and load the required settings for that specific application(though this would require quite extensive coding it's the most dynamic one, BUT the first example - using command-lines, is the much easier one.

Edited by FreeFry

Share this post


Link to post
Share on other sites

Hehe, no worries.

That will be hard to find an example of. But, it's very possible:)

Check out:

IniWrite and IniRead

The $CmdLine array works like this:

$CmdLine[0] contains the number of parameters, in other words:

program.exe paramter1 paramter2 "parameter 3" < -- note that parameters with spaces in them needs to be contained inside quotes " "

Running your program with that example, would set $CmdLine[0] to 3

$CmdLine[1] = parameter1

$CmdLine[2] = parameter2

$CmdLine[3] = "parameter 3"

Note: that what you want to do would not require the use of command-lines...

You could just detect the window that is active, and load the required settings for that specific application(though this would require quite extensive coding it's the most dynamic one, BUT the first example - using command-lines, is the much easier one.

Thanks man, I think I'm starting to get it now. For some reason I thought the $CmdLine array was what you used to send to your script, not receive. So if I launch with "Toolbar.exe APPNAME", I could load the APPNAME's ini with something like this?

IniRead(@ScriptDir & "\iniFolder\" & $CmdLine[1] & ".ini")

BTW, here's the newbie question of the week:

"...ahem....How do I create an EXE with parameters?" :whistle:

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hehe, I'm glad to hear that you learned something new. :lol:

So if I launch with "Toolbar.exe APPNAME", I could load the APPNAME's ini with something like this?

IniRead(@ScriptDir & "\iniFolder\" & $CmdLine[1]& ".ini")

Yes, that's exactly how you would do it! (though, I would recommend checking $CmdLine[0]:

If $CmdLine[0] < 1 Then Exit

Otherwise if someone would run the program without command-line parameters, it would crash with an error message :)

And for your other question:

You don't really "create" programs with parameters. They handle parameters -just like yours would do with that above code.

Actually, any program can be run with command-line parameters, but only those that are coded to support/accept/read them, will do so. :whistle:

Edit:

lol, if that last one was a joke, I blame me for not sleeping for over 15 hours ;p

Edited by FreeFry

Share this post


Link to post
Share on other sites

Okay, whatever suits you best. :whistle:

Or wait a minute...

Did you mean to ask how you run a program with command-line parameters?

Share this post


Link to post
Share on other sites

Have a look at:

While 1
    If WinExist("classname=Notepad") And BitAND(WinGetState("classname=Notepad"), 2) Or WinActive("title, or handle to your toolbar window") Then
        ; Do whatever here
    Else
        ; Hide toolbar here
    EndIf

    Sleep(100)
WEnd

That's not right, you could make your application accept command-line parameters

Look at $CmdLine[0] in the helpfile

Edit:

Added onto example code.

Edit2:

Added further onto example code.

You will still have to acosiate your script with txt ... So I can doubleclick a test.txt file and the script is loading :whistle:


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

Yes, but that is easily done. :whistle:

Share this post


Link to post
Share on other sites

That would be my creation along with many wonderful folks helping out. There is a new version on the way, so stay tuned.

The way I dock it now is like this:

$gui = GUICreate("SciTE Toolbar", 20, 19, 350, 0, $WS_POPUP, $WS_EX_NOACTIVATE + $WS_EX_TOOLWINDOW)

I do a winmove to get it in the correct position after it builds, but that is the basics.

Share this post


Link to post
Share on other sites

Zeee creator of zee Scite Toolbar??

**Gomer Pyle voice: "Well Volllllyyyyyyyy!"

Thanks, I've actually been locking horns with that one for a few days straight now. I started by going through it line for line with the manual and added comments for every item, but had to give a best guess in a few spots. I think I have a decent grasp of how it works now and I can customize it a bit, but I'm still a little hazy on a few things. If you find the time, can you enlighten me?

If _Singleton("SciTEButtons\a5s1df60a6er6e54z", 1) = 0

Where in the heck did "a5s1df60a6er6e54z" come from?

;~ GUICtrlCreateGraphic ( left, top [, width [, height [, style]]] )
;~   $SS_GRAYFRAME Specifies a box with a frame drawn in same color as screen bg, -gray in the default scheme
    GUICtrlCreateGraphic($Count, 0, 1, 24, $SS_GRAYFRAME)
    GUICtrlSetBkColor(-1, 0xFF0000)
;~  GUICtrlSetResizing( controlID, resizing )-Defines the resizing method used by a control.
;~ $GUI_DOCKALL  -- control will not move during resizing
    GUICtrlSetResizing(-1, $GUI_DOCKALL)
    GUICtrlCreateGraphic($Count + 1, 0, 1, 24)
    GUICtrlSetBkColor(-1, 0xffffff)

It looks like this draws a darker and lighter line next to each other for a divider, but I don't understand the whole grayframe part. The manual says that gray is the default scheme, so I thought it was being used to match the color of the main toolbar,.. but when each control is only 1px wide and assigned to use a bg color; what is "create graphic" and "grayframe" actually doing? Would using a 1x24 label and setting the bg color be doing the same thing?

$gui = GUICreate("SciTE Toolbar", 20, 19, 350, 0, $WS_POPUP, $WS_EX_NOACTIVATE + $WS_EX_TOOLWINDOW)

I was unable to find $WS_EX_NOACTIVATE in the manual, but saw you defined it earlier as 0x8000000. What does that refer to?

DllCall("user32.dll", "int", "SetParent", "hwnd", $gui, "hwnd", $hwnd)

This "looks" like it might be the answer to my initial post. When you assign $gui "SetParent" to $hwnd, what is that saying?

I also have a question on your loop for creating the buttons. I'm creating a floating Toolbar with a bg image. It will vary in length based on number of options, so a static image won't do. I'm going to try cutting it into four slices (Left(20w x 40h), Right(20w x 40h), Div(20w x 40h), and Mid(40x40 ). That way I can create the left and right parts before/after the loop, throw in divs where need be,.and have the mid section tile once for each icon added. Is there going to be any issues with setting a bg image and then overlapping it with an icon for every option? Is there a better way to go about it? Any example floating around that I haven't found yet?

Well I think that's about it. Hat's off once again for a great example. I really appreciate it.

Share this post


Link to post
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
Sign in to follow this  
Followers 0