 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Tue Jul 22, 2008 8:34 am Post subject: |
|
|
For the first problem, you need to tell the script what to do OnExit before the first return of the script, right now the OnExit command is not being reached. Also, you formatted it a bit wrong. Your code should look like this:
| Code: |
IniRead, Checkbox, MyScript.ini, MyItems, Checkbox
;-------------------------------------------------------------
Menu, MyMenu, Add, &MenuItem, ToggleState
Menu, MenuBar, Add, &FirstMenu, :MyMenu
Gui, Menu, MenuBar
Menu, MyMenu, % (CheckBox) ? "Check" : "Uncheck", &MenuItem
OnExit, CheckboxStatus
Return
;-------------------------------------------------------------
SetTimer, AutoRun, 1000
GoSub, MyFunction
;-------------------------------------------------------------
ToggleState:
menu, MyMenu, ToggleCheck, &MenuItem
GoSub, MyFunction
return
;-------------------------------------------------------------
MyFunction:
if(Checkbox)
{
SetTimer, AutoRun, On
}
else
{
SetTimer, AutoRun, Off
}
Checkbox := !Checkbox
return
;-------------------------------------------------------------
GuiClose:
CheckboxStatus:
IniWrite, %Checkbox% , MyScript.ini, MyItems, Checkbox
ExitApp
;GuiClose: ;works better to have only one label for closing
;ExitApp
;-------------------------------------------------------------
|
Also, note that the code in the olive brown color will never be executed, since there is a return above it. If you want it to be run when the script starts, put it at the top under the IniRead command.
For your second question, that seems strange. If you are using relative coordinates for the MouseMove, then if the Menu is active at the time that might cause problems... Although the mouse should still move, just maybe not to the right place. |
|
| Back to top |
|
 |
Logman
Joined: 19 Feb 2008 Posts: 55
|
Posted: Tue Jul 22, 2008 9:26 am Post subject: |
|
|
Fair enough, that explains a whole lot about the errors I make . Got a lot to think over, thanks for your help once again. |
|
| Back to top |
|
 |
Logman
Joined: 19 Feb 2008 Posts: 55
|
Posted: Thu Jul 24, 2008 3:27 am Post subject: |
|
|
I now have more menu's than a large restaurant . But I am still having this mouseover problem. My script has an 'includes' folder and the part with the mouseover is in an ahk there. Now the funny part is that I have an almost identical version that has the mouseover working. But since I put the menus in, whilst I can still see this function attempting to click the buttons (can see flashing), the mouse is not moving. The function won't work without mouseover, the buttons flash but don't click. So what are the possibilities of why a function can be working (because the buttons are flashing) but a mouseover doesn't happen, when this same function (and I copy and pasted it to make sure it is identical) works in an almost identical script  |
|
| Back to top |
|
 |
Logman
Joined: 19 Feb 2008 Posts: 55
|
Posted: Thu Jul 24, 2008 3:50 am Post subject: |
|
|
| Krogdor wrote: | | If you are using relative coordinates for the MouseMove, then if the Menu is active at the time that might cause problems... Although the mouse should still move, just maybe not to the right place. |
The co-ordinates are just the straight up co-ordinates of a button that is in a window that doesn't change in character at all. |
|
| Back to top |
|
 |
Logman
Joined: 19 Feb 2008 Posts: 55
|
Posted: Thu Jul 24, 2008 4:15 am Post subject: |
|
|
| I do have menu's in the working script, just without checkboxes in them. I know that sounds completely irrelevant but I really can't see any difference in these two scripts... |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Thu Jul 24, 2008 4:22 am Post subject: |
|
|
That seems weird...
Are any of the settings different? SendMode, KeyDelay, etc? |
|
| Back to top |
|
 |
Logman
Joined: 19 Feb 2008 Posts: 55
|
Posted: Thu Jul 24, 2008 4:44 am Post subject: |
|
|
I went through and cut pasted a whole heap of stuff and it's started working. I recently started to use the #includes method with another folder- perhaps in that process I misplaced the juncture of one of the extra ahk's but who knows . On another matter,I have a bunch of pictures and icons in the gui, is it possible to put them into an includes folder without using a path or must they stay in the main folder? I send my script to other people so paths are not an option-have tried but with no success. |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Thu Jul 24, 2008 5:11 am Post subject: |
|
|
| Well you could do something like have the user specify a directory, and then include that directory as a variable before all of the files. Or set the working directory to a different location. |
|
| Back to top |
|
 |
Logman
Joined: 19 Feb 2008 Posts: 55
|
Posted: Thu Jul 24, 2008 5:23 am Post subject: |
|
|
mmm, was trying to avoid that, some of the users need help turning their PC on . Not to worry, just a neatness thing, I was hoping to get the main folder down to the main ahk and the preferences file but I notice that ahk writers far more savvy than me have icons in their main folder so I thought it was a long shot. I pretty much have my script ready, it is far more user friendly now, thanks again  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|